// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/mm.c
// Function: _mmap_pages
void __mmap_pages(struct mm *mm, virt_t addr, struct page **pages, pfn_t count,
			unsigned long flags)
{
	DBG_ASSERT((addr & PAGE_MASK) == 0);

	const virt_t from = addr;
	const virt_t to = from + ((virt_t)count << PAGE_BITS);

	struct pt_iter iter;
	pfn_t i = 0;

	for_each_slot_in_range(page_addr(mm->pt), from, to, iter) {
		DBG_ASSERT(iter.level == 0);
		DBG_ASSERT(iter.pt[iter.level] != 0);

		struct page *page = pages[i++];
		const phys_t paddr = page_paddr(page);
		const int index = iter.idx[iter.level];
		pte_t *pt = iter.pt[iter.level];

		get_page(page);
		pt[index] = paddr | flags | PTE_PRESENT;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x10(%rbp), %rax
andq $0xfff, %rax            # imm = 0xFFF
cmpq $0x0, %rax
je 0xffffffff801108ce
leaq 0x18d3(%rip), %rdi      # 0xffffffff80112179
leaq 0x2693(%rip), %rsi      # 0xffffffff80112f40
movl $0x185, %edx            # imm = 0x185
leaq 0x18c4(%rip), %rcx      # 0xffffffff8011217d
leaq 0x2685(%rip), %r8       # 0xffffffff80112f45
movb $0x0, %al
callq 0xffffffff80101e60
callq 0xffffffff80111cd0
jmp 0xffffffff801108cc
jmp 0xffffffff801108d0
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
shlq $0xc, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xffffffff8010fdc0
movq %rax, %rsi
movq -0x30(%rbp), %rdx
leaq -0x78(%rbp), %rdi
callq 0xffffffff80105050
movq %rax, -0x88(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x88(%rbp)
movb %al, -0xa9(%rbp)
je 0xffffffff80110941
movq -0x88(%rbp), %rax
movq 0x38(%rax), %rax
cmpq -0x38(%rbp), %rax
setb %al
movb %al, -0xa9(%rbp)
movb -0xa9(%rbp), %al
testb $0x1, %al
jne 0xffffffff80110950
jmp 0xffffffff80110a5c
jmp 0xffffffff80110952
cmpl $0x0, -0x78(%rbp)
je 0xffffffff80110987
leaq 0x181a(%rip), %rdi      # 0xffffffff80112179
leaq 0x25da(%rip), %rsi      # 0xffffffff80112f40
movl $0x18e, %edx            # imm = 0x18E
leaq 0x180b(%rip), %rcx      # 0xffffffff8011217d
leaq 0x25e4(%rip), %r8       # 0xffffffff80112f5d
movb $0x0, %al
callq 0xffffffff80101e60
callq 0xffffffff80111cd0
jmp 0xffffffff80110985
jmp 0xffffffff80110989
jmp 0xffffffff8011098b
movslq -0x78(%rbp), %rax
cmpq $0x0, -0x70(%rbp,%rax,8)
jne 0xffffffff801109c6
leaq 0x17db(%rip), %rdi      # 0xffffffff80112179
leaq 0x259b(%rip), %rsi      # 0xffffffff80112f40
movl $0x18f, %edx            # imm = 0x18F
leaq 0x17cc(%rip), %rcx      # 0xffffffff8011217d
leaq 0x25b5(%rip), %r8       # 0xffffffff80112f6d
movb $0x0, %al
callq 0xffffffff80101e60
callq 0xffffffff80111cd0
jmp 0xffffffff801109c4
jmp 0xffffffff801109c8
movq -0x18(%rbp), %rax
movq -0x80(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x80(%rbp)
movq (%rax,%rcx,8), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0xffffffff80110a70
movq %rax, -0x98(%rbp)
movslq -0x78(%rbp), %rax
movl -0x50(%rbp,%rax,4), %eax
movl %eax, -0x9c(%rbp)
movslq -0x78(%rbp), %rax
movq -0x70(%rbp,%rax,8), %rax
movq %rax, -0xa8(%rbp)
movq -0x90(%rbp), %rdi
callq 0xffffffff80110a90
movq -0x98(%rbp), %rdx
orq -0x28(%rbp), %rdx
orq $0x1, %rdx
movq -0xa8(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x88(%rbp), %rdi
callq 0xffffffff80105320
movq %rax, -0x88(%rbp)
jmp 0xffffffff80110917
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)