// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/main.c
// Function: test_page_fault
static void test_page_fault(void)
{
	DBG_INFO("start page fault test");

	int rc = mmap(PAGE_SIZE, 2 * PAGE_SIZE, 0);
	char *ptr = (char *)PAGE_SIZE;

	if (rc)
		DBG_ERR("mmap failed with error %s", errstr(rc));

	for (int i = 0; i != PAGE_SIZE; ++i)
		DBG_ASSERT(ptr[i] == 0);
	munmap(PAGE_SIZE, 2 * PAGE_SIZE);

	rc = mmap(PAGE_SIZE, 2 * PAGE_SIZE, VMA_PERM_WRITE);

	if (rc)
		DBG_ERR("mmap failed with error %s", errstr(rc));

	for (int i = 0; i != PAGE_SIZE; ++i)
		ptr[i] = (char)i;

	for (int i = 0; i != PAGE_SIZE; ++i)
		DBG_ASSERT(ptr[i] == (char)i);
	munmap(PAGE_SIZE, 2 * PAGE_SIZE);

	DBG_INFO("finish page fault test");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
leaq 0x11265(%rip), %rdi     # 0xffffffff80112144
leaq 0x11262(%rip), %rsi     # 0xffffffff80112148
movl $0x33, %edx
leaq 0x112be(%rip), %rcx     # 0xffffffff801121b0
movb $0x0, %al
callq 0xffffffff80101e60
movl $0x1000, %edi           # imm = 0x1000
movl $0x2000, %esi           # imm = 0x2000
xorl %edx, %edx
callq 0xffffffff80110000
movl %eax, -0x4(%rbp)
movl $0x1000, %eax           # imm = 0x1000
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x4(%rbp)
je 0xffffffff80100f48
movl -0x4(%rbp), %edi
callq 0xffffffff8010d240
movq %rax, %r8
leaq 0x1124b(%rip), %rdi     # 0xffffffff80112179
leaq 0x11213(%rip), %rsi     # 0xffffffff80112148
movl $0x39, %edx
leaq 0x11285(%rip), %rcx     # 0xffffffff801121c6
movb $0x0, %al
callq 0xffffffff80101e60
movl $0x0, -0x14(%rbp)
movslq -0x14(%rbp), %rax
cmpq $0x1000, %rax           # imm = 0x1000
je 0xffffffff80100fac
jmp 0xffffffff80100f5d
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0xffffffff80100f9d
leaq 0x11204(%rip), %rdi     # 0xffffffff80112179
leaq 0x111cc(%rip), %rsi     # 0xffffffff80112148
movl $0x3c, %edx
leaq 0x111f5(%rip), %rcx     # 0xffffffff8011217d
leaq 0x11251(%rip), %r8      # 0xffffffff801121e0
movb $0x0, %al
callq 0xffffffff80101e60
callq 0xffffffff80111cd0
jmp 0xffffffff80100f9b
jmp 0xffffffff80100f9f
jmp 0xffffffff80100fa1
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xffffffff80100f4f
movl $0x1000, %edi           # imm = 0x1000
movl $0x2000, %esi           # imm = 0x2000
callq 0xffffffff80110400
movl $0x1000, %edi           # imm = 0x1000
movl $0x2000, %esi           # imm = 0x2000
movl $0x1, %edx
callq 0xffffffff80110000
movl %eax, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
je 0xffffffff80101004
movl -0x4(%rbp), %edi
callq 0xffffffff8010d240
movq %rax, %r8
leaq 0x1118f(%rip), %rdi     # 0xffffffff80112179
leaq 0x11157(%rip), %rsi     # 0xffffffff80112148
movl $0x42, %edx
leaq 0x111c9(%rip), %rcx     # 0xffffffff801121c6
movb $0x0, %al
callq 0xffffffff80101e60
movl $0x0, -0x18(%rbp)
movslq -0x18(%rbp), %rax
cmpq $0x1000, %rax           # imm = 0x1000
je 0xffffffff80101032
movl -0x18(%rbp), %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xffffffff8010100b
movl $0x0, -0x1c(%rbp)
movslq -0x1c(%rbp), %rax
cmpq $0x1000, %rax           # imm = 0x1000
je 0xffffffff8010109b
jmp 0xffffffff80101047
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl -0x1c(%rbp), %ecx
movsbl %cl, %ecx
cmpl %ecx, %eax
je 0xffffffff8010108c
leaq 0x11115(%rip), %rdi     # 0xffffffff80112179
leaq 0x110dd(%rip), %rsi     # 0xffffffff80112148
movl $0x48, %edx
leaq 0x11106(%rip), %rcx     # 0xffffffff8011217d
leaq 0x1116e(%rip), %r8      # 0xffffffff801121ec
movb $0x0, %al
callq 0xffffffff80101e60
callq 0xffffffff80111cd0
jmp 0xffffffff8010108a
jmp 0xffffffff8010108e
jmp 0xffffffff80101090
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xffffffff80101039
movl $0x1000, %edi           # imm = 0x1000
movl $0x2000, %esi           # imm = 0x2000
callq 0xffffffff80110400
leaq 0x11093(%rip), %rdi     # 0xffffffff80112144
leaq 0x11090(%rip), %rsi     # 0xffffffff80112148
movl $0x4b, %edx
leaq 0x1113a(%rip), %rcx     # 0xffffffff801121fe
movb $0x0, %al
callq 0xffffffff80101e60
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)