// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/paging.c
// Function: map_range_large
static int map_range_large(pte_t *pml4, virt_t from, virt_t to, phys_t phys,
			pte_t flags)
{
	const int rc = __pt_populate_range(pml4, from, to, flags | PTE_LARGE);
	const pte_t page_flags = PTE_WRITE | PTE_PRESENT;

	if (rc)
		return rc;

	struct pt_iter iter;

	for_each_slot_in_range(pml4, from, to, iter) {
		const int level = iter.level;
		const int index = iter.idx[level];
		pte_t *pt = iter.pt[level];

		DBG_ASSERT(level == 1 || level == 0);
		DBG_ASSERT(!pte_present(pt[index]));

		if (level == 1) {
			pt[index] = phys | page_flags | PTE_LARGE;
			phys += PML1_SIZE;
		} else {
			pt[index] = phys | page_flags;
			phys += PAGE_SIZE;
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rcx
orq $0x80, %rcx
callq 0xffffffff80105560
movl %eax, -0x34(%rbp)
movq $0x3, -0x40(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0xffffffff80106ae7
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xffffffff80106c7b
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x80(%rbp), %rdi
callq 0xffffffff80105050
movq %rax, -0x88(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x88(%rbp)
movb %al, -0x99(%rbp)
je 0xffffffff80106b29
movq -0x88(%rbp), %rax
movq 0x38(%rax), %rax
cmpq -0x20(%rbp), %rax
setb %al
movb %al, -0x99(%rbp)
movb -0x99(%rbp), %al
testb $0x1, %al
jne 0xffffffff80106b38
jmp 0xffffffff80106c74
movl -0x80(%rbp), %eax
movl %eax, -0x8c(%rbp)
movslq -0x8c(%rbp), %rax
movl -0x58(%rbp,%rax,4), %eax
movl %eax, -0x90(%rbp)
movslq -0x8c(%rbp), %rax
movq -0x78(%rbp,%rax,8), %rax
movq %rax, -0x98(%rbp)
cmpl $0x1, -0x8c(%rbp)
je 0xffffffff80106ba6
cmpl $0x0, -0x8c(%rbp)
je 0xffffffff80106ba6
leaq 0xb5fb(%rip), %rdi      # 0xffffffff80112179
leaq 0xba72(%rip), %rsi      # 0xffffffff801125f7
movl $0x17c, %edx            # imm = 0x17C
leaq 0xb5ec(%rip), %rcx      # 0xffffffff8011217d
leaq 0xbb07(%rip), %r8       # 0xffffffff8011269f
movb $0x0, %al
callq 0xffffffff80101e60
callq 0xffffffff80111cd0
jmp 0xffffffff80106ba4
jmp 0xffffffff80106ba8
jmp 0xffffffff80106baa
movq -0x98(%rbp), %rax
movslq -0x90(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xffffffff801051c0
testb $0x1, %al
jne 0xffffffff80106bc7
jmp 0xffffffff80106bf6
leaq 0xb5ab(%rip), %rdi      # 0xffffffff80112179
leaq 0xba22(%rip), %rsi      # 0xffffffff801125f7
movl $0x17d, %edx            # imm = 0x17D
leaq 0xb59c(%rip), %rcx      # 0xffffffff8011217d
leaq 0xbad0(%rip), %r8       # 0xffffffff801126b8
movb $0x0, %al
callq 0xffffffff80101e60
callq 0xffffffff80111cd0
jmp 0xffffffff80106bf4
jmp 0xffffffff80106bf8
cmpl $0x1, -0x8c(%rbp)
jne 0xffffffff80106c32
movq -0x28(%rbp), %rdx
orq $0x3, %rdx
orq $0x80, %rdx
movq -0x98(%rbp), %rax
movslq -0x90(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
addq $0x200000, %rax         # imm = 0x200000
movq %rax, -0x28(%rbp)
jmp 0xffffffff80106c5a
movq -0x28(%rbp), %rdx
orq $0x3, %rdx
movq -0x98(%rbp), %rax
movslq -0x90(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
addq $0x1000, %rax           # imm = 0x1000
movq %rax, -0x28(%rbp)
jmp 0xffffffff80106c5c
movq -0x88(%rbp), %rdi
callq 0xffffffff80105320
movq %rax, -0x88(%rbp)
jmp 0xffffffff80106aff
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)