LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/stdlib.c
// Function: strtol
long strtol(const char *str, char **endptr, int base)
{
	int sign = 0;

	while (isspace(*str))
		++str;

	if (*str == '-' || *str == '+')
		sign = (*str++ == '-');

	const long value = (long)strtoul(str, endptr, base);

	return sign ? -1l * value : value;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movsbl (%rax), %edi
callq 0xffffffff80102110
cmpl $0x0, %eax
je 0xffffffff80102189
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0xffffffff8010216a
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0xffffffff801021a1
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2b, %eax
jne 0xffffffff801021c1
movq -0x8(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x8(%rbp)
movsbl (%rax), %eax
cmpl $0x2d, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0xffffffff80102200
movq %rax, -0x20(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0xffffffff801021e6
imulq $-0x1, -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0xffffffff801021ee
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/stdlib.c
// Function: strtoul
unsigned long strtoul(const char *str, char **endptr, int base)
{
	static const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";

	unsigned long answer = 0;
	const char *pos;

	if (base == 0 && *str == '0') {
		if (*(str + 1) && (*(str + 1) == 'x' || *(str + 1) == 'X')) {
			base = 16;
			str += 2;
		} else {
			base = 8;
			str += 1;
		}
	}

	if (base == 0)
		base = 10;

	while ((pos = strchr(digits, tolower(*str)))) {
		answer = answer * base + (pos - digits);
		++str;
	}

	if (endptr)
		*endptr = (char *)str;

	return answer;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0xffffffff8010227e
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jne 0xffffffff8010227e
movq -0x8(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
je 0xffffffff80102269
movq -0x8(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x78, %eax
je 0xffffffff80102254
movq -0x8(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x58, %eax
jne 0xffffffff80102269
movl $0x10, -0x14(%rbp)
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
jmp 0xffffffff8010227c
movl $0x8, -0x14(%rbp)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0xffffffff8010227e
cmpl $0x0, -0x14(%rbp)
jne 0xffffffff8010228b
movl $0xa, -0x14(%rbp)
jmp 0xffffffff8010228d
movq -0x8(%rbp), %rax
movsbl (%rax), %edi
callq 0xffffffff801020b0
movl %eax, %esi
leaq 0xfaae(%rip), %rdi      # 0xffffffff80111d50
callq 0xffffffff80101910
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0xffffffff801022e0
movq -0x20(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq %rcx, %rax
movq -0x28(%rbp), %rcx
leaq 0xfa88(%rip), %rdx      # 0xffffffff80111d50
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0xffffffff8010228d
cmpq $0x0, -0x10(%rbp)
je 0xffffffff801022f2
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/vsinkprintf.c
// Function: untoa
static int untoa(uintmax_t value, char *str, int base)
{
	static const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";

	int pos = 0;

	do {
		str[pos++] = digits[value % base];
		value /= base;
	} while (value);

	for (int i = 0; i != pos / 2; ++i) {
		const char tmp = str[i];

		str[i] = str[pos - i - 1];
		str[pos - i - 1] = tmp;
	}
	str[pos] = 0;
	return pos;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
xorl %edx, %edx
divq %rcx
leaq 0xf116(%rip), %rax      # 0xffffffff80111ff0
movb (%rax,%rdx), %dl
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x18(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movslq -0x14(%rbp), %rcx
movq -0x8(%rbp), %rax
xorl %edx, %edx
divq %rcx
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0xffffffff80102ec6
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x18(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x24(%rbp), %eax
cmpl %ecx, %eax
je 0xffffffff80102f78
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x1d(%rbp)
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
subl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %dl
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movb -0x1d(%rbp), %dl
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
subl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xffffffff80102f11
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x18(%rbp), %eax
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/balloc.c
// Function: balloc_pool_insert
static void balloc_pool_insert(struct balloc_pool *pool,
			unsigned long long addr, unsigned long long size)
{
	unsigned long long end = addr + size;
	const int first = balloc_lower_bound(pool, addr);
	const int last = balloc_upper_bound(pool, end);

	if (first != last) {
		if (pool->areas[first].addr < addr)
			addr = pool->areas[first].addr;

		struct balloc_area *last_area = &(pool->areas[last - 1]);

		if (end < last_area->addr + last_area->size)
			end = last_area->addr + last_area->size;
	}

	if (first + 1 != last) {
		const size_t sz = (pool->size - last) * sizeof(*pool->areas);

		memmove(&(pool->areas[first + 1]), &(pool->areas[last]), sz);
	}

	pool->areas[first].addr = addr;
	pool->areas[first].size = end - addr;
	pool->size -= last - first - 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xffffffff801035b0
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xffffffff80103640
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
je 0xffffffff80103094
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
cmpq -0x10(%rbp), %rax
jae 0xffffffff8010304c
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x28(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
movq -0x30(%rbp), %rdx
addq 0x8(%rdx), %rcx
cmpq %rcx, %rax
jae 0xffffffff80103092
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
addq 0x8(%rcx), %rax
movq %rax, -0x20(%rbp)
jmp 0xffffffff80103094
movl -0x24(%rbp), %eax
addl $0x1, %eax
cmpl -0x28(%rbp), %eax
je 0xffffffff801030e4
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
subl -0x28(%rbp), %eax
cltq
shlq $0x4, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl -0x24(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x4, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
movslq -0x28(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
movq -0x38(%rbp), %rdx
callq 0xffffffff80101700
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
subq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movl -0x28(%rbp), %edx
subl -0x24(%rbp), %edx
subl $0x1, %edx
movq -0x8(%rbp), %rax
movl 0xc(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xc(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/balloc.c
// Function: balloc_pool_delete
static void balloc_pool_delete(struct balloc_pool *pool,
			unsigned long long addr, unsigned long long size)
{
	const int pos = balloc_lower_bound(pool, addr);
	const size_t sz = (pool->size - pos - 1) * sizeof(*pool->areas);
	struct balloc_area *area = &(pool->areas[pos]);

	if (area->addr == addr && area->size > size) {
		area->addr += size;
		area->size -= size;
		return;
	}

	if (area->addr + area->size == addr + size && area->size > size) {
		area->size -= size;
		return;
	}

	if (area->addr == addr && area->size == size) {
		memmove(area, area + 1, sz);
		--pool->size;
		return;
	}

	memmove(area + 2, area + 1, sz);
	(area + 1)->addr = addr + size;
	(area + 1)->size = area->addr + area->size - (area + 1)->addr;
	area->size = addr - area->addr;
	++pool->size;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xffffffff801035b0
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
subl -0x1c(%rbp), %eax
subl $0x1, %eax
cltq
shlq $0x4, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
cmpq -0x10(%rbp), %rax
jne 0xffffffff80103202
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0x18(%rbp), %rax
jbe 0xffffffff80103202
movq -0x18(%rbp), %rcx
movq -0x30(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x18(%rbp), %rdx
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x8(%rax)
jmp 0xffffffff801032eb
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
addq 0x8(%rcx), %rax
movq -0x10(%rbp), %rcx
addq -0x18(%rbp), %rcx
cmpq %rcx, %rax
jne 0xffffffff80103244
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0x18(%rbp), %rax
jbe 0xffffffff80103244
movq -0x18(%rbp), %rdx
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x8(%rax)
jmp 0xffffffff801032eb
movq -0x30(%rbp), %rax
movq (%rax), %rax
cmpq -0x10(%rbp), %rax
jne 0xffffffff80103283
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0x18(%rbp), %rax
jne 0xffffffff80103283
movq -0x30(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x10, %rsi
movq -0x28(%rbp), %rdx
callq 0xffffffff80101700
movq -0x8(%rbp), %rax
movl 0xc(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0xffffffff801032eb
movq -0x30(%rbp), %rdi
addq $0x20, %rdi
movq -0x30(%rbp), %rsi
addq $0x10, %rsi
movq -0x28(%rbp), %rdx
callq 0xffffffff80101700
movq -0x10(%rbp), %rcx
addq -0x18(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rcx
movq -0x30(%rbp), %rax
addq 0x8(%rax), %rcx
movq -0x30(%rbp), %rax
subq 0x10(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rax
subq (%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/balloc.c
// Function: balloc_alloc_aligned_from_pool
static long long balloc_alloc_aligned_from_pool(struct balloc_pool *pool,
			unsigned long long low, unsigned long long high,
			size_t size, size_t align)
{
	const int first = balloc_lower_bound(pool, low);
	const int last = balloc_upper_bound(pool, high);

	for (int i = first; i != last; ++i) {
		struct balloc_area *area = &(pool->areas[i]);
		unsigned long long start = area->addr;
		unsigned long long end = start + area->size;

		if (start < low) start = low;
		if (end > high) end = high;

		start = ALIGN(start, align);
		if (start >= end || end - start < size)
			continue;

		balloc_pool_delete(pool, start, size);

		return (long long)start;
	}

	return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %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
callq 0xffffffff801035b0
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xffffffff80103640
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x38(%rbp), %eax
je 0xffffffff80103537
movq -0x10(%rbp), %rax
movq (%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
addq 0x8(%rcx), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0xffffffff801034d1
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x20(%rbp), %rax
jbe 0xffffffff801034e3
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xffffffff801036d0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0xffffffff8010350c
movq -0x58(%rbp), %rax
subq -0x50(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0xffffffff8010350e
jmp 0xffffffff80103529
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xffffffff80103170
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xffffffff8010353f
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xffffffff80103482
movq $-0x1, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/balloc.c
// Function: balloc_lower_bound
static int balloc_lower_bound(const struct balloc_pool *pool,
			unsigned long long addr)
{
	int left = 0, right = pool->size;

	while (left < right) {
		const int mid = left + (right - left) / 2;
		const struct balloc_area *area = &(pool->areas[mid]);
		const unsigned long long end = area->addr + area->size;

		if (end < addr)
			left = mid + 1;
		else
			right = mid;
	}

	return left;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x18(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0xffffffff80103639
movl -0x14(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x18(%rbp), %eax
subl -0x14(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x34(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
addq 0x8(%rcx), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0xffffffff80103631
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xffffffff80103637
movl -0x1c(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0xffffffff801035cd
movl -0x14(%rbp), %eax
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/balloc.c
// Function: balloc_upper_bound
static int balloc_upper_bound(const struct balloc_pool *pool,
			unsigned long long addr)
{
	int left = 0, right = pool->size;

	while (left < right) {
		const int mid = left + (right - left) / 2;
		const struct balloc_area *area = &(pool->areas[mid]);
		const unsigned long long begin = area->addr;

		if (begin > addr)
			right = mid;
		else
			left = mid + 1;
	}

	return left;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x18(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0xffffffff801036c1
movl -0x14(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x18(%rbp), %eax
subl -0x14(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x34(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x10(%rbp), %rax
jbe 0xffffffff801036b6
movl -0x1c(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0xffffffff801036bf
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xffffffff8010365d
movl -0x14(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: memory_free_region
void memory_free_region(unsigned long long addr, unsigned long long size)
{
	const unsigned long long begin = ALIGN(addr, PAGE_SIZE);
	const unsigned long long end = MINU(ALIGN_DOWN(addr + size, PAGE_SIZE),
				MAX_PHYS_SIZE);

	if (begin >= end)
		return;

	if (begin < LOWMEM_SIZE && end > LOWMEM_SIZE) {
		__memory_free_region(begin, LOWMEM_SIZE);
		__memory_free_region(LOWMEM_SIZE, end);
	} else {
		__memory_free_region(begin, end);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0xffffffff801037e0
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
addq -0x10(%rbp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0xffffffff80103840
movq %rax, %rdi
movabsq $0x1000000000, %rsi # imm = 0x1000000000
callq 0xffffffff80103810
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
jb 0xffffffff80103776
jmp 0xffffffff801037cb
movabsq $0x100000000, %rax # imm = 0x100000000
cmpq %rax, -0x18(%rbp)
jae 0xffffffff801037be
movabsq $0x100000000, %rax # imm = 0x100000000
cmpq %rax, -0x20(%rbp)
jbe 0xffffffff801037be
movq -0x18(%rbp), %rdi
movabsq $0x100000000, %rsi # imm = 0x100000000
callq 0xffffffff80103870
movq -0x20(%rbp), %rsi
movabsq $0x100000000, %rdi # imm = 0x100000000
callq 0xffffffff80103870
jmp 0xffffffff801037cb
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xffffffff80103870
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: _memory_free_region
static void __memory_free_region(unsigned long long begin,
			unsigned long long end)
{
	const pfn_t b = begin >> PAGE_BITS;
	const pfn_t e = end >> PAGE_BITS;
	const pfn_t pages = e - b;

	struct memory_node *node = pfn_node(b);

	const pfn_t node_pfn = b - node->begin_pfn;

	for (pfn_t pfn = node_pfn; pfn != node_pfn + pages;) {
		struct page *page = node_page(node, pfn);
		int order = pfn_max_order(pfn);

		/**
		 * Actually we need not check that order is non negative
		 * because order originally non negative and goes less
		 * while (1 << order) > pages and pages is positive, so
		 * order never get less than zero.
		 * But clang static checker complains about it, so i've
		 * added order check in loop condition
		 */
		while (order && pfn + ((pfn_t)1 << order) > pages)
			--order;

		free_pages_node(page, order, node);
		pfn += (pfn_t)1 << order;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
shrq $0xc, %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
shrq $0xc, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
subq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
callq 0xffffffff80103d30
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
subq 0x20(%rcx), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
addq -0x28(%rbp), %rcx
cmpq %rcx, %rax
je 0xffffffff80103963
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xffffffff80103da0
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
callq 0xffffffff80104410
movl %eax, -0x4c(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x4c(%rbp)
movb %al, -0x4d(%rbp)
je 0xffffffff80103925
movq -0x40(%rbp), %rax
movl -0x4c(%rbp), %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
addq %rcx, %rax
cmpq -0x28(%rbp), %rax
seta %al
movb %al, -0x4d(%rbp)
movb -0x4d(%rbp), %al
testb $0x1, %al
jne 0xffffffff8010392e
jmp 0xffffffff80103939
movl -0x4c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xffffffff801038fb
movq -0x48(%rbp), %rdi
movl -0x4c(%rbp), %esi
movq -0x30(%rbp), %rdx
callq 0xffffffff801041a0
movl -0x4c(%rbp), %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0xffffffff801038c9
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: setup_buddy
void setup_buddy(void)
{
	balloc_for_each_region(&memory_node_add);
	balloc_for_each_free_region(&memory_free_region);

	struct list_head type_nodes[NT_COUNT];

	for (int i = 0; i != NT_COUNT; ++i)
		list_init(&type_nodes[i]);

	for (int i = 0; i != memory_nodes; ++i) {
		struct memory_node *node = memory_node_get(i);

		list_add_tail(&node->link, &type_nodes[node->type]);
	}

	for (int i = 0; i != NT_COUNT; ++i) {
		list_splice(type_nodes + i, &node_order);
		node_type[i] = node_order.next;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
leaq 0xd1(%rip), %rdi        # 0xffffffff80103c00
callq 0xffffffff80103300
leaq -0x41b(%rip), %rdi      # 0xffffffff80103720
callq 0xffffffff801033a0
movl $0x0, -0x24(%rbp)
cmpl $0x2, -0x24(%rbp)
je 0xffffffff80103b6c
movslq -0x24(%rbp), %rax
leaq -0x20(%rbp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
callq 0xffffffff80101190
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xffffffff80103b47
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl 0x2dcb4(%rip), %eax     # 0xffffffff80131830
je 0xffffffff80103bb0
movl -0x28(%rbp), %edi
callq 0xffffffff80103700
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x34(%rax), %eax
leaq -0x20(%rbp), %rsi
shlq $0x4, %rax
addq %rax, %rsi
callq 0xffffffff80101220
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xffffffff80103b73
movl $0x0, -0x34(%rbp)
cmpl $0x2, -0x34(%rbp)
je 0xffffffff80103bf9
leaq -0x20(%rbp), %rdi
movslq -0x34(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
leaq 0x13f85(%rip), %rsi     # 0xffffffff80117b58
callq 0xffffffff801012b0
movq 0x13f79(%rip), %rdx     # 0xffffffff80117b58
movslq -0x34(%rbp), %rcx
leaq 0x2dc56(%rip), %rax     # 0xffffffff80131840
movq %rdx, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xffffffff80103bb7
addq $0x40, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: memory_node_add
static void memory_node_add(unsigned long long addr, unsigned long long size)
{
	const unsigned long long begin = ALIGN(addr, PAGE_SIZE);
	const unsigned long long end = MINU(ALIGN_DOWN(addr + size, PAGE_SIZE),
				MAX_PHYS_SIZE);

	if (begin >= end)
		return;

	if (begin < LOWMEM_SIZE && end > LOWMEM_SIZE) {
		__memory_node_add(NT_LOW, begin, LOWMEM_SIZE);
		__memory_node_add(NT_HIGH, LOWMEM_SIZE, end);
	} else {
		const enum node_type type = (end <= LOWMEM_SIZE)
					? NT_LOW : NT_HIGH;

		__memory_node_add(type, begin, end);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0xffffffff801037e0
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
addq -0x10(%rbp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0xffffffff80103840
movq %rax, %rdi
movabsq $0x1000000000, %rsi # imm = 0x1000000000
callq 0xffffffff80103810
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
jb 0xffffffff80103c56
jmp 0xffffffff80103cd3
movabsq $0x100000000, %rax # imm = 0x100000000
cmpq %rax, -0x18(%rbp)
jae 0xffffffff80103ca5
movabsq $0x100000000, %rax # imm = 0x100000000
cmpq %rax, -0x20(%rbp)
jbe 0xffffffff80103ca5
movq -0x18(%rbp), %rsi
xorl %edi, %edi
movabsq $0x100000000, %rdx # imm = 0x100000000
callq 0xffffffff80104470
movq -0x20(%rbp), %rdx
movl $0x1, %edi
movabsq $0x100000000, %rsi # imm = 0x100000000
callq 0xffffffff80104470
jmp 0xffffffff80103cd3
movq -0x20(%rbp), %rdx
movabsq $0x100000000, %rsi # imm = 0x100000000
movl $0x1, %eax
xorl %ecx, %ecx
cmpq %rsi, %rdx
cmovbel %ecx, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %edi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xffffffff80104470
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: pfn2page
struct page *pfn2page(pfn_t pfn)
{
	struct memory_node *node = pfn_node(pfn);

	if (!node)
		return 0;

	return node_page(node, pfn - node->begin_pfn);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0xffffffff80103d30
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xffffffff80103d0a
movq $0x0, -0x8(%rbp)
jmp 0xffffffff80103d23
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rax
subq 0x20(%rax), %rsi
callq 0xffffffff80103da0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: pfn_node
static struct memory_node *pfn_node(pfn_t pfn)
{
	for (int i = 0; i != memory_nodes; ++i) {
		if (nodes[i].end_pfn <= pfn)
			continue;

		return &nodes[i];
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x2dae8(%rip), %eax     # 0xffffffff80131830
je 0xffffffff80103d91
movslq -0x14(%rbp), %rcx
leaq 0x1e2db(%rip), %rax     # 0xffffffff80122030
imulq $0xf8, %rcx, %rcx
addq %rcx, %rax
movq 0x28(%rax), %rax
cmpq -0x10(%rbp), %rax
ja 0xffffffff80103d6b
jmp 0xffffffff80103d86
movslq -0x14(%rbp), %rcx
leaq 0x1e2ba(%rip), %rax     # 0xffffffff80122030
imulq $0xf8, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0xffffffff80103d99
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xffffffff80103d3f
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: max_pfns
pfn_t max_pfns(void)
{
	pfn_t max = 0;

	for (int i = 0; i != memory_nodes; ++i) {
		struct memory_node *node = memory_node_get(i);

		max = MAXU(max, node->end_pfn);
	}
	return max;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq $0x0, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl 0x2d990(%rip), %eax     # 0xffffffff80131830
je 0xffffffff80103ece
movl -0xc(%rbp), %edi
callq 0xffffffff80103700
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0xffffffff80103ee0
movq %rax, -0x8(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xffffffff80103e97
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: alloc_pages_node
struct page *alloc_pages_node(int order, struct memory_node *node)
{
	const bool enabled = spin_lock_irqsave(&node->lock);
	struct page * pages = __alloc_pages_node(order, node);

	spin_unlock_irqrestore(&node->lock, enabled);

	return pages;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
callq 0xffffffff80103f60
andb $0x1, %al
movb %al, -0x11(%rbp)
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xffffffff80103f80
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movb -0x11(%rbp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0xffffffff801040a0
movq -0x20(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: _alloc_pages_node
static struct page *__alloc_pages_node(int order, struct memory_node *node)
{
	int coorder = order;

	while (coorder < BUDDY_ORDERS) {
		if (!list_empty(&node->free_list[coorder]))
			break;
		++coorder;
	}

	if (coorder >= BUDDY_ORDERS)
		return 0;

	struct page *page = LIST_ENTRY(list_first(&node->free_list[coorder]),
				struct page, link);

	list_del(&page->link);
	page_set_busy(page);

	while (coorder > order) {
		const pfn_t pfn = node_pfn(node, page);
		const pfn_t bpfn = buddy_pfn(pfn, --coorder);
		struct page *buddy = node_page(node, bpfn);

		page_set_order(buddy, coorder);
		page_set_free(buddy);

		list_add(&buddy->link, &node->free_list[coorder]);
	}

	return page;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0xc(%rbp)
movq %rsi, -0x18(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x1c(%rbp)
cmpl $0xc, -0x1c(%rbp)
jge 0xffffffff80103fc4
movq -0x18(%rbp), %rdi
addq $0x38, %rdi
movslq -0x1c(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
callq 0xffffffff801012f0
testb $0x1, %al
jne 0xffffffff80103fb9
jmp 0xffffffff80103fc4
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xffffffff80103f95
cmpl $0xc, -0x1c(%rbp)
jl 0xffffffff80103fd7
movq $0x0, -0x8(%rbp)
jmp 0xffffffff8010408c
movq -0x18(%rbp), %rdi
addq $0x38, %rdi
movslq -0x1c(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
callq 0xffffffff80101370
addq $-0x8, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
callq 0xffffffff80101250
movq -0x28(%rbp), %rdi
callq 0xffffffff80104660
movl -0x1c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jle 0xffffffff80104084
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xffffffff80103e50
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movl -0x1c(%rbp), %esi
addl $-0x1, %esi
movl %esi, -0x1c(%rbp)
callq 0xffffffff80104730
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xffffffff80103da0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0xffffffff80104760
movq -0x40(%rbp), %rdi
callq 0xffffffff80104780
movq -0x40(%rbp), %rdi
addq $0x8, %rdi
movq -0x18(%rbp), %rsi
addq $0x38, %rsi
movslq -0x1c(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0xffffffff801011b0
jmp 0xffffffff8010400d
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: dump_buddy_state
void dump_buddy_state(void)
{
	for (int i = 0; i != memory_nodes; ++i) {
		struct memory_node *node = memory_node_get(i);

		printf("node %d\n", i);
		dump_buddy_node_state(node);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl 0x2d748(%rip), %eax     # 0xffffffff80131830
je 0xffffffff8010411b
movl -0x4(%rbp), %edi
callq 0xffffffff80103700
movq %rax, -0x10(%rbp)
movl -0x4(%rbp), %esi
leaq 0xe1e6(%rip), %rdi      # 0xffffffff801122e6
movb $0x0, %al
callq 0xffffffff80101bc0
movq -0x10(%rbp), %rdi
callq 0xffffffff80104130
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0xffffffff801040df
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: dump_buddy_node_state
static void dump_buddy_node_state(struct memory_node *node)
{
	for (int i = 0; i != BUDDY_ORDERS; ++i) {
		const int sz = list_size(&node->free_list[i]);

		if (sz)
			printf("\torder %d: %d\n", i, sz);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0xc, -0xc(%rbp)
je 0xffffffff8010418b
movq -0x8(%rbp), %rdi
addq $0x38, %rdi
movslq -0xc(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
callq 0xffffffff80101390
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
je 0xffffffff8010417e
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
leaq 0xe1a5(%rip), %rdi      # 0xffffffff8011231c
movb $0x0, %al
callq 0xffffffff80101bc0
jmp 0xffffffff80104180
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xffffffff80104143
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: free_pages_node
void free_pages_node(struct page *pages, int order, struct memory_node *node)
{
	if (!pages)
		return;

	const bool enabled = spin_lock_irqsave(&node->lock);

	__free_pages_node(pages, order, node);
	spin_unlock_irqrestore(&node->lock, enabled);	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0xffffffff801041bc
jmp 0xffffffff801041f3
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
callq 0xffffffff80103f60
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
callq 0xffffffff80104200
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0xffffffff801040a0
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: _free_pages_node
static void __free_pages_node(struct page *pages, int order,
			struct memory_node *node)
{
	const pfn_t node_pfns = node->end_pfn - node->begin_pfn;
	pfn_t pfn = node_pfn(node, pages);

	while (order < BUDDY_ORDERS - 1) {
		const pfn_t bpfn = buddy_pfn(pfn, order);

		if (bpfn >= node_pfns)
			break;

		if (bpfn + ((pfn_t)1 << order) > node_pfns)
			break;

		struct page *buddy = node_page(node, bpfn);

		if (page_busy(buddy))
			break;

		if (order != page_get_order(buddy))
			break;

		list_del(&buddy->link);
		++order;

		if (bpfn < pfn) {
			pfn = bpfn;
			pages = buddy;
		}
	}

	page_set_order(pages, order);
	page_set_free(pages);

	list_add(&pages->link, &node->free_list[order]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rcx
subq 0x20(%rcx), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0xffffffff80103e50
movq %rax, -0x28(%rbp)
cmpl $0xb, -0xc(%rbp)
jge 0xffffffff801042ef
movq -0x28(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xffffffff80104730
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x20(%rbp), %rax
jb 0xffffffff80104261
jmp 0xffffffff801042ef
movq -0x30(%rbp), %rax
movl -0xc(%rbp), %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
addq %rcx, %rax
cmpq -0x20(%rbp), %rax
jbe 0xffffffff8010427e
jmp 0xffffffff801042ef
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xffffffff80103da0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0xffffffff801047f0
testb $0x1, %al
jne 0xffffffff8010429e
jmp 0xffffffff801042a0
jmp 0xffffffff801042ef
movl -0xc(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x38(%rbp), %rdi
callq 0xffffffff80104810
movl %eax, %ecx
movl -0x3c(%rbp), %eax
cmpl %ecx, %eax
je 0xffffffff801042ba
jmp 0xffffffff801042ef
movq -0x38(%rbp), %rdi
addq $0x8, %rdi
callq 0xffffffff80101250
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0xffffffff801042ea
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xffffffff80104238
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xffffffff80104760
movq -0x8(%rbp), %rdi
callq 0xffffffff80104780
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
movq -0x18(%rbp), %rsi
addq $0x38, %rsi
movslq -0xc(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0xffffffff801011b0
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: _alloc_pages
struct page *__alloc_pages(int order, int type)
{
	const struct list_head *head = &node_order;
	struct list_head *ptr = node_type[type];

	for (; ptr != head; ptr = ptr->next) {
		struct memory_node *node = LIST_ENTRY(ptr, struct memory_node,
					link);
		struct page *pages = alloc_pages_node(order, node);

		if (pages)
			return pages;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0xc(%rbp)
movl %esi, -0x10(%rbp)
leaq 0x13813(%rip), %rax     # 0xffffffff80117b58
movq %rax, -0x18(%rbp)
movslq -0x10(%rbp), %rcx
leaq 0x2d4ec(%rip), %rax     # 0xffffffff80131840
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x18(%rbp), %rax
je 0xffffffff8010439e
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0xc(%rbp), %edi
movq -0x28(%rbp), %rsi
callq 0xffffffff80103f10
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xffffffff8010438f
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xffffffff801043a6
jmp 0xffffffff80104391
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0xffffffff8010435c
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: free_pages
void free_pages(struct page *pages, int order)
{
	if (!pages)
		return;

	struct memory_node *node = page_node(pages);

	free_pages_node(pages, order, node);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0xffffffff801043e8
jmp 0xffffffff80104405
movq -0x8(%rbp), %rdi
callq 0xffffffff80103e20
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
callq 0xffffffff801041a0
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/memory.c
// Function: pfn_max_order
static int pfn_max_order(pfn_t pfn)
{
	for (int i = 0; i != BUDDY_ORDERS - 1; ++i)
		if (pfn & ((pfn_t)1 << i))
			return i;

	return BUDDY_ORDERS - 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0xb, -0x14(%rbp)
je 0xffffffff80104455
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0xffffffff80104448
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xffffffff8010445c
jmp 0xffffffff8010444a
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xffffffff8010441f
movl $0xb, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/interrupt.c
// Function: isr_common_handler
void isr_common_handler(struct thread_regs *ctx)
{
	const int intno = ctx->intno;

	if (intno < IDT_EXCEPTIONS) {
		if (intno == 14 && !page_fault_handler(ctx))
			return;
		default_exception_handler(ctx);
		return;
	}

	const int irqno = intno - IDT_EXCEPTIONS;
	const irq_t irq = handler[irqno];

	mask_irq(irqno);
	ack_irq(irqno);
	if (irq)
		irq(irqno);
	unmask_irq(irqno);

	if (need_resched())
		schedule();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rax
movl %eax, -0xc(%rbp)
cmpl $0x20, -0xc(%rbp)
jge 0xffffffff8010486e
cmpl $0xe, -0xc(%rbp)
jne 0xffffffff80104863
movq -0x8(%rbp), %rdi
callq 0xffffffff801048d0
cmpl $0x0, %eax
jne 0xffffffff80104863
jmp 0xffffffff801048c2
movq -0x8(%rbp), %rdi
callq 0xffffffff80104940
jmp 0xffffffff801048c2
movl -0xc(%rbp), %eax
subl $0x20, %eax
movl %eax, -0x10(%rbp)
movslq -0x10(%rbp), %rcx
leaq 0x2cfce(%rip), %rax     # 0xffffffff80131850
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movl -0x10(%rbp), %edi
callq 0xffffffff80104980
movl -0x10(%rbp), %edi
callq 0xffffffff801049d0
cmpq $0x0, -0x18(%rbp)
je 0xffffffff801048aa
movq -0x18(%rbp), %rax
movl -0x10(%rbp), %edi
callq *%rax
movl -0x10(%rbp), %edi
callq 0xffffffff801049f0
callq 0xffffffff80108a60
testb $0x1, %al
jne 0xffffffff801048bd
jmp 0xffffffff801048c2
callq 0xffffffff80107ea0
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/interrupt.c
// Function: page_fault_handler
static int page_fault_handler(struct thread_regs *ctx)
{
	const int access = (ctx->error & BIT_CONST(1)) != 0
				? VMA_ACCESS_WRITE
				: VMA_ACCESS_READ;
	const virt_t vaddr = load_cr2();
	struct thread *thread = current();

	if (!thread)
		return -EINVAL;

	local_irq_enable();

	return mm_page_fault(thread, vaddr, access);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rdx
andq $0x2, %rdx
xorl %eax, %eax
movl $0x1, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x14(%rbp)
callq 0xffffffff80104cf0
movq %rax, -0x20(%rbp)
callq 0xffffffff80108940
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xffffffff8010491e
movl $0xfffffffa, -0x4(%rbp) # imm = 0xFFFFFFFA
jmp 0xffffffff80104936
callq 0xffffffff80104d10
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0xffffffff8010fbc0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/interrupt.c
// Function: register_irq_handler
void register_irq_handler(int irq, irq_t isr)
{
	DBG_ASSERT(irq < IDT_IRQS);

	const int intno = irq + IDT_EXCEPTIONS;

	handler[irq] = isr;
	setup_irq(isr_entry[intno], intno);
	unmask_irq(irq);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x10, -0x4(%rbp)
jl 0xffffffff80104a74
leaq 0xd72d(%rip), %rdi      # 0xffffffff80112179
leaq 0xd8d8(%rip), %rsi      # 0xffffffff8011232b
movl $0xd5, %edx
leaq 0xd71e(%rip), %rcx      # 0xffffffff8011217d
leaq 0xd8d1(%rip), %r8       # 0xffffffff80112337
movb $0x0, %al
callq 0xffffffff80101e60
callq 0xffffffff80111cd0
jmp 0xffffffff80104a72
jmp 0xffffffff80104a76
movl -0x4(%rbp), %eax
addl $0x20, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdx
movslq -0x4(%rbp), %rcx
leaq 0x2cdc2(%rip), %rax     # 0xffffffff80131850
movq %rdx, (%rax,%rcx,8)
movslq -0x14(%rbp), %rcx
movq $-0x7feff460, %rax      # imm = 0x80100BA0
movq (%rax,%rcx,8), %rdi
movl -0x14(%rbp), %esi
callq 0xffffffff80104ac0
movl -0x4(%rbp), %edi
callq 0xffffffff801049f0
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/interrupt.c
// Function: unregister_irq_handler
void unregister_irq_handler(int irq, irq_t isr)
{
	DBG_ASSERT(irq < IDT_IRQS);

	const int intno = irq + IDT_EXCEPTIONS;

	if (handler[irq] == isr) {
		mask_irq(irq);
		handler[irq] = (irq_t)0;
		clear_idt_entry(intno);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x10, -0x4(%rbp)
jl 0xffffffff80104b34
leaq 0xd66d(%rip), %rdi      # 0xffffffff80112179
leaq 0xd818(%rip), %rsi      # 0xffffffff8011232b
movl $0xe0, %edx
leaq 0xd65e(%rip), %rcx      # 0xffffffff8011217d
leaq 0xd811(%rip), %r8       # 0xffffffff80112337
movb $0x0, %al
callq 0xffffffff80101e60
callq 0xffffffff80111cd0
jmp 0xffffffff80104b32
jmp 0xffffffff80104b36
movl -0x4(%rbp), %eax
addl $0x20, %eax
movl %eax, -0x14(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x2cd06(%rip), %rax     # 0xffffffff80131850
movq (%rax,%rcx,8), %rax
cmpq -0x10(%rbp), %rax
jne 0xffffffff80104b77
movl -0x4(%rbp), %edi
callq 0xffffffff80104980
movslq -0x4(%rbp), %rcx
leaq 0x2cce9(%rip), %rax     # 0xffffffff80131850
movq $0x0, (%rax,%rcx,8)
movl -0x14(%rbp), %edi
callq 0xffffffff80104b80
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/interrupt.c
// Function: setup_ints
void setup_ints(void)
{
	for (int i = 0; i != IDT_IRQS; ++i)
		irqmask_count[i] = 1;

	for (int i = 0; i != IDT_EXCEPTIONS; ++i)
		setup_irq(isr_entry[i], i);

	extern void syscall_handler(void);

	setup_syscall(&syscall_handler, IDT_SYSCALL);

	idt_ptr.size = sizeof(idt) - 1;
	idt_ptr.base = (uintptr_t)idt;
	set_idt(&idt_ptr);

	irqchip = &i8259a;
	irqchip_map(irqchip, IDT_EXCEPTIONS);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x0, -0x4(%rbp)
cmpl $0x10, -0x4(%rbp)
je 0xffffffff80104be2
movslq -0x4(%rbp), %rcx
leaq 0x2cd00(%rip), %rax     # 0xffffffff801318d0
movl $0x1, (%rax,%rcx,4)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0xffffffff80104bbf
movl $0x0, -0x8(%rbp)
cmpl $0x20, -0x8(%rbp)
je 0xffffffff80104c11
movslq -0x8(%rbp), %rcx
movq $-0x7feff460, %rax      # imm = 0x80100BA0
movq (%rax,%rcx,8), %rdi
movl -0x8(%rbp), %esi
callq 0xffffffff80104ac0
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0xffffffff80104be9
movq $-0x7feff836, %rdi      # imm = 0x801007CA
movl $0x80, %esi
callq 0xffffffff80104c70
movw $0x80f, 0x2cce5(%rip) # imm = 0x80F
leaq 0x2ccee(%rip), %rax     # 0xffffffff80131920
movq %rax, 0x2ccd9(%rip)     # 0xffffffff80131912
leaq 0x2ccd0(%rip), %rdi     # 0xffffffff80131910
callq 0xffffffff80104ca0
movq $-0x7fee8070, %rax      # imm = 0x80117F90
movq %rax, 0x2d4dd(%rip)     # 0xffffffff80132130
movq 0x2d4d6(%rip), %rdi     # 0xffffffff80132130
movl $0x20, %esi
callq 0xffffffff80104cc0
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/interrupt.c
// Function: dump_error_frame
static void dump_error_frame(const struct thread_regs *frame)
{
	printf("exception %ld (%ld) at %#lx:%#lx\n", frame->intno, frame->error,
				frame->cs, frame->rip);
	puts("register state:");
	printf("\tstack %lx:%lx, rflags %#lx\n", frame->ss, frame->rsp,
				frame->rflags);
	printf("\trax %#lx, rbx %#lx, rcx %#lx, rdx %#lx\n", frame->rax,
				frame->rbx, frame->rcx, frame->rdx);
	printf("\trbp %#lx, rdi %#lx, rsi %#lx\n", frame->rbp, frame->rdi,
				frame->rsi);
	printf("\tr8 %#lx, r9 %#lx, r10 %#lx, r11 %#lx\n", frame->r8, frame->r9,
				frame->r10, frame->r11);
	printf("\tr12 %#lx, r13 %#lx, r14 %#lx, r15 %#lx\n", frame->r12,
				frame->r13, frame->r14, frame->r15);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x88(%rax), %r8
leaq 0xd79b(%rip), %rdi      # 0xffffffff801124f7
movb $0x0, %al
callq 0xffffffff80101bc0
leaq 0xd7af(%rip), %rdi      # 0xffffffff80112519
callq 0xffffffff80101af0
movq -0x8(%rbp), %rax
movq 0xa8(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rcx
leaq 0xd792(%rip), %rdi      # 0xffffffff80112529
movb $0x0, %al
callq 0xffffffff80101bc0
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x60(%rax), %r8
leaq 0xd781(%rip), %rdi      # 0xffffffff80112546
movb $0x0, %al
callq 0xffffffff80101bc0
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x70(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rcx
leaq 0xd784(%rip), %rdi      # 0xffffffff8011256f
movb $0x0, %al
callq 0xffffffff80101bc0
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x30(%rax), %r8
leaq 0xd775(%rip), %rdi      # 0xffffffff8011258e
movb $0x0, %al
callq 0xffffffff80101bc0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %r8
leaq 0xd76f(%rip), %rdi      # 0xffffffff801125b5
movb $0x0, %al
callq 0xffffffff80101bc0
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/krinkinmu[P]64bit/interrupt.c
// Function: dump_backtrace
static void dump_backtrace(const struct thread_regs *frame)
{
	struct thread *thread = current();

	if (!thread)
		return;

	const uintptr_t stack_begin = (uintptr_t)thread_stack_begin(thread);
	const uintptr_t stack_end = (uintptr_t)thread_stack_end(thread);

	puts("Backtrace:");
	__backtrace(frame->rbp, stack_begin, stack_end);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
callq 0xffffffff80108940
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xffffffff80104e7e
jmp 0xffffffff80104eb9
movq -0x10(%rbp), %rdi
callq 0xffffffff80107f40
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0xffffffff80107fc0
movq %rax, -0x20(%rbp)
leaq 0xd73f(%rip), %rdi      # 0xffffffff801125de
callq 0xffffffff80101af0
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xffffffff80111c40
addq $0x20, %rsp
popq %rbp
retq
nop