#include "kernel/types.h"
#include "kernel/stat.h"
#include "user/user.h"

#define PGSIZE (1 << 12)

int
main()
{
  int *topOfHeap = (int *)sbrk(1) + PGSIZE / sizeof(int);
  int *mmap_addr = topOfHeap + 2 * PGSIZE / sizeof(int);

  if (mmap((uint64)mmap_addr) > 0) {
    printf("mmap successful\n");
  };

  if (mmap((uint64)mmap_addr + 4 * PGSIZE) > 0) {
    printf("mmap successful\n");
  };

  *mmap_addr = 4;

  if (munmap((uint64)mmap_addr) > 0) {
    printf("munmap successful\n");
  }

  if (sbrk(3 * PGSIZE) > 0) {
    printf("sbrk successful\n");
  } else {
    printf("sbrk unsuccessful\n");
  }

  if (*mmap_addr == 4) {
    printf("wrong impl\n");
  }
}
