LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/x86_interpreter.c
// Function: step_memwrite
static int step_memwrite(uint32_t inst_addr, int segment, uint32_t addr, uint32_t value, int size) {
	int i;
	if (UINT32_MAX - segment_offsets[segment] < addr ||
	(size <= 0 || UINT32_MAX - (segment_offsets[segment] + addr) < (uint32_t)(size - 1))) {
		return 0;
	}
	for (i = 0; i < size; i++) {
		uint32_t this_addr = segment_offsets[segment] + addr + i;
		uint8_t dummy_read;
		if (!memory_access(&dummy_read, this_addr, (value >> (i * 8)) & 0xff, 1)) {
			fprintf(stderr, "failed to write memory %08"PRIx32" at %08"PRIx32"\n\n", this_addr, inst_addr);
			print_regs(stderr);
			return 0;
		}
	}
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, 0x14(%rsp)
movl %edx, %r12d
movslq %esi, %r15
leaq 0xcf72(%rip), %rax      # 0x12150
movl (%rax,%r15,4), %eax
addl %edx, %eax
setb %cl
testl %r8d, %r8d
setle %dl
xorl %ebx, %ebx
orb %cl, %dl
jne 0x51ff
movl %r8d, %r14d
movl %r8d, %ecx
negl %ecx
cmpl %ecx, %eax
jbe 0x5210
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %edi, 0x10(%rsp)
xorl %r13d, %r13d
pushq $0x1
popq %rbx
subl $0x1, %r14d
jb 0x51ff
leaq 0xcf29(%rip), %rax      # 0x12150
movl (%rax,%r15,4), %ebp
addl %r12d, %ebp
movl 0x14(%rsp), %eax
movl %r13d, %ecx
shrl %cl, %eax
movzbl %al, %edx
leaq 0xf(%rsp), %rdi
movl %ebp, %esi
movl %ebx, %ecx
callq 0x13d2
testl %eax, %eax
je 0x5255
incl %r12d
addl $0x8, %r13d
jmp 0x521a
movq 0xcd9c(%rip), %r14      # 0x11ff8
movq (%r14), %rdi
leaq 0x78f1(%rip), %rsi      # 0xcb57
xorl %ebx, %ebx
movl %ebp, %edx
movl 0x10(%rsp), %ecx
xorl %eax, %eax
callq 0x10d0
movq (%r14), %rdi
callq 0x12ac
jmp 0x51ff
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/x86_interpreter.c
// Function: step_push
static int step_push(uint32_t inst_addr, uint32_t value, int op_width, int is_addr_16bit) {
	uint32_t addr = regs[ESP];
	if (is_addr_16bit) addr &= 0xffff;
	addr -= op_width;
	if (!step_memwrite(inst_addr, SS, addr, value, op_width)) return 0;
	if (is_addr_16bit) {
		regs[ESP] = (regs[ESP] & UINT32_C(0xffff0000)) | (addr & 0xffff);
	} else {
		regs[ESP] = addr;
	}
	return 1;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %ecx, %ebx
movl %edx, %r8d
movl %esi, %ecx
movl 0xce81(%rip), %eax      # 0x12110
testl %ebx, %ebx
movzwl %ax, %ebp
cmovel %eax, %ebp
subl %edx, %ebp
pushq $0x2
popq %rsi
movl %ebp, %edx
callq 0x51bf
testl %eax, %eax
je 0x52c6
movzwl 0xce64(%rip), %eax      # 0x12112
shll $0x10, %eax
movzwl %bp, %ecx
orl %eax, %ecx
testl %ebx, %ebx
cmovel %ebp, %ecx
movl %ecx, 0xce4f(%rip)      # 0x12110
pushq $0x1
popq %rax
jmp 0x52c8
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/x86_interpreter.c
// Function: step_pop
static uint32_t step_pop(int* success, uint32_t inst_addr, int op_width, int is_addr_16bit) {
	int memread_ok = 0;
	uint32_t next_esp;
	uint32_t value = step_memread(&memread_ok, inst_addr, SS,
		is_addr_16bit ? regs[ESP] & 0xffff : regs[ESP], op_width);
	if (!memread_ok) {
		*success = 0;
		return 0;
	}
	next_esp = regs[ESP] + op_width;
	if (is_addr_16bit) {
		regs[ESP] = (regs[ESP] & UINT32_C(0xffff0000)) | (next_esp & 0xffff);
	} else {
		regs[ESP] = next_esp;
	}
	*success = 1;
	return value;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %r14d
movl %edx, %ebp
movq %rdi, %rbx
leaq 0x4(%rsp), %r15
andl $0x0, (%r15)
testl %ecx, %ecx
movl 0xce21(%rip), %eax      # 0x12110
movzwl %ax, %ecx
cmovel %eax, %ecx
pushq $0x2
popq %rdx
movq %r15, %rdi
movl %ebp, %r8d
callq 0x509d
cmpl $0x0, (%r15)
je 0x532d
movl 0xce01(%rip), %ecx      # 0x12110
addl %ecx, %ebp
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
movzwl %bp, %edx
orl %ecx, %edx
testl %r14d, %r14d
cmovel %ebp, %edx
movl %edx, 0xcde8(%rip)      # 0x12110
pushq $0x1
popq %rcx
jmp 0x5331
xorl %ecx, %ecx
xorl %eax, %eax
movl %ecx, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/x86_interpreter.c
// Function: str_to_uint32
int str_to_uint32(uint32_t* out, const char* str) {
	uint32_t value = 0;
	uint32_t digit_mult = 0;
	if (str[0] == '0') {
		if (str[1] == 'x' || str[1] == 'X') {
			digit_mult = 16;
			str += 2;
		} else if (str[1] == 'b' || str[1]== 'B') {
			digit_mult = 2;
			str += 2;
		} else if (str[1] == '\0') {
			*out = 0;
			return 1;
		} else {
			digit_mult = 8;
			str += 1;
		}
	} else {
		digit_mult = 10;
	}
	while (*str != '\0') {
		uint32_t digit_value = 0;
		if ('0' <= *str && *str <= '9') digit_value = *str - '0';
		else if ('a' <= *str && *str <= 'z') digit_value = *str - 'a' + 10;
		else if ('A' <= *str && *str <= 'Z') digit_value = *str - 'A' + 10;
		else return 0; /* 不正な文字 */
		if (digit_value >= digit_mult) return 0; /* 進数に対して大きすぎる数字 */
		if (UINT32_MAX / digit_mult < value) return 0; /* オーバーフロー */
		value *= digit_mult;
		if (UINT32_MAX - digit_value < value) return 0; /* オーバーフロー */
		value += digit_value;
		str++;
	}
	*out = value;
	return 1;
}

// Assembly:
cmpb $0x30, (%rsi)
jne 0x5371
movzbl 0x1(%rsi), %r9d
testl %r9d, %r9d
je 0x53d7
cmpl $0x42, %r9d
je 0x5375
cmpl $0x78, %r9d
je 0x5369
cmpl $0x62, %r9d
je 0x5375
cmpl $0x58, %r9d
jne 0x537d
addq $0x2, %rsi
pushq $0x10
jmp 0x5382
pushq $0xa
jmp 0x5382
addq $0x2, %rsi
pushq $0x2
jmp 0x5382
incq %rsi
pushq $0x8
popq %rcx
xorl %r9d, %r9d
xorl %r8d, %r8d
movzbl (%rsi), %r10d
testl %r10d, %r10d
je 0x53d7
leal -0x30(%r10), %eax
cmpb $0x9, %al
ja 0x53a0
movzbl %al, %r10d
jmp 0x53ba
leal -0x61(%r10), %eax
cmpb $0x19, %al
ja 0x53ae
addl $-0x57, %r10d
jmp 0x53ba
leal -0x41(%r10), %eax
cmpb $0x19, %al
ja 0x53e2
addl $-0x37, %r10d
cmpl %ecx, %r10d
jae 0x53de
movl %ecx, %eax
mull %r9d
jo 0x53de
imull %ecx, %r9d
addl %r9d, %r10d
jb 0x53de
incq %rsi
movl %r10d, %r9d
jmp 0x5389
movl %r9d, (%rdi)
pushq $0x1
popq %r8
movl %r8d, %eax
retq
xorl %r8d, %r8d
jmp 0x53de
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dynamic_memory.c
// Function: dmemory_read
void dmemory_read(void* dest, uint32_t addr, uint32_t size) {
	if (size > 0 && size - 1 > UINT32_MAX - addr) size = UINT32_MAX - addr + 1;
	uint8_t* destu8 = (uint8_t*)dest;
	int fidx_s, sidx_s, fidx_e, sidx_e;
	if (!get_idxs(&fidx_s, &sidx_s, &fidx_e, &sidx_e, addr, size)) return;
	uint32_t read_offset = addr % ALLOCATE_UNIT_SIZE;
	uint32_t read_size = ALLOCATE_UNIT_SIZE - read_offset;
	int i, j;
	for (i = fidx_s; i <= fidx_e; i++) {
		int jmin = (i == fidx_s ? sidx_s : 0);
		int jmax = (i == fidx_e ? sidx_e : SECOND_TABLE_SIZE - 1);
		for (j = jmin; j <= jmax; j++) {
			if (read_size > size) read_size = size;
			if (aut_table[i] != NULL && (*aut_table[i])[j] != NULL) {
				memcpy(destu8, *(*aut_table[i])[j] + read_offset, read_size);
			}
			destu8 += read_size;
			size -= read_size;
			read_offset = 0;
			read_size = ALLOCATE_UNIT_SIZE;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %ebp
movl %edx, %eax
negl %eax
movl %esi, %ebx
negl %ebx
cmpl %esi, %eax
cmovael %edx, %ebx
movq %rdi, %r14
testl %edx, %edx
cmovel %edx, %ebx
leaq 0x14(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movl %ebp, %r8d
movl %ebx, %r9d
callq 0x5d02
testl %eax, %eax
je 0x5cf3
movl %ebp, %ecx
andl $0xfff, %ecx            # imm = 0xFFF
movl $0x1000, %r13d          # imm = 0x1000
subl %ecx, %r13d
movslq 0x14(%rsp), %rax
movslq 0xc(%rsp), %rdx
movslq 0x10(%rsp), %rsi
movq %rsi, 0x20(%rsp)
movslq 0x8(%rsp), %rsi
movq %rsi, 0x18(%rsp)
leaq 0xc51e(%rip), %rdi      # 0x12170
movq %rax, 0x30(%rsp)
movq %rax, %r8
movq %rdx, 0x28(%rsp)
cmpq %rdx, %r8
jg 0x5cf3
cmpq 0x30(%rsp), %r8
movl $0x0, %ebp
cmoveq 0x20(%rsp), %rbp
cmpq %rdx, %r8
movl $0x3ff, %r12d           # imm = 0x3FF
cmoveq 0x18(%rsp), %r12
cmpq %r12, %rbp
jg 0x5ce6
cmpl %ebx, %r13d
cmovael %ebx, %r13d
movq (%rdi,%r8,8), %rax
movl %r13d, %r15d
testq %rax, %rax
je 0x5cd3
movq (%rax,%rbp,8), %rsi
testq %rsi, %rsi
je 0x5cd3
movl %ecx, %eax
addq %rax, %rsi
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, 0x4(%rsp)
movq %r14, %rbx
movq %r8, %r14
callq 0x10e0
movq %r14, %r8
movq %rbx, %r14
movl 0x4(%rsp), %ebx
leaq 0xc49d(%rip), %rdi      # 0x12170
addq %r15, %r14
subl %r13d, %ebx
incq %rbp
movl $0x1000, %r13d          # imm = 0x1000
xorl %ecx, %ecx
jmp 0x5c87
incq %r8
movq 0x28(%rsp), %rdx
jmp 0x5c5f
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dynamic_memory.c
// Function: get_idxs
static int get_idxs(int* fidx_s, int* sidx_s, int* fidx_e, int* sidx_e, uint32_t addr, uint32_t size) {
	if (size == 0) return 0;
	size--;
	if (size > UINT32_MAX - addr) return 0;
	*fidx_s = (addr >> FIRST_TABLE_SHIFT) % FIRST_TABLE_SIZE;
	*sidx_s = (addr >> SECOND_TABLE_SHIFT) % SECOND_TABLE_SIZE;
	*fidx_e = ((addr + size) >> FIRST_TABLE_SHIFT) % FIRST_TABLE_SIZE;
	*sidx_e = ((addr + size) >> SECOND_TABLE_SHIFT) % SECOND_TABLE_SIZE;
	return 1;
}

// Assembly:
xorl %eax, %eax
testl %r9d, %r9d
je 0x5d3d
decl %r9d
addl %r8d, %r9d
jb 0x5d3d
movl %r8d, %eax
shrl $0x16, %eax
movl %eax, (%rdi)
shrl $0xc, %r8d
movl $0x3ff, %eax            # imm = 0x3FF
andl %eax, %r8d
movl %r8d, (%rsi)
movl %r9d, %esi
shrl $0x16, %esi
movl %esi, (%rdx)
shrl $0xc, %r9d
andl %eax, %r9d
movl %r9d, (%rcx)
pushq $0x1
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dynamic_memory.c
// Function: dmemory_write
void dmemory_write(void* src, uint32_t addr, uint32_t size) {
	if (size > 0 && size - 1 > UINT32_MAX - addr) size = UINT32_MAX - addr + 1;
	uint8_t* srcu8 = (uint8_t*)src;
	int fidx_s, sidx_s, fidx_e, sidx_e;
	if (!get_idxs(&fidx_s, &sidx_s, &fidx_e, &sidx_e, addr, size)) return;
	uint32_t write_offset = addr % ALLOCATE_UNIT_SIZE;
	uint32_t write_size = ALLOCATE_UNIT_SIZE - write_offset;
	int i, j;
	for (i = fidx_s; i <= fidx_e; i++) {
		int jmin = (i == fidx_s ? sidx_s : 0);
		int jmax = (i == fidx_e ? sidx_e : SECOND_TABLE_SIZE - 1);
		for (j = jmin; j <= jmax; j++) {
			if (write_size > size) write_size = size;
			if (aut_table[i] != NULL && (*aut_table[i])[j] != NULL) {
				memcpy(*(*aut_table[i])[j] + write_offset, srcu8, write_size);
			}
			srcu8 += write_size;
			size -= write_size;
			write_offset = 0;
			write_size = ALLOCATE_UNIT_SIZE;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %ebp
movl %edx, %eax
negl %eax
movl %esi, %ebx
negl %ebx
cmpl %esi, %eax
cmovael %edx, %ebx
movq %rdi, %r14
testl %edx, %edx
cmovel %edx, %ebx
leaq 0x14(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movl %ebp, %r8d
movl %ebx, %r9d
callq 0x5d02
testl %eax, %eax
je 0x5e61
movl %ebp, %ecx
andl $0xfff, %ecx            # imm = 0xFFF
movl $0x1000, %r13d          # imm = 0x1000
subl %ecx, %r13d
movslq 0x14(%rsp), %rax
movslq 0xc(%rsp), %rdx
movslq 0x10(%rsp), %rsi
movq %rsi, 0x20(%rsp)
movslq 0x8(%rsp), %rsi
movq %rsi, 0x18(%rsp)
leaq 0xc3b0(%rip), %rsi      # 0x12170
movq %rax, 0x30(%rsp)
movq %rax, %r8
movq %rdx, 0x28(%rsp)
cmpq %rdx, %r8
jg 0x5e61
cmpq 0x30(%rsp), %r8
movl $0x0, %ebp
cmoveq 0x20(%rsp), %rbp
cmpq %rdx, %r8
movl $0x3ff, %r12d           # imm = 0x3FF
cmoveq 0x18(%rsp), %r12
cmpq %r12, %rbp
jg 0x5e54
cmpl %ebx, %r13d
cmovael %ebx, %r13d
movq (%rsi,%r8,8), %rax
movl %r13d, %r15d
testq %rax, %rax
je 0x5e41
movq (%rax,%rbp,8), %rdi
testq %rdi, %rdi
je 0x5e41
movl %ecx, %eax
addq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl %ebx, 0x4(%rsp)
movq %r14, %rbx
movq %r8, %r14
callq 0x10e0
movq %r14, %r8
movq %rbx, %r14
movl 0x4(%rsp), %ebx
leaq 0xc32f(%rip), %rsi      # 0x12170
addq %r15, %r14
subl %r13d, %ebx
incq %rbp
movl $0x1000, %r13d          # imm = 0x1000
xorl %ecx, %ecx
jmp 0x5df5
incq %r8
movq 0x28(%rsp), %rdx
jmp 0x5dcd
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dynamic_memory.c
// Function: dmemory_allocate
void dmemory_allocate(uint32_t addr, uint32_t size) {
	int fidx_s, sidx_s, fidx_e, sidx_e;
	if (!get_idxs(&fidx_s, &sidx_s, &fidx_e, &sidx_e, addr, size)) return;
	int i, j;
	for (i = fidx_s; i <= fidx_e; i++) {
		int jmin = (i == fidx_s ? sidx_s : 0);
		int jmax = (i == fidx_e ? sidx_e : SECOND_TABLE_SIZE - 1);
		if (aut_table[i] == NULL) {
			aut_table[i] = malloc(sizeof(*aut_table[i]));
			if (aut_table[i] == NULL) {
				perror("malloc");
				exit(1);
			}
			for (j = 0; j < SECOND_TABLE_SIZE; j++) (*aut_table[i])[j] = NULL;
		}
		for (j = jmin; j <= jmax; j++) {
			if ((*aut_table[i])[j] == NULL) {
				(*aut_table[i])[j] = calloc(1, sizeof(*(*aut_table[i])[j]));
				if ((*aut_table[i])[j] == NULL) {
					perror("calloc");
					exit(1);
				}
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %r9d
movl %edi, %r8d
leaq 0xc(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x4(%rsp), %rdx
movq %rsp, %rcx
callq 0x5d02
testl %eax, %eax
je 0x5f5d
movslq 0xc(%rsp), %r15
movslq 0x4(%rsp), %r12
movslq 0x8(%rsp), %rax
movq %rax, 0x18(%rsp)
movslq (%rsp), %rax
movq %rax, 0x10(%rsp)
pushq $0x1
popq %rbx
movq %r15, 0x20(%rsp)
cmpq %r12, %r15
jg 0x5f5d
leaq 0xc298(%rip), %rax      # 0x12170
movq (%rax,%r15,8), %r14
testq %r14, %r14
je 0x5f2c
cmpq 0x20(%rsp), %r15
movl $0x0, %ebp
cmoveq 0x18(%rsp), %rbp
cmpq %r12, %r15
movl $0x3ff, %r13d           # imm = 0x3FF
cmoveq 0x10(%rsp), %r13
cmpq %r13, %rbp
jg 0x5f27
cmpq $0x0, (%r14,%rbp,8)
jne 0x5f22
movl $0x1000, %esi           # imm = 0x1000
movq %rbx, %rdi
callq 0x10b0
movq %rax, (%r14,%rbp,8)
testq %rax, %rax
je 0x5f6c
incq %rbp
jmp 0x5f00
incq %r15
jmp 0x5ec8
movl $0x2000, %edi           # imm = 0x2000
callq 0x1100
movq %rax, %r14
leaq 0xc230(%rip), %rax      # 0x12170
movq %r14, (%rax,%r15,8)
testq %r14, %r14
je 0x5f80
xorl %eax, %eax
cmpq $0x400, %rax            # imm = 0x400
je 0x5ee1
andq $0x0, (%r14,%rax,8)
incq %rax
jmp 0x5f4b
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6cb4(%rip), %rdi      # 0xcc27
callq 0x1160
pushq $0x1
popq %rdi
callq 0x1180
leaq 0x6c99(%rip), %rdi      # 0xcc20
jmp 0x5f73
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dynamic_memory.c
// Function: dmemory_deallocate
void dmemory_deallocate(uint32_t addr, uint32_t size) {
	int fidx_s, sidx_s, fidx_e, sidx_e;
	if (!get_idxs(&fidx_s, &sidx_s, &fidx_e, &sidx_e, addr, size)) return;
	int i, j;
	for (i = fidx_s; i <= fidx_e; i++) {
		int jmin = (i == fidx_s ? sidx_s : 0);
		int jmax = (i == fidx_e ? sidx_e : SECOND_TABLE_SIZE - 1);
		if (aut_table[i] != NULL) {
			for (j = jmin; j <= jmax; j++) {
				free((*aut_table[i])[j]);
				(*aut_table[i])[j] = NULL;
			}
			if (jmin == 0 && jmax == SECOND_TABLE_SIZE - 1) {
				free(aut_table[i]);
				aut_table[i] = NULL;
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %r9d
movl %edi, %r8d
leaq 0x14(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x5d02
testl %eax, %eax
je 0x605e
movslq 0x14(%rsp), %r14
movslq 0xc(%rsp), %r15
movl 0x10(%rsp), %eax
movl %eax, 0x4(%rsp)
movl 0x8(%rsp), %eax
movl %eax, (%rsp)
leaq 0xc192(%rip), %r13      # 0x12170
movq %r14, 0x20(%rsp)
movq %r15, 0x18(%rsp)
cmpq %r15, %r14
jg 0x605e
cmpq 0x20(%rsp), %r14
movl $0x0, %r12d
cmovel 0x4(%rsp), %r12d
cmpq %r15, %r14
movl $0x3ff, %ebp            # imm = 0x3FF
cmovel (%rsp), %ebp
movq (%r13,%r14,8), %rbx
testq %rbx, %rbx
je 0x6059
movslq %r12d, %r13
movslq %ebp, %r15
cmpq %r15, %r13
jg 0x6032
movq (%rbx,%r13,8), %rdi
callq 0x1030
andq $0x0, (%rbx,%r13,8)
incq %r13
jmp 0x601a
testl %r12d, %r12d
movq 0x18(%rsp), %r15
leaq 0xc12f(%rip), %r13      # 0x12170
jne 0x6059
cmpl $0x3ff, %ebp            # imm = 0x3FF
jne 0x6059
movq %rbx, %rdi
callq 0x1030
andq $0x0, (%r13,%r14,8)
incq %r14
jmp 0x5fe8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dynamic_memory.c
// Function: dmemory_is_allocated
int dmemory_is_allocated(uint32_t addr, uint32_t size) {
	int fidx_s, sidx_s, fidx_e, sidx_e;
	if (size == 0) return 1;
	if (!get_idxs(&fidx_s, &sidx_s, &fidx_e, &sidx_e, addr, size)) return 0;
	int i, j;
	for (i = fidx_s; i <= fidx_e; i++) {
		int jmin = (i == fidx_s ? sidx_s : 0);
		int jmax = (i == fidx_e ? sidx_e : SECOND_TABLE_SIZE - 1);
		for (j = jmin; j <= jmax; j++) {
			if (aut_table[i] == NULL || (*aut_table[i])[j] == NULL) return 0;
		}
	}
	return 1;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
pushq $0x1
popq %rbx
testl %esi, %esi
je 0x6101
movl %esi, %r9d
movl %edi, %r8d
leaq 0x14(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x5d02
testl %eax, %eax
je 0x6105
movslq 0x14(%rsp), %rcx
movslq 0xc(%rsp), %rdx
movslq 0x10(%rsp), %rsi
movslq 0x8(%rsp), %rdi
leaq 0xc0b3(%rip), %r8       # 0x12170
movq %rcx, %r9
xorl %eax, %eax
cmpq %rdx, %r9
jg 0x6101
cmpq %rcx, %r9
movl $0x0, %r10d
cmoveq %rsi, %r10
cmpq %rdx, %r9
movl $0x3ff, %r11d           # imm = 0x3FF
cmoveq %rdi, %r11
cmpq %r11, %r10
jg 0x60fc
movq (%r8,%r9,8), %r14
testq %r14, %r14
je 0x6107
cmpq $0x0, (%r14,%r10,8)
leaq 0x1(%r10), %r10
jne 0x60e1
jmp 0x6107
incq %r9
jmp 0x60c2
movl %ebx, %eax
jmp 0x6107
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_utils.c
// Function: dmem_write_uint
int dmem_write_uint(uint32_t addr, uint32_t value, int size) {
	uint8_t buffer[4];
	int i;
	if (size < 0 || 4 < size) return 0;
	if (!dmemory_is_allocated(addr, size)) return 0;
	for (i = 0; i < size; i++) buffer[i] = (value >> (8 * i)) & 0xff;
	dmemory_write(buffer, addr, size);
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
xorl %r14d, %r14d
cmpl $0x4, %edx
ja 0x615e
movl %edx, %r15d
movl %esi, %ebp
movl %edi, %ebx
movl %edx, %esi
callq 0x606d
testl %eax, %eax
je 0x615e
movl %r15d, %edx
xorl %ecx, %ecx
xorl %eax, %eax
cmpq %rax, %rdx
je 0x614e
movl %ebp, %esi
shrl %cl, %esi
movb %sil, 0x4(%rsp,%rax)
incq %rax
addl $0x8, %ecx
jmp 0x6138
leaq 0x4(%rsp), %rdi
movl %ebx, %esi
callq 0x5d3e
pushq $0x1
popq %r14
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_utils.c
// Function: dmem_read_uint
uint32_t dmem_read_uint(int* ok, uint32_t addr, int size) {
	uint8_t buffer[4];
	uint32_t res = 0;
	int i;
	if (ok != NULL) *ok = 0;
	if (size < 0 || 4 < size) return 0;
	if (!dmemory_is_allocated(addr, size)) return 0;
	dmemory_read(buffer, addr ,size);
	for (i = 0; i < size; i++) res |= buffer[i] << (8 * i);
	if (ok != NULL) *ok = 1;
	return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %edx, %r15d
movl %esi, %r12d
movq %rdi, %rbx
testq %rdi, %rdi
je 0x6189
andl $0x0, (%rbx)
xorl %ebp, %ebp
cmpl $0x4, %r15d
ja 0x61df
movl %r12d, %edi
movl %r15d, %esi
callq 0x606d
testl %eax, %eax
je 0x61df
leaq 0xc(%rsp), %r14
movq %r14, %rdi
movl %r12d, %esi
movl %r15d, %edx
callq 0x5bd0
movl %r15d, %eax
shlq $0x3, %rax
xorl %ecx, %ecx
xorl %ebp, %ebp
cmpq %rcx, %rax
je 0x61d4
movzbl (%r14), %edx
shll %cl, %edx
orl %edx, %ebp
addq $0x8, %rcx
incq %r14
jmp 0x61be
testq %rbx, %rbx
je 0x61df
movl $0x1, (%rbx)
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_utils.c
// Function: dmem_read_string
char* dmem_read_string(uint32_t addr) {
	uint32_t size = 0;
	uint8_t test_value;
	char* ret;
	/* 文字列の範囲を調べる(終端のNULを含む) */
	do {
		if (!dmemory_is_allocated(addr + size, 1)) return NULL;
		dmemory_read(&test_value, addr + size, 1);
		if (size == UINT32_MAX) return NULL;
		size++;
	} while (test_value != 0);
	/* 調べた範囲を読み込む */
	ret = malloc(size);
	if (ret == NULL) return NULL;
	dmemory_read(ret, addr, size);
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %r14d
xorl %ebx, %ebx
pushq $0x1
popq %rbp
leaq 0x7(%rsp), %r12
xorl %r15d, %r15d
leal (%r14,%r15), %r13d
movl %r13d, %edi
movl %ebp, %esi
callq 0x606d
testl %eax, %eax
je 0x625a
movq %r12, %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x5bd0
cmpl $-0x1, %r15d
je 0x625a
incl %r15d
cmpb $0x0, 0x7(%rsp)
jne 0x6209
movl %r15d, %edi
callq 0x1100
testq %rax, %rax
je 0x6258
movq %rax, %rbx
movq %rax, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x5bd0
jmp 0x625a
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_utils.c
// Function: dmem_get_args
int dmem_get_args(uint32_t esp, int num, ...) {
	va_list args;
	int ok = 1;
	int i;
	uint32_t addr = esp;
	va_start(args, num);
	for (i = 0; ok && i < num; i++) {
		uint32_t* dest = va_arg(args, uint32_t*);
		if (UINT32_MAX - addr < 4) {
			ok = 0;
			break;
		}
		addr += 4;
		*dest = dmem_read_uint(&ok, addr, 4);
	}
	va_end(args);
	return ok;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movl %esi, %ebx
movl %edi, %ebp
leaq 0x30(%rsp), %rsi
movq %rdx, 0x10(%rsi)
movq %rcx, 0x18(%rsi)
movq %r8, 0x20(%rsi)
movq %r9, 0x28(%rsi)
testb %al, %al
je 0x62d4
movaps %xmm0, 0x60(%rsp)
movaps %xmm1, 0x70(%rsp)
movaps %xmm2, 0x80(%rsp)
movaps %xmm3, 0x90(%rsp)
movaps %xmm4, 0xa0(%rsp)
movaps %xmm5, 0xb0(%rsp)
movaps %xmm6, 0xc0(%rsp)
movaps %xmm7, 0xd0(%rsp)
leaq 0xc(%rsp), %r14
movl $0x1, (%r14)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, 0x10(%rsp)
leaq 0x120(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %rsi, 0x20(%rsp)
xorl %r12d, %r12d
pushq $0x1
popq %rax
pushq $0x4
popq %r15
testl %eax, %eax
je 0x6367
cmpl %ebx, %r12d
jge 0x6367
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x632f
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x633d
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
cmpl $-0x4, %ebp
jae 0x6362
movq (%rax), %r13
addl $0x4, %ebp
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x616c
movl %eax, (%r13)
incl %r12d
movl 0xc(%rsp), %eax
jmp 0x630b
andl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_libc_stdio.c
// Function: dmem_libc_stdio_initialize
int dmem_libc_stdio_initialize(uint32_t iob_addr_in) {
	int i;
	iob_addr = iob_addr_in;
	for (i = 0; i < IOB_SIZE; i++) {
		file_info[i].fp = NULL;
		file_info[i].is_standard = 0;
		file_info[i].can_read = 0;
		file_info[i].can_write = 0;
		file_info[i].previous_operation = POP_NONE;
	}
	file_info[0].fp = stdin;
	file_info[0].is_standard = 1;
	file_info[0].can_read = 1;
	file_info[1].fp = stdout;
	file_info[1].is_standard = 1;
	file_info[1].can_write = 1;
	file_info[2].fp = stderr;
	file_info[2].is_standard = 1;
	file_info[2].can_write = 1;
	return 1;
}

// Assembly:
movl %edi, 0xddea(%rip)      # 0x14170
xorl %eax, %eax
leaq 0xddf1(%rip), %rcx      # 0x14180
xorps %xmm0, %xmm0
cmpq $0xc00, %rax            # imm = 0xC00
je 0x63aa
movups %xmm0, (%rax,%rcx)
andq $0x0, 0x10(%rax,%rcx)
addq $0x18, %rax
jmp 0x6392
movq 0xbc27(%rip), %rax      # 0x11fd8
movq (%rax), %rax
movq %rax, 0xddc5(%rip)      # 0x14180
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0xddbc(%rip)      # 0x14188
movq 0xbbfd(%rip), %rax      # 0x11fd0
movq (%rax), %rax
movq %rax, 0xddbb(%rip)      # 0x14198
pushq $0x1
popq %rax
movl %eax, 0xddba(%rip)      # 0x141a0
movl %eax, 0xddbc(%rip)      # 0x141a8
movq 0xbc05(%rip), %rcx      # 0x11ff8
movq (%rcx), %rcx
movq %rcx, 0xddb3(%rip)      # 0x141b0
movl %eax, 0xddb5(%rip)      # 0x141b8
movl %eax, 0xddb7(%rip)      # 0x141c0
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_libc_stdio.c
// Function: file_ptr_to_info
static file_info_t* file_ptr_to_info(uint32_t file_ptr) {
	uint32_t delta;
	if (file_ptr < iob_addr) return NULL;
	delta = file_ptr - iob_addr;
	if (delta % BYTE_PER_IOB_FILE != 0) return NULL;
	delta /= BYTE_PER_IOB_FILE;
	return delta < IOB_SIZE ? &file_info[delta] : NULL;
}

// Assembly:
subl 0xdcd0(%rip), %edi      # 0x14170
jb 0x64a8
testb $0x1f, %dil
je 0x64ab
xorl %eax, %eax
retq
movl %edi, %eax
shrl $0x5, %eax
imulq $0x18, %rax, %rax
leaq 0xdcc5(%rip), %rcx      # 0x14180
addq %rax, %rcx
xorl %eax, %eax
cmpl $0x1000, %edi           # imm = 0x1000
cmovbq %rcx, %rax
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_libc_stdio.c
// Function: integer_to_string
static uint32_t integer_to_string(char* dest, uint32_t value,
uint32_t least_digits, uint32_t radix, const char* digits) {
	char buffer[64];
	char *p = buffer + (sizeof(buffer) / sizeof(*buffer));
	uint32_t digit_cnt = 0;
	uint32_t i;
	/* 変換する */
	while (value > 0 || least_digits > 0) {
		*(--p) = digits[value % radix];
		value /= radix;
		if (least_digits > 0) least_digits--;
		digit_cnt++;
	}
	/* 結果を書き込む */
	for (i = 0; i < digit_cnt; i++) dest[i] = p[i];
	return digit_cnt;
}

// Assembly:
movl %edx, %r9d
movl %esi, %eax
xorl %r10d, %r10d
xorl %esi, %esi
movl %eax, %edx
orl %r9d, %edx
je 0x7989
xorl %edx, %edx
divl %ecx
movb (%r8,%rdx), %dl
movb %dl, -0x9(%rsp,%rsi)
subl $0x1, %r9d
cmovbl %r10d, %r9d
decq %rsi
jmp 0x7969
movq %rsi, %rax
negq %rax
movl %eax, %ecx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x79ae
leaq (%rsp,%rdx), %r8
addq $-0x48, %r8
movb 0x40(%rsi,%r8), %r8b
movb %r8b, (%rdi,%rdx)
incq %rdx
jmp 0x7993
retq
nop
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_libc_stdlib.c
// Function: dmem_libc_stdlib_initialize
int dmem_libc_stdlib_initialize(uint32_t heap_start_addr) {
	if (heap_start_addr % HEAP_ALIGN != 0) {
		uint32_t delta = HEAP_ALIGN - heap_start_addr % HEAP_ALIGN;
		if (UINT32_MAX - delta < heap_start_addr) return 0;
		heap_start = heap_start_addr + delta;
	} else {
		heap_start = heap_start_addr;
	}
	if (heap_start == 0) heap_start = HEAP_ALIGN;
	heap_info_head = NULL;
	return 1;
}

// Assembly:
movl %edi, %ecx
andl $0x3f, %ecx
je 0x79c6
addl $-0x41, %ecx
xorl %eax, %eax
cmpl %edi, %ecx
jb 0x79df
andl $-0x40, %edi
addl $0x40, %edi
testl %edi, %edi
pushq $0x40
popq %rax
cmovnel %edi, %eax
movl %eax, 0xd3ac(%rip)      # 0x14d80
andq $0x0, 0xd3ac(%rip)      # 0x14d88
pushq $0x1
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_libc_stdlib.c
// Function: dmem_libc_calloc
int dmem_libc_calloc(uint32_t* ret, uint32_t esp) {
	uint32_t num, elem_size;
	if (!dmem_get_args(esp, 2, &num, &elem_size)) return 0;
	if (num > 0 && UINT32_MAX / num < elem_size) {
		*ret = 0;
	} else {
		size_t size = elem_size * num;
		char* buf = malloc(size);
		*ret = malloc_core(size);
		if (buf != NULL) {
			memset(buf, 0, size);
			dmemory_write(buf, *ret, size);
			free(buf);
		} else {
			size_t i;
			uint8_t cbuf = 0;
			for (i = 0; i < size; i++) {
				dmemory_write(&cbuf, (*ret) + i, 1);
			}
		}
	}
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %esi, %eax
movq %rdi, %rbx
xorl %ebp, %ebp
pushq $0x2
popq %rsi
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movl %eax, %edi
xorl %eax, %eax
callq 0x626c
testl %eax, %eax
je 0x7a5f
movl 0xc(%rsp), %ecx
movl 0x8(%rsp), %r14d
testl %ecx, %ecx
je 0x7a26
movl %ecx, %eax
mull %r14d
jno 0x7a26
andl $0x0, (%rbx)
jmp 0x7a5c
imull %ecx, %r14d
pushq $0x1
popq %rdi
movq %r14, %rsi
callq 0x10b0
movq %rax, %r15
movl %r14d, %edi
callq 0x7a96
movl %eax, (%rbx)
testq %r15, %r15
je 0x7a6e
movq %r15, %rdi
movl %eax, %esi
movl %r14d, %edx
callq 0x5d3e
movq %r15, %rdi
callq 0x1030
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7(%rsp), %r15
movb $0x0, (%r15)
xorl %r12d, %r12d
pushq $0x1
popq %rbp
cmpq %r12, %r14
je 0x7a5f
movl (%rbx), %esi
addl %r12d, %esi
movq %r15, %rdi
movl %ebp, %edx
callq 0x5d3e
incq %r12
jmp 0x7a7d
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_libc_stdlib.c
// Function: malloc_core
static uint32_t malloc_core(uint32_t size) {
	heap_info_t** pptr = &heap_info_head;
	heap_info_t* ptr = heap_info_head;
	heap_info_t* new_node;
	uint32_t addr = heap_start;
	if (UINT32_MAX - (HEAP_ALIGN - 1) < size) {
		return 0;
	}
	size = (size + (HEAP_ALIGN - 1)) / HEAP_ALIGN * HEAP_ALIGN;
	if (size == 0) size = HEAP_ALIGN;
	while(ptr != NULL) {
		if (!ptr->used && ptr->size >= size) {
			/* 十分な空き領域が見つかった */
			if (ptr->size == size) {
				/* ちょうどいい大きさ */
				ptr->used = 1;
			} else {
				/* 余る */
				new_node = malloc(sizeof(heap_info_t));
				if (new_node == NULL) {
					return 0;
				}
				new_node->size = ptr->size - size;
				new_node->used = 0;
				new_node->next = ptr->next;
				ptr->size = size;
				ptr->used = 1;
				ptr->next = new_node;
			}
			return addr;
		} else {
			addr += ptr->size;
			pptr = &ptr->next;
			ptr = ptr->next;
		}
	}
	/* 空き領域が見つからなかったので、作る */
	new_node = malloc(sizeof(heap_info_t));
	if (new_node == NULL) {
		return 0;
	}
	dmemory_allocate(addr, size);
	new_node->size = size;
	new_node->used = 1;
	new_node->next = NULL;
	*pptr = new_node;
	return addr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
xorl %ebp, %ebp
cmpl $-0x40, %edi
ja 0x7b5a
movl 0xd2d1(%rip), %ebx      # 0x14d80
addl $0x3f, %edi
andl $-0x40, %edi
pushq $0x40
popq %r14
cmovnel %edi, %r14d
leaq 0xd2c4(%rip), %r12      # 0x14d88
movq (%r12), %r15
testq %r15, %r15
je 0x7aee
cmpl $0x0, 0x4(%r15)
setne %al
movl (%r15), %r12d
cmpl %r14d, %r12d
setb %cl
orb %al, %cl
je 0x7b1e
addl %r12d, %ebx
addq $0x8, %r15
movq %r15, %r12
jmp 0x7ac4
pushq $0x10
popq %rdi
callq 0x1100
testq %rax, %rax
je 0x7b5a
movq %rax, %r15
movl %ebx, %edi
movl %r14d, %esi
callq 0x5e70
movl %r14d, (%r15)
movl $0x1, 0x4(%r15)
andq $0x0, 0x8(%r15)
movq %r15, (%r12)
jmp 0x7b58
subl %r14d, %r12d
jne 0x7b2d
movl $0x1, 0x4(%r15)
jmp 0x7b58
pushq $0x10
popq %rdi
callq 0x1100
testq %rax, %rax
je 0x7b5a
movl %r12d, (%rax)
andl $0x0, 0x4(%rax)
movq 0x8(%r15), %rcx
movq %rcx, 0x8(%rax)
movl %r14d, (%r15)
movl $0x1, 0x4(%r15)
movq %rax, 0x8(%r15)
movl %ebx, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_libc_stdlib.c
// Function: free_core
static int free_core(uint32_t addr_to_free) {
	heap_info_t* prev_ptr = NULL;
	heap_info_t* ptr = heap_info_head;
	uint32_t addr = heap_start;
	if (addr_to_free == 0) return 1;
	while (ptr != NULL) {
		if (ptr->used && addr == addr_to_free) {
			ptr->used = 0;
			if (prev_ptr != NULL && !prev_ptr->used) {
				/* 空き領域を統合する */
				prev_ptr->size += ptr->size;
				prev_ptr->next = ptr->next;
				free(ptr);
			}
			return 1;
		}
		addr += ptr->size;
		prev_ptr = ptr;
		ptr = ptr->next;
	}
	/* 該当の領域が見つからなかった */
	return 0;
}

// Assembly:
pushq %rbx
pushq $0x1
popq %rbx
testl %edi, %edi
je 0x7bef
leaq 0xd1e5(%rip), %rsi      # 0x14d88
movl 0xd1d7(%rip), %edx      # 0x14d80
xorl %ecx, %ecx
movq (%rsi), %rax
testq %rax, %rax
je 0x7bc8
cmpl $0x0, 0x4(%rax)
je 0x7bbd
cmpl %edi, %edx
je 0x7bcc
addl (%rax), %edx
leaq 0x8(%rax), %rsi
movq %rax, %rcx
jmp 0x7bab
xorl %ebx, %ebx
jmp 0x7bef
andl $0x0, 0x4(%rax)
testq %rcx, %rcx
je 0x7bef
cmpl $0x0, 0x4(%rcx)
jne 0x7bef
movl (%rax), %edx
addl %edx, (%rcx)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rcx)
movq %rax, %rdi
callq 0x1030
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_libc_string.c
// Function: dmem_libc_memcpy
int dmem_libc_memcpy(uint32_t* ret, uint32_t esp) {
	uint32_t dest, src, size;
	char* buf;
	if (!dmem_get_args(esp, 3, &dest, &src, &size)) return 0;
	if (!dmemory_is_allocated(src, size) || !dmemory_is_allocated(dest, size)) return 0;

	buf = malloc(size);
	if (buf == NULL) return 0;
	dmemory_read(buf, src, size);
	dmemory_write(buf, dest, size);
	*ret = dest;
	free(buf);
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %esi, %eax
movq %rdi, %rbx
xorl %ebp, %ebp
pushq $0x3
popq %rsi
leaq 0x10(%rsp), %rdx
leaq 0x14(%rsp), %rcx
leaq 0xc(%rsp), %r8
movl %eax, %edi
xorl %eax, %eax
callq 0x626c
testl %eax, %eax
je 0x7e73
movl 0x14(%rsp), %edi
movl 0xc(%rsp), %esi
callq 0x606d
testl %eax, %eax
je 0x7e73
movl 0x10(%rsp), %edi
movl 0xc(%rsp), %esi
callq 0x606d
testl %eax, %eax
je 0x7e73
movl 0xc(%rsp), %r15d
movq %r15, %rdi
callq 0x1100
testq %rax, %rax
je 0x7e73
movq %rax, %r14
movl 0x14(%rsp), %esi
movq %rax, %rdi
movl %r15d, %edx
callq 0x5bd0
movl 0x10(%rsp), %esi
movl 0xc(%rsp), %edx
movq %r14, %rdi
callq 0x5d3e
movl 0x10(%rsp), %eax
movl %eax, (%rbx)
movq %r14, %rdi
callq 0x1030
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_libc_string.c
// Function: dmem_libc_strcpy
int dmem_libc_strcpy(uint32_t* ret, uint32_t esp) {
	uint32_t dest, src;
	char* str;
	size_t str_len;
	if (!dmem_get_args(esp, 2, &dest, &src)) return 0;

	str = dmem_read_string(src);
	if (str == NULL) return 0;
	str_len = strlen(str);
	if (UINT32_MAX - 1 < str_len) return 0;
	if (!dmemory_is_allocated(dest, (uint32_t)str_len + 1)) return 0;
	dmemory_write(str, dest, (uint32_t)str_len + 1);
	*ret = dest;
	return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %eax
movq %rdi, %r14
xorl %ebx, %ebx
pushq $0x2
popq %rsi
movq %rsp, %rdx
leaq 0x4(%rsp), %rcx
movl %eax, %edi
xorl %eax, %eax
callq 0x626c
testl %eax, %eax
je 0x7ef6
movl 0x4(%rsp), %edi
callq 0x61ee
testq %rax, %rax
je 0x7ef6
movq %rax, %r15
movq %rax, %rdi
callq 0x1080
movq %rax, %r12
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmpq %rax, %r12
ja 0x7ef6
movl (%rsp), %edi
incl %r12d
movl %r12d, %esi
callq 0x606d
testl %eax, %eax
je 0x7ef6
movl (%rsp), %esi
movq %r15, %rdi
movl %r12d, %edx
callq 0x5d3e
movl (%rsp), %eax
movl %eax, (%r14)
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_libc_string.c
// Function: dmem_libc_strncpy
int dmem_libc_strncpy(uint32_t* ret, uint32_t esp) {
	uint32_t dest, src, limit;
	uint32_t i;
	int use_src = 1;
	int printf(const char*, ...);
	if (!dmem_get_args(esp, 3, &dest, &src, &limit)) return 0;
	if (!dmemory_is_allocated(dest, limit)) return 0;
	for (i = 0; i < limit; i++) {
		uint8_t c;
		int ok = 0;
		if (use_src) {
			if (UINT32_MAX - i < src) return 0;
			c = (uint8_t)dmem_read_uint(&ok, src + i, 1);
			if (!ok) return 0;
			if (c == 0) use_src = 0;
		} else {
			c = 0;
		}
		dmemory_write(&c, dest + i, 1);
	}
	*ret = dest;
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %eax
movq %rdi, %rbx
xorl %ebp, %ebp
pushq $0x3
popq %rsi
leaq 0x10(%rsp), %rdx
leaq 0x1c(%rsp), %rcx
leaq 0x18(%rsp), %r8
movl %eax, %edi
xorl %eax, %eax
callq 0x626c
testl %eax, %eax
je 0x7fd9
movl 0x10(%rsp), %edi
movl 0x18(%rsp), %esi
callq 0x606d
testl %eax, %eax
je 0x7fd9
movq %rbx, 0x20(%rsp)
pushq $0x1
popq %rbx
xorl %r12d, %r12d
pushq $-0x1
popq %r13
leaq 0xf(%rsp), %r14
leaq 0x14(%rsp), %r15
movl %ebx, %ebp
cmpl 0x18(%rsp), %r12d
jae 0x7fcb
andl $0x0, 0x14(%rsp)
testl %ebp, %ebp
je 0x7fa7
movl 0x1c(%rsp), %esi
cmpl %r13d, %esi
ja 0x7fc7
addl %r12d, %esi
movq %r15, %rdi
movl %ebx, %edx
callq 0x616c
movb %al, 0xf(%rsp)
cmpl $0x0, 0x14(%rsp)
je 0x7fc7
xorl %ebp, %ebp
testb %al, %al
setne %bpl
jmp 0x7fae
movb $0x0, 0xf(%rsp)
xorl %ebp, %ebp
movl 0x10(%rsp), %esi
addl %r12d, %esi
movq %r14, %rdi
movl %ebx, %edx
callq 0x5d3e
incl %r12d
decl %r13d
jmp 0x7f6c
xorl %ebp, %ebp
jmp 0x7fd9
movl 0x10(%rsp), %eax
movq 0x20(%rsp), %rcx
movl %eax, (%rcx)
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_libc_string.c
// Function: dmem_libc_strcmp
int dmem_libc_strcmp(uint32_t* ret, uint32_t esp) {
	uint32_t sptr1, sptr2;
	uint32_t i;
	if (!dmem_get_args(esp, 2, &sptr1, &sptr2)) return 0;

	for (i = 0; ; i++) {
		uint32_t c1, c2;
		int ok1, ok2;
		if (UINT32_MAX - sptr1 < i || UINT32_MAX - sptr2 < i) return 0;
		c1 = dmem_read_uint(&ok1, sptr1 + i, 1);
		c2 = dmem_read_uint(&ok2, sptr2 + i, 1);
		if (!(ok1 && ok2)) return 0;
		if (c1 > c2) {
			*ret = 1;
			return 1;
		} else if (c1 < c2) {
			*ret = -1;
			return 1;
		} else if (c1 == 0) { /* c1 == c2 */
			*ret = 0;
			return 1;
		}
		if (i == UINT32_MAX) return 0;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %eax
movq %rdi, %r14
xorl %ebx, %ebx
pushq $0x2
popq %rsi
leaq 0xc(%rsp), %rdx
movq %rsp, %rcx
movl %eax, %edi
xorl %eax, %eax
callq 0x626c
testl %eax, %eax
je 0x808e
movq %r14, 0x10(%rsp)
leaq 0x8(%rsp), %r15
pushq $0x1
popq %rbx
leaq 0x4(%rsp), %r12
pushq $-0x1
popq %r13
xorl %r14d, %r14d
movl 0xc(%rsp), %esi
addl %r14d, %esi
jb 0x807a
movl (%rsp), %eax
addl %r14d, %eax
jb 0x807a
movq %r15, %rdi
movl %ebx, %edx
callq 0x616c
movl %eax, %ebp
movl (%rsp), %esi
addl %r14d, %esi
movq %r12, %rdi
movl %ebx, %edx
callq 0x616c
cmpl $0x0, 0x8(%rsp)
je 0x807a
cmpl $0x0, 0x4(%rsp)
je 0x807a
cmpl %eax, %ebp
ja 0x807e
jb 0x8086
testl %ebp, %ebp
je 0x8083
incl %r14d
jne 0x8030
xorl %ebx, %ebx
jmp 0x808e
movl %ebx, %r13d
jmp 0x8086
xorl %r13d, %r13d
movq 0x10(%rsp), %rax
movl %r13d, (%rax)
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_libc_string.c
// Function: dmem_libc_strncmp
int dmem_libc_strncmp(uint32_t* ret, uint32_t esp) {
	uint32_t sptr1, sptr2, n;
	uint32_t i;
	if (!dmem_get_args(esp, 3, &sptr1, &sptr2, &n)) return 0;

	for (i = 0; i < n; i++) {
		uint32_t c1, c2;
		int ok1, ok2;
		if (UINT32_MAX - sptr1 < i || UINT32_MAX - sptr2 < i) return 0;
		c1 = dmem_read_uint(&ok1, sptr1 + i, 1);
		c2 = dmem_read_uint(&ok2, sptr2 + i, 1);
		if (!(ok1 && ok2)) return 0;
		if (c1 > c2) {
			*ret = 1;
			return 1;
		} else if (c1 < c2) {
			*ret = -1;
			return 1;
		} else if (c1 == 0) { /* c1 == c2 */
			break;
		}
		if (i == UINT32_MAX) return 0;
	}
	*ret = 0;
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %eax
movq %rdi, %rbx
xorl %ebp, %ebp
pushq $0x3
popq %rsi
leaq 0x1c(%rsp), %rdx
leaq 0xc(%rsp), %rcx
leaq 0x18(%rsp), %r8
movl %eax, %edi
xorl %eax, %eax
callq 0x626c
testl %eax, %eax
je 0x815e
movq %rbx, 0x20(%rsp)
xorl %ebx, %ebx
leaq 0x14(%rsp), %r15
pushq $0x1
popq %r14
leaq 0x10(%rsp), %r12
xorl %ebp, %ebp
cmpl 0x18(%rsp), %ebx
jae 0x813f
movl 0x1c(%rsp), %esi
addl %ebx, %esi
jb 0x815e
movl 0xc(%rsp), %eax
addl %ebx, %eax
jb 0x815e
movq %r15, %rdi
movl %r14d, %edx
callq 0x616c
movl %eax, %r13d
movl 0xc(%rsp), %esi
addl %ebx, %esi
movq %r12, %rdi
movl %r14d, %edx
callq 0x616c
cmpl $0x0, 0x14(%rsp)
je 0x815e
cmpl $0x0, 0x10(%rsp)
je 0x815e
cmpl %eax, %r13d
ja 0x814c
jb 0x8151
incl %ebx
testl %r13d, %r13d
jne 0x80ee
movq 0x20(%rsp), %rax
andl $0x0, (%rax)
pushq $0x1
popq %rbp
jmp 0x815e
movl %r14d, %ecx
jmp 0x8154
pushq $-0x1
popq %rcx
movq 0x20(%rsp), %rax
movl %ecx, (%rax)
movl %r14d, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_libc_string.c
// Function: dmem_libc_strchr
int dmem_libc_strchr(uint32_t* ret, uint32_t esp) {
	uint32_t str_ptr, target;
	char* str;
	char* res;
	if (!dmem_get_args(esp, 2, &str_ptr, &target)) return 0;

	str = dmem_read_string(str_ptr);
	if (str == NULL) return 0;

	res = strchr(str, target);
	if (res == NULL) {
		*ret = 0;
	} else {
		*ret = str_ptr + (res - str);
	}
	free(str);
	return 1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %eax
movq %rdi, %rbx
xorl %ebp, %ebp
pushq $0x2
popq %rsi
leaq 0x8(%rsp), %rdx
leaq 0xc(%rsp), %rcx
movl %eax, %edi
xorl %eax, %eax
callq 0x626c
testl %eax, %eax
je 0x81d3
movl 0x8(%rsp), %edi
callq 0x61ee
testq %rax, %rax
je 0x81d3
movq %rax, %r14
movl 0xc(%rsp), %esi
movq %rax, %rdi
callq 0x1090
movl %eax, %ecx
subl %r14d, %ecx
addl 0x8(%rsp), %ecx
xorl %edx, %edx
testq %rax, %rax
cmovnel %ecx, %edx
movl %edx, (%rbx)
movq %r14, %rdi
callq 0x1030
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_libc_string.c
// Function: dmem_libc_memset
int dmem_libc_memset(uint32_t* ret, uint32_t esp) {
	uint32_t target, data, size;
	char* buf;
	if (!dmem_get_args(esp, 3, &target, &data, &size)) return 0;
	if (!dmemory_is_allocated(target, size)) return 0;
	buf = malloc(size);
	if (buf == NULL) return 0;
	memset(buf, (uint8_t)data, size);
	dmemory_write(buf, target, size);
	free(buf);
	*ret = target;
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %esi, %eax
movq %rdi, %rbx
xorl %ebp, %ebp
pushq $0x3
popq %rsi
leaq 0xc(%rsp), %rdx
leaq 0x14(%rsp), %rcx
leaq 0x10(%rsp), %r8
movl %eax, %edi
xorl %eax, %eax
callq 0x626c
testl %eax, %eax
je 0x8263
movl 0xc(%rsp), %edi
movl 0x10(%rsp), %esi
callq 0x606d
testl %eax, %eax
je 0x8263
movl 0x10(%rsp), %r14d
movq %r14, %rdi
callq 0x1100
testq %rax, %rax
je 0x8263
movq %rax, %r15
movl 0x14(%rsp), %esi
movq %rax, %rdi
movq %r14, %rdx
callq 0x10a0
movl 0xc(%rsp), %esi
movq %r15, %rdi
movl %r14d, %edx
callq 0x5d3e
movq %r15, %rdi
callq 0x1030
movl 0xc(%rsp), %eax
movl %eax, (%rbx)
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/dmem_libc_string.c
// Function: dmem_libc_strlen
int dmem_libc_strlen(uint32_t* ret, uint32_t esp) {
	uint32_t str_ptr;
	uint32_t i;
	if (!dmem_get_args(esp, 1, &str_ptr)) return 0;

	i = 0;
	for (;;) {
		int ok;
		uint32_t c = dmem_read_uint(&ok, str_ptr + i, 1);
		if (!ok) return 0;
		if (c == 0) {
			*ret = i;
			return 1;
		}
		if (i == UINT32_MAX || UINT32_MAX - i - 1 < str_ptr) return 0;
		i++;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %esi, %eax
movq %rdi, %r14
xorl %ebx, %ebx
pushq $0x1
popq %rsi
leaq 0x8(%rsp), %rdx
movl %eax, %edi
xorl %eax, %eax
callq 0x626c
testl %eax, %eax
je 0x82da
pushq $-0x2
popq %rbp
movl 0x8(%rsp), %esi
leaq 0xc(%rsp), %r15
pushq $0x1
popq %rbx
xorl %r12d, %r12d
addl %r12d, %esi
movq %r15, %rdi
movl %ebx, %edx
callq 0x616c
cmpl $0x0, 0xc(%rsp)
je 0x82d3
testl %eax, %eax
je 0x82d7
incl %r12d
je 0x82d3
movl 0x8(%rsp), %esi
cmpl %esi, %ebp
jb 0x82d3
decl %ebp
jmp 0x82aa
xorl %ebx, %ebx
jmp 0x82da
movl %r12d, (%r14)
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/read_file.c
// Function: read_whole_file
void* read_whole_file(size_t* size, const char* filename) {
	FILE* fp;
	size_t read_size = 0;
	char* buffer = NULL;
	fp = fopen(filename, "rb");
	if (fp == NULL) {
		fprintf(stderr, "input file open failed\n");
		return NULL;
	}
	for (;;) {
		char data[BUFFER_SIZE];
		size_t new_read_size = fread(data, sizeof(*data), BUFFER_SIZE, fp);
		if (ferror(fp)) {
			fprintf(stderr, "input file read error\n");
			fclose(fp);
			free(buffer);
			return NULL;
		} else if (new_read_size == 0) {
			break;
		} else {
			char *new_buffer;
			if (SIZE_MAX - read_size < new_read_size) {
				fprintf(stderr, "input file too big\n");
				fclose(fp);
				free(buffer);
				return NULL;
			}
			new_buffer = realloc(buffer, read_size + new_read_size);
			if (new_buffer == NULL) {
				perror("realloc");
				free(buffer);
				fclose(fp);
				return NULL;
			}
			buffer = new_buffer;
			memcpy(buffer + read_size, data, new_read_size);
			read_size += new_read_size;
		}
	}
	fclose(fp);
	if (size != NULL) *size = read_size;
	return buffer;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1018, %rsp           # imm = 0x1018
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x434a(%rip), %rsi      # 0xcf24
movq %rax, %rdi
callq 0x1150
movq %rax, (%rsp)
testq %rax, %rax
je 0x8c8e
movq %rbx, 0x8(%rsp)
xorl %r14d, %r14d
leaq 0x10(%rsp), %rbx
xorl %r12d, %r12d
movl $0x1000, %edx           # imm = 0x1000
movq %rbx, %rdi
pushq $0x1
popq %rsi
movq (%rsp), %r13
movq %r13, %rcx
callq 0x1060
movq %rax, %r15
movq %r13, %rdi
callq 0x1050
testl %eax, %eax
jne 0x8cac
testq %r15, %r15
je 0x8c70
movq %r12, %rbp
addq %r15, %rbp
jb 0x8cc1
movq %rbx, %r13
movq %r14, %rdi
movq %rbp, %rsi
callq 0x1130
testq %rax, %rax
je 0x8cf0
movq %rax, %rbx
addq %rax, %r12
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x10e0
movq %rbx, %r14
movq %r13, %rbx
movq %rbp, %r12
jmp 0x8bff
movq (%rsp), %rdi
callq 0x1070
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x8c86
movq %r12, (%rax)
movq %r14, %rax
jmp 0x8d0f
movq 0x9363(%rip), %rax      # 0x11ff8
movq (%rax), %rcx
leaq 0x4288(%rip), %rdi      # 0xcf27
pushq $0x17
popq %rsi
pushq $0x1
popq %rdx
callq 0x1190
jmp 0x8d0d
movq 0x9345(%rip), %rax      # 0x11ff8
movq (%rax), %rcx
leaq 0x4282(%rip), %rdi      # 0xcf3f
pushq $0x16
jmp 0x8cd4
movq 0x9330(%rip), %rax      # 0x11ff8
movq (%rax), %rcx
leaq 0x4284(%rip), %rdi      # 0xcf56
pushq $0x13
popq %rsi
pushq $0x1
popq %rdx
callq 0x1190
movq (%rsp), %rdi
callq 0x1070
movq %r14, %rdi
callq 0x1030
jmp 0x8d0d
leaq 0x4273(%rip), %rdi      # 0xcf6a
callq 0x1160
movq %r14, %rdi
callq 0x1030
movq (%rsp), %rdi
callq 0x1070
xorl %eax, %eax
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/read_raw.c
// Function: read_raw
int read_raw(const char* filename) {
	size_t file_size = 0;
	void* file_data = read_whole_file(&file_size, filename);
	if (file_data == NULL) return 0;
	dmemory_allocate(0, file_size);
	dmemory_write(file_data, 0, file_size);
	free(file_data);
	return 1;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rsi
leaq 0x8(%rsp), %rdi
andq $0x0, (%rdi)
callq 0x8bbc
testq %rax, %rax
je 0x8d68
movq %rax, %rbx
movl 0x8(%rsp), %esi
xorl %edi, %edi
callq 0x5e70
movl 0x8(%rsp), %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5d3e
movq %rbx, %rdi
callq 0x1030
pushq $0x1
popq %rax
jmp 0x8d6a
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/mikecat[P]x86_interpreter/read_elf.c
// Function: read_num
static uint32_t read_num(const uint8_t* data, int size) {
	uint32_t ret = 0;
	int i;
	for (i = 0; i < size; i++) {
		ret |= data[i] << (i * 8);
	}
	return ret;
}

// Assembly:
xorl %ecx, %ecx
testl %esi, %esi
cmovlel %ecx, %esi
shlq $0x3, %rsi
xorl %eax, %eax
cmpq %rcx, %rsi
je 0x9107
movzbl (%rdi), %edx
shll %cl, %edx
orl %edx, %eax
addq $0x8, %rcx
incq %rdi
jmp 0x90f2
retq