// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: _memory_node_add
static void __memory_node_add(enum node_type type, unsigned long begin,
			unsigned long end)
{
	struct memory_node *node = &nodes[memory_nodes];
	const pfn_t pages = (end - begin) >> PAGE_BITS;
	const pfn_t pfn = begin >> PAGE_BITS;

	list_init(&node->link);
	spinlock_init(&node->lock);
	node->begin_pfn = pfn;
	node->end_pfn = pfn + pages;
	node->id = memory_nodes++;
	node->type = type;
	for (int i = 0; i != BUDDY_ORDERS; ++i)
		list_init(&node->free_list[i]);

	const long long mmap = balloc_alloc_aligned(PAGE_SIZE, LOWMEM_SIZE,
				sizeof(struct page) * pages, PAGE_SIZE);

	node->mmap = va(mmap);
	for (pfn_t i = 0; i != pages; ++i) {
		struct page *page = &node->mmap[i];

		page->flags = node->id;
		page_set_busy(page);
		list_init(&page->link);
	}

	printf("memory node %ld (%s): pfns %ld-%ld\n",
		node->id, type == NT_LOW ? "low" : "high",
		node->begin_pfn, node->end_pfn - 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movslq 0x2d3a6(%rip), %rcx     # 0xffffffff80131830
leaq 0x1db9f(%rip), %rax     # 0xffffffff80122030
imulq $0xf8, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
subq -0x10(%rbp), %rax
shrq $0xc, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
shrq $0xc, %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
callq 0xffffffff80101190
movq -0x20(%rbp), %rdi
addq $0x18, %rdi
callq 0xffffffff80104620
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rcx
addq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
movl 0x2d33d(%rip), %ecx     # 0xffffffff80131830
movl %ecx, %eax
addl $0x1, %eax
movl %eax, 0x2d332(%rip)     # 0xffffffff80131830
movq -0x20(%rbp), %rax
movl %ecx, 0x30(%rax)
movl -0x4(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x34(%rax)
movl $0x0, -0x34(%rbp)
cmpl $0xc, -0x34(%rbp)
je 0xffffffff8010453f
movq -0x20(%rbp), %rdi
addq $0x38, %rdi
movslq -0x34(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
callq 0xffffffff80101190
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xffffffff80104516
movq -0x28(%rbp), %rdx
shlq $0x5, %rdx
movl $0x1000, %ecx           # imm = 0x1000
movabsq $0x100000000, %rsi # imm = 0x100000000
movq %rcx, %rdi
callq 0xffffffff801033d0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0xffffffff80104640
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0xffffffff801045d2
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x48(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movslq 0x30(%rax), %rcx
movq -0x50(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rdi
callq 0xffffffff80104660
movq -0x50(%rbp), %rdi
addq $0x8, %rdi
callq 0xffffffff80101190
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0xffffffff8010457e
movq -0x20(%rbp), %rax
movl 0x30(%rax), %esi
movl -0x4(%rbp), %ecx
leaq 0xdd34(%rip), %rdx      # 0xffffffff80112317
leaq 0xdd29(%rip), %rax      # 0xffffffff80112313
cmpl $0x0, %ecx
cmoveq %rax, %rdx
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x20(%rbp), %rax
movq 0x28(%rax), %r8
subq $0x1, %r8
leaq 0xdce3(%rip), %rdi      # 0xffffffff801122ef
movb $0x0, %al
callq 0xffffffff80101bc0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)