LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/VeeeectorPan[P]MyNetdisk/clientSrc/recv_file_from_offset.c
// Function: recv_file_from_offset
int recv_file_from_offset(int sock_fd,int file_fd, int file_size,int offset)
{
    int total = offset;
    int pipefd[2];
    int ret = pipe(pipefd);
    ERROR_CHECK(ret,-1,"pipe");
    int download_size = 0;
    int splice_size = file_size/10000;
    int previous_download_size = 0;
    while(total < file_size)
    {
        ret = splice(sock_fd,NULL,pipefd[1],NULL,4096,SPLICE_F_MOVE|SPLICE_F_MORE);
        ERROR_CHECK(ret,-1,"splice");
        ret = splice(pipefd[0],NULL,file_fd,NULL,ret,SPLICE_F_MOVE|SPLICE_F_MORE);
        ERROR_CHECK(ret,-1,"splice");
        total += ret;
        download_size += ret;
        if(download_size - previous_download_size >= splice_size)
        {
            printf("downloading %.2f\r",(double)download_size/file_size * 100);
            fflush(stdout);
            previous_download_size = download_size;
        }
    }
    printf("downloading %.2f\n",(double)download_size/file_size * 100);
    return 0;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %ebx
movl %edx, %r15d
movl %esi, -0x2c(%rbp)
movl %edi, -0x30(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x21c0
cmpl $-0x1, %eax
je 0x4136
xorpd %xmm0, %xmm0
cvtsi2sd %r15d, %xmm1
cmpl %r15d, %ebx
jge 0x410b
movsd %xmm1, -0x38(%rbp)
movslq %r15d, %rax
imulq $0x68db8bad, %rax, %rcx # imm = 0x68DB8BAD
movq %rcx, %rax
shrq $0x3f, %rax
sarq $0x2c, %rcx
addl %eax, %ecx
movq %rcx, -0x48(%rbp)
xorl %r14d, %r14d
xorl %r12d, %r12d
movl -0x3c(%rbp), %edx
movl $0x1000, %r8d           # imm = 0x1000
movl -0x30(%rbp), %edi
xorl %esi, %esi
xorl %ecx, %ecx
movl $0x5, %r9d
callq 0x20b0
cmpl $-0x1, %eax
je 0x413f
movl -0x40(%rbp), %edi
movslq %eax, %r8
xorl %esi, %esi
movl -0x2c(%rbp), %edx
xorl %ecx, %ecx
movl $0x5, %r9d
callq 0x20b0
movq %rax, %r13
cmpl $-0x1, %r13d
je 0x413f
addl %r13d, %r12d
movl %r12d, %eax
subl %r14d, %eax
cmpl -0x48(%rbp), %eax
jl 0x40f2
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
divsd -0x38(%rbp), %xmm0
mulsd 0x10de(%rip), %xmm0     # 0x51b0
leaq 0x10eb(%rip), %rdi      # 0x51c4
movb $0x1, %al
callq 0x2030
movq 0x2ed9(%rip), %rax      # 0x6fc0
movq (%rax), %rdi
callq 0x2180
movl %r12d, %r14d
addl %r13d, %ebx
cmpl %r15d, %ebx
jl 0x4066
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movsd -0x38(%rbp), %xmm1
divsd %xmm1, %xmm0
mulsd 0x1099(%rip), %xmm0     # 0x51b0
leaq 0x10b8(%rip), %rdi      # 0x51d6
movb $0x1, %al
callq 0x2030
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x107b(%rip), %rdi      # 0x51b8
jmp 0x4146
leaq 0x1077(%rip), %rdi      # 0x51bd
callq 0x2120
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x4127
nop
// File: /workspace/github_c_makefile_star2_O1/sprt[P]lossless-transport/src/sender.c
// Function: get_timeout
uint32_t get_timeout(void) {
	/* Select waits until either the socket is ready for reading or the
	 * timeout expires. If the window is full or if we've reached EOF on the
	 * file, we can't write any more data right now and we should block,
	 * albeit at *most* until the closest timer in the window expires. */
	if ((window_full(w) && !window_empty(w)) || sent_eof) {
		uint32_t timer = pkt_get_timestamp(window_peek_min_timestamp(w));
		uint32_t now = get_monotime();
		/* select doesn't like negative timeouts, and we can't return
		 * a negative number through an unsigned type anyway */
		if (timer > now) {
			return timer - now;
		}
	}
	return 0;
}

// Assembly:
pushq %rbx
movq 0x42d8(%rip), %rdi      # 0x6560
callq 0x1fe1
testb %al, %al
je 0x22a1
movq 0x42c8(%rip), %rdi      # 0x6560
callq 0x2009
testb %al, %al
je 0x22aa
cmpb $0x1, 0x42c0(%rip)      # 0x6568
jne 0x22c9
movq 0x42af(%rip), %rdi      # 0x6560
callq 0x218c
movq %rax, %rdi
callq 0x17e8
movl %eax, %ebx
callq 0x1d45
subl %eax, %ebx
ja 0x22cb
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/sprt[P]lossless-transport/src/sender.c
// Function: handle_ack
void handle_ack(pkt_t *ack) {
	/* The seqnum field has the next sequence number expected by the receiver.
	 * The timestamp field corresponds to the last packet received by the receiver. */

	/* Whether the packet with the given timestamp has been popped from the buffer. */
	bool popped_timestamp = false;

	/* ACKs are cumulative so we can remove from the buffer all packets that
	 * have a smaller sequence number. */
	pkt_t *min_seqnum = window_peek_min_seqnum(w);
	while (min_seqnum != NULL && pkt_get_seqnum(min_seqnum) < pkt_get_seqnum(ack)) {
		assert(window_pop_min_seqnum(w) == min_seqnum);
		log_msg("Removed packet #%d from buffer\n", pkt_get_seqnum(min_seqnum));

		if (pkt_get_timestamp(min_seqnum) == pkt_get_timestamp(ack)) {
			popped_timestamp = true;
		}

		pkt_del(min_seqnum);
		min_seqnum = window_peek_min_seqnum(w);
	}

	window_slide_to(w, pkt_get_seqnum(ack));

	if (!popped_timestamp) {
		pkt_t *last = window_pop_timestamp(w, pkt_get_timestamp(ack));
		if (last == NULL) {
			log_msg("No packet with matching timestamp in buffer\n");
		} else {
			log_msg("Acking packet #%d from timestamp field, removed from buffer\n",
				pkt_get_seqnum(last));
		}
		pkt_del(last);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x427c(%rip), %rdi      # 0x6560
callq 0x2230
testq %rax, %rax
je 0x23ad
movq %rax, %r14
xorl %r12d, %r12d
leaq 0xf5a(%rip), %r15       # 0x3259
movl $0x1, %r13d
movq %r14, %rdi
callq 0x17e4
movl %eax, %ebp
movq %rbx, %rdi
callq 0x17e4
cmpb %al, %bpl
jae 0x237e
movq 0x423d(%rip), %rdi      # 0x6560
callq 0x2247
cmpq %r14, %rax
jne 0x2427
movq %r14, %rdi
callq 0x17e4
movzbl %al, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x1220
movq %r14, %rdi
callq 0x17e8
movl %eax, %ebp
movq %rbx, %rdi
callq 0x17e8
cmpl %eax, %ebp
movzbl %r12b, %r12d
cmovel %r13d, %r12d
movq %r14, %rdi
callq 0x14bb
movq 0x41ef(%rip), %rdi      # 0x6560
callq 0x2230
movq %rax, %r14
testq %rax, %rax
jne 0x2305
movq 0x41db(%rip), %r14      # 0x6560
movq %rbx, %rdi
callq 0x17e4
movzbl %al, %esi
movq %r14, %rdi
callq 0x1efc
testb $0x1, %r12b
je 0x23c7
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x41ac(%rip), %r14      # 0x6560
movq %rbx, %rdi
callq 0x17e4
movzbl %al, %esi
movq %r14, %rdi
callq 0x1efc
movq 0x4192(%rip), %r14      # 0x6560
movq %rbx, %rdi
callq 0x17e8
movq %r14, %rdi
movl %eax, %esi
callq 0x20cc
movq %rax, %rbx
testq %rax, %rax
je 0x2403
movq %rbx, %rdi
callq 0x17e4
movzbl %al, %esi
leaq 0xeac(%rip), %rdi       # 0x32a6
xorl %eax, %eax
callq 0x1220
jmp 0x2411
leaq 0xe6f(%rip), %rdi       # 0x3279
xorl %eax, %eax
callq 0x1220
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x14bb
leaq 0xdde(%rip), %rdi       # 0x320c
leaq 0xdfe(%rip), %rsi       # 0x3233
leaq 0xe04(%rip), %rcx       # 0x3240
movl $0x39, %edx
callq 0x10e0
// File: /workspace/github_c_makefile_star2_O1/sprt[P]lossless-transport/src/sender.c
// Function: handle_nack
void handle_nack(pkt_t *nack) {
	if (!window_has(w, pkt_get_seqnum(nack))) {
		log_msg("Out of window, ignoring\n");
		return;
	}

	pkt_t *match = window_find_seqnum(w, pkt_get_seqnum(nack));
	if (match == NULL) {
		log_msg("No packet with matching seqnum in buffer\n");
		return;
	}

	/* Set the timer of the corresponding packet to the current time
	 * so that it will be resent immediately (retransmit_packets calls
	 * get_monotime after this). */
	pkt_set_timestamp(match, get_monotime());
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x410c(%rip), %r14      # 0x6560
callq 0x17e4
movzbl %al, %esi
movq %r14, %rdi
callq 0x1f26
testb %al, %al
je 0x24a0
movq 0x40f1(%rip), %r14      # 0x6560
movq %rbx, %rdi
callq 0x17e4
movzbl %al, %esi
movq %r14, %rdi
callq 0x2012
testq %rax, %rax
je 0x24a9
movq %rax, %rbx
callq 0x1d45
movq %rbx, %rdi
movl %eax, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x18a3
leaq 0xe3c(%rip), %rdi       # 0x32e3
jmp 0x24b0
leaq 0xe4c(%rip), %rdi       # 0x32fc
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1220
// File: /workspace/github_c_makefile_star2_O1/sprt[P]lossless-transport/src/sender.c
// Function: retransmit_packets
void retransmit_packets(void) {
	uint32_t loop_now = get_monotime();
	pkt_t *pkt = window_peek_min_timestamp(w);

	while (pkt != NULL && pkt_get_timestamp(pkt) <= loop_now) {
		/* Don't put this outside the loop! Would defeat its purpose. */
		uint32_t now = get_monotime();

		/* Reschedule the retransmission of the packet in case it fails again */
		if (window_update_timestamp(w, pkt_get_timestamp(pkt), now + TIMER) == -1) {
			exit_msg("Cannot update timestamp of packet\n");
		}

		/* Resend it now */
		if (send_packet(sockfd, pkt) == -1) {
			exit_perror("send");
		}

		/* The packet was in the buffer already so nothing else to do */

		log_msg("> RETR %s\n", pkt_repr(pkt));
		pkt = window_peek_min_timestamp(w);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
callq 0x1d45
movl %eax, %ebx
movq 0x4089(%rip), %rdi      # 0x6560
callq 0x218c
testq %rax, %rax
je 0x2589
movq %rax, %r13
leaq 0xe5a(%rip), %r15       # 0x3349
leaq 0xe58(%rip), %r12       # 0x334e
movq %r13, %rdi
callq 0x17e8
cmpl %ebx, %eax
ja 0x2589
callq 0x1d45
movl %eax, %ebp
movq 0x404c(%rip), %r14      # 0x6560
movq %r13, %rdi
callq 0x17e8
addl $0x44aa20, %ebp         # imm = 0x44AA20
movq %r14, %rdi
movl %eax, %esi
movl %ebp, %edx
callq 0x2050
cmpl $-0x1, %eax
jne 0x2541
leaq 0xdec(%rip), %rdi       # 0x3326
xorl %eax, %eax
callq 0x1948
movl 0x3bd1(%rip), %edi      # 0x6118
movq %r13, %rsi
callq 0x1cf1
cmpl $-0x1, %eax
jne 0x255c
movq %r15, %rdi
callq 0x19ea
movq %r13, %rdi
callq 0x1a56
movq %r12, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x1220
movq 0x3fe8(%rip), %rdi      # 0x6560
callq 0x218c
movq %rax, %r13
testq %rax, %rax
jne 0x24f6
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/sprt[P]lossless-transport/src/sender.c
// Function: main
int main(int argc, char **argv) {
	parse_args(argc, argv, &hostname, &port, &filename);

	/* Initial window assumed to be 1, will be updated on ACKs */
	w = window_create(1, MAX_WINDOW_SIZE, 255);
	if (w == NULL) {
		exit_msg("Could not create window\n");
	}

	struct sockaddr_in6 dst_addr;
	const char *err = real_address(hostname, &dst_addr);
	if (err != NULL) {
		exit_msg("real_address: %s\n", err);
	}

	/* Connect the socket. This tells the socket both to send to this
	 * address by default and to only receive from this address. */
	sockfd = create_socket(NULL, -1, &dst_addr, port);
	if (sockfd == -1) {
		exit_msg("Could not create socket\n");
	}

	if (filename == NULL) {
		infile = stdin;
	} else {
		infile = fopen(filename, "rb");
		if (infile == NULL) {
			exit_perror("fopen");
		}
	}

	/* If we haven't sent the EOF packet, we still have data to read.
	 * If the window isn't empty, there are still unacknowledged packets
	 * that we'll potentially have to resend. */
	while (!sent_eof || !window_empty(w)) {
		/* This is probably the line you're looking for */
		main_loop();
	}

	log_msg("EOF acknowledged, quitting\n");

	window_free(w);
	fclose(infile);

	return 0;
}

// Assembly:
subq $0x28, %rsp
leaq 0x3a4c(%rip), %rdx      # 0x6578
leaq 0x3a4d(%rip), %rcx      # 0x6580
leaq 0x3a4e(%rip), %r8       # 0x6588
callq 0x1b17
movl $0x1, %edi
movl $0x1f, %esi
movl $0xff, %edx
callq 0x1e54
movq %rax, 0x3a06(%rip)      # 0x6560
testq %rax, %rax
jne 0x2b6d
leaq 0x9f6(%rip), %rdi       # 0x355c
xorl %eax, %eax
callq 0x1948
movq 0x3a04(%rip), %rdi      # 0x6578
leaq 0xc(%rsp), %rsi
callq 0x1bc8
testq %rax, %rax
je 0x2b94
leaq 0x9eb(%rip), %rdi       # 0x3575
movq %rax, %rsi
xorl %eax, %eax
callq 0x1948
movzwl 0x39e5(%rip), %ecx      # 0x6580
leaq 0xc(%rsp), %rdx
xorl %edi, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x1c3d
movl %eax, 0x3566(%rip)      # 0x6118
cmpl $-0x1, %eax
jne 0x2bc5
leaq 0x9c9(%rip), %rdi       # 0x3587
xorl %eax, %eax
callq 0x1948
movq 0x39bc(%rip), %rdi      # 0x6588
testq %rdi, %rdi
je 0x2bf7
leaq 0x9c8(%rip), %rsi       # 0x35a0
callq 0x1150
movq %rax, 0x398c(%rip)      # 0x6570
testq %rax, %rax
jne 0x2c0f
leaq 0x9b3(%rip), %rdi       # 0x35a3
callq 0x19ea
jmp 0x2c0f
movq 0x33ca(%rip), %rax      # 0x5fc8
movq (%rax), %rax
movq %rax, 0x3968(%rip)      # 0x6570
jmp 0x2c0f
callq 0x2598
cmpb $0x1, 0x3952(%rip)      # 0x6568
jne 0x2c0a
movq 0x3941(%rip), %rdi      # 0x6560
callq 0x2009
testb %al, %al
je 0x2c0a
leaq 0x97a(%rip), %rdi       # 0x35a9
xorl %eax, %eax
callq 0x1220
movq 0x3923(%rip), %rdi      # 0x6560
callq 0x1e93
movq 0x3927(%rip), %rdi      # 0x6570
callq 0x10b0
xorl %eax, %eax
addq $0x28, %rsp
retq
// File: /workspace/github_c_makefile_star2_O1/mikecat[P]x86_interpreter/x86_interpreter.c
// Function: print_regs
void print_regs(FILE* fp) {
	fprintf(fp, "   EAX:%08"PRIx32" EBX:%08"PRIx32" ECX:%08"PRIx32" EDX:%08"PRIx32"\n",
		regs[EAX], regs[EBX], regs[ECX], regs[EDX]);
	fprintf(fp, "   ESI:%08"PRIx32" EDI:%08"PRIx32" ESP:%08"PRIx32" EBP:%08"PRIx32"\n",
		regs[ESI], regs[EDI], regs[ESP], regs[EBP]);
	fprintf(fp, "   EIP:%08"PRIx32"\n", eip);
	fprintf(fp, "EFLAGS:%08"PRIx32
		" (CF[%c] PF[%c] AF[%c] ZF[%c] SF[%c] IF[%c] DF[%c] OF[%c])\n", eflags,
		eflags & CF ? 'x' : ' ', eflags & PF ? 'x' : ' ', eflags & AF ? 'x' : ' ',
		eflags & ZF ? 'x' : ' ', eflags & SF ? 'x' : ' ', eflags & IF ? 'x' : ' ',
		eflags & DF ? 'x' : ' ', eflags & OF ? 'x' : ' ');
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x11143(%rip), %edx     # 0x13100
movl 0x11149(%rip), %ecx     # 0x1310c
movl 0x1113a(%rip), %r8d     # 0x13104
movl 0x11137(%rip), %r9d     # 0x13108
leaq 0xb33c(%rip), %rsi      # 0xd314
xorl %eax, %eax
callq 0x10d0
movl 0x11133(%rip), %edx     # 0x13118
movl 0x11131(%rip), %ecx     # 0x1311c
movl 0x1111e(%rip), %r8d     # 0x13110
movl 0x1111b(%rip), %r9d     # 0x13114
leaq 0xb33c(%rip), %rsi      # 0xd33c
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10d0
movl 0x11110(%rip), %edx     # 0x13120
leaq 0xb34d(%rip), %rsi      # 0xd364
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10d0
movl 0x110fd(%rip), %edx     # 0x13124
testb $0x1, %dl
movl $0x20, %eax
movl $0x78, %ecx
cmovel %eax, %ecx
testb $0x4, %dl
movl $0x78, %r8d
cmovel %eax, %r8d
testb $0x10, %dl
movl $0x78, %r9d
cmovel %eax, %r9d
testb $0x40, %dl
movl $0x78, %r10d
cmovel %eax, %r10d
testb %dl, %dl
movl $0x78, %r11d
cmovnsl %eax, %r11d
btl $0x9, %edx
movl $0x78, %r14d
cmovael %eax, %r14d
btl $0xa, %edx
movl $0x78, %r15d
cmovael %eax, %r15d
movl $0x78, %r12d
btl $0xb, %edx
cmovael %eax, %r12d
subq $0x8, %rsp
leaq 0xb2d2(%rip), %rsi      # 0xd371
movq %rbx, %rdi
xorl %eax, %eax
pushq %r12
pushq %r15
pushq %r14
pushq %r11
pushq %r10
callq 0x10d0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/mikecat[P]x86_interpreter/x86_interpreter.c
// Function: memory_access
int memory_access(uint8_t* data_read, uint32_t addr, uint8_t data, int we) {
	if (dmemory_is_allocated(addr, 1)) {
		if (we) dmemory_write(&data, addr, 1);
		dmemory_read(data_read, addr, 1);
		return 1;
	} else {
		return 0;
	}
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %ecx, %ebp
movl %esi, %ebx
movq %rdi, %r14
movb %dl, 0xf(%rsp)
movl %esi, %edi
movl $0x1, %esi
callq 0x7134
testl %eax, %eax
je 0x210d
testl %ebp, %ebp
je 0x20f7
leaq 0xf(%rsp), %rdi
movl %ebx, %esi
movl $0x1, %edx
callq 0x6d8a
movl $0x1, %ebp
movq %r14, %rdi
movl %ebx, %esi
movl $0x1, %edx
callq 0x6c34
jmp 0x210f
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/mikecat[P]x86_interpreter/x86_interpreter.c
// Function: step_memread
static uint32_t step_memread(int* success, uint32_t inst_addr, int segment, uint32_t addr, int size) {
	uint32_t res = 0;
	int i;
	if (UINT32_MAX - segment_offsets[segment] < addr ||
	(size <= 0 || UINT32_MAX - (segment_offsets[segment] + addr) < (uint32_t)(size - 1))) {
		*success = 0;
		return 0;
	}
	for (i = 0; i < size; i++) {
		uint32_t this_addr = segment_offsets[segment] + addr + i;
		uint8_t value;
		if (!memory_access(&value, this_addr, 0, 0)) {
			fprintf(stderr, "failed to read memory %08"PRIx32" at %08"PRIx32"\n\n", this_addr, inst_addr);
			print_regs(stderr);
			*success = 0;
			return 0;
		}
		res |= value << (i * 8);
	}
	if (size < 4) {
		if (res & (UINT32_C(0x80) << ((size - 1) * 8))) {
			res |= UINT32_C(0xffffffff) << (size * 8);
		} else {
			res &= UINT32_C(0xffffffff) >> ((4 - size) * 8);
		}
	}
	*success = 1;
	return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %r15d
movslq %edx, %rax
leaq 0xd041(%rip), %rcx      # 0x13150
movq %rax, 0x20(%rsp)
movl (%rcx,%rax,4), %ecx
addl %r15d, %ecx
setb %dl
testl %r8d, %r8d
setle %r9b
xorl %eax, %eax
orb %dl, %r9b
je 0x6132
xorl %ebp, %ebp
jmp 0x6236
leal -0x1(%r8), %edx
movl $0x0, %ebp
addl %edx, %ecx
jb 0x6236
movl %edx, 0x14(%rsp)
movq %rdi, 0x8(%rsp)
testl %r8d, %r8d
movq %r8, 0x18(%rsp)
jle 0x61ed
movl %esi, 0x10(%rsp)
xorl %r13d, %r13d
movl %r8d, %r14d
xorl %ebp, %ebp
movq 0x20(%rsp), %rax
leaq 0xcfde(%rip), %rcx      # 0x13150
movl (%rcx,%rax,4), %r12d
addl %r15d, %r12d
leaq 0x7(%rsp), %rdi
movl %r12d, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x20bf
movl %eax, %ebx
testl %eax, %eax
je 0x61b2
movzbl 0x7(%rsp), %eax
movl %r13d, %ecx
shll %cl, %eax
orl %eax, %ebp
testl %ebx, %ebx
je 0x6229
addl $0x8, %r13d
incl %r15d
decl %r14d
jne 0x6166
jmp 0x61ef
movq 0xce3f(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
leaq 0x7947(%rip), %rsi      # 0xdb0a
movl %r12d, %edx
movl 0x10(%rsp), %ecx
xorl %eax, %eax
callq 0x10d0
movq 0xce20(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
callq 0x1fac
movq 0x8(%rsp), %rax
movl $0x0, (%rax)
jmp 0x619c
xorl %ebp, %ebp
movl $0x1, %eax
movq 0x18(%rsp), %rsi
cmpl $0x3, %esi
jg 0x6222
movl 0x14(%rsp), %ecx
shll $0x3, %ecx
movl %ebp, %edx
shrl %cl, %edx
shll $0x3, %esi
testb %dl, %dl
movq 0x8(%rsp), %rdi
jns 0x622d
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %esi, %ecx
shll %cl, %edx
orl %edx, %ebp
jmp 0x6236
movq 0x8(%rsp), %rdi
jmp 0x6236
xorl %ebp, %ebp
jmp 0x6238
negb %sil
movl %esi, %ecx
shll %cl, %ebp
shrl %cl, %ebp
movl %eax, (%rdi)
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_O1/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
pushq %rax
movl %ecx, %r14d
movl %edx, %r15d
movslq %esi, %r13
leaq 0xceec(%rip), %rax      # 0x13150
movl (%rax,%r13,4), %eax
addl %edx, %eax
setb %cl
testl %r8d, %r8d
setle %dl
xorl %r12d, %r12d
orb %cl, %dl
jne 0x62d0
movl %r8d, %ebp
movl %r8d, %ecx
negl %ecx
cmpl %ecx, %eax
ja 0x62d0
testl %ebp, %ebp
jle 0x62ca
movl %edi, 0x4(%rsp)
xorl %r12d, %r12d
leaq 0xceb8(%rip), %rax      # 0x13150
movl (%rax,%r13,4), %ebx
addl %r15d, %ebx
movl %r14d, %eax
movl %r12d, %ecx
shrl %cl, %eax
movzbl %al, %edx
leaq 0x3(%rsp), %rdi
movl %ebx, %esi
movl $0x1, %ecx
callq 0x20bf
testl %eax, %eax
je 0x62e2
addl $0x8, %r12d
incl %r15d
decl %ebp
jne 0x6291
movl $0x1, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xcd0f(%rip), %r14      # 0x12ff8
movq (%r14), %rdi
leaq 0x783c(%rip), %rsi      # 0xdb2f
xorl %r12d, %r12d
movl %ebx, %edx
movl 0x4(%rsp), %ecx
xorl %eax, %eax
callq 0x10d0
movq (%r14), %rdi
callq 0x1fac
jmp 0x62d0
// File: /workspace/github_c_makefile_star2_O1/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 0xcdf3(%rip), %eax      # 0x13110
testl %ebx, %ebx
movzwl %ax, %ebp
cmovel %eax, %ebp
subl %edx, %ebp
movl $0x2, %esi
movl %ebp, %edx
callq 0x6249
testl %eax, %eax
je 0x6358
movzwl 0xcdd4(%rip), %eax      # 0x13112
shll $0x10, %eax
movzwl %bp, %ecx
orl %eax, %ecx
testl %ebx, %ebx
cmovel %ebp, %ecx
movl %ecx, 0xcdbf(%rip)      # 0x13110
movl $0x1, %eax
jmp 0x635a
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
movl $0x0, (%r15)
testl %ecx, %ecx
movl 0xcd8c(%rip), %eax      # 0x13110
movzwl %ax, %ecx
cmovel %eax, %ecx
movq %r15, %rdi
movl $0x2, %edx
movl %ebp, %r8d
callq 0x60f4
cmpl $0x0, (%r15)
je 0x63c6
movl 0xcd6a(%rip), %ecx      # 0x13110
addl %ecx, %ebp
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
movzwl %bp, %edx
orl %ecx, %edx
testl %r14d, %r14d
cmovel %ebp, %edx
movl %edx, 0xcd51(%rip)      # 0x13110
movl $0x1, %ecx
jmp 0x63ca
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_O1/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:
movl $0xa, %ecx
cmpb $0x30, (%rsi)
jne 0x6426
leaq 0x1(%rsi), %r8
movzbl 0x1(%rsi), %r9d
movl $0x8, %ecx
cmpl $0x57, %r9d
jle 0x6412
cmpl $0x78, %r9d
je 0x6407
cmpl $0x62, %r9d
je 0x641d
cmpl $0x58, %r9d
jne 0x6429
addq $0x2, %rsi
movl $0x10, %ecx
jmp 0x6426
testl %r9d, %r9d
je 0x647f
cmpl $0x42, %r9d
jne 0x6429
addq $0x2, %rsi
movl $0x2, %ecx
movq %rsi, %r8
xorl %r9d, %r9d
movzbl (%r8), %esi
testl %esi, %esi
je 0x647f
leal -0x30(%rsi), %eax
cmpb $0x9, %al
ja 0x6443
leal -0x30(%rsi), %eax
movzbl %al, %esi
jmp 0x6459
leal -0x61(%rsi), %eax
cmpb $0x19, %al
ja 0x644f
addl $-0x57, %esi
jmp 0x6459
leal -0x41(%rsi), %eax
cmpb $0x19, %al
ja 0x646d
addl $-0x37, %esi
cmpl %ecx, %esi
jae 0x646d
movl %ecx, %eax
mull %r9d
jo 0x646d
imull %ecx, %r9d
addl %r9d, %esi
jae 0x6475
xorl %eax, %eax
testb %al, %al
jne 0x642c
jmp 0x6488
incq %r8
movb $0x1, %al
movl %esi, %r9d
jmp 0x646f
movl %r9d, (%rdi)
movl $0x1, %eax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/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
movq %rdi, %rbx
movl %edx, %eax
negl %eax
movl %esi, %r15d
negl %r15d
cmpl %esi, %eax
cmovael %edx, %r15d
testl %edx, %edx
cmovel %edx, %r15d
movb $0x1, %cl
testl %r15d, %r15d
je 0x6c99
leal -0x1(%r15), %edx
addl %esi, %edx
movl %edx, 0x4(%rsp)
jb 0x6c99
movl %esi, %eax
shrl $0x16, %eax
movl %esi, %edx
shrl $0xc, %edx
movl $0x3ff, %ecx            # imm = 0x3FF
andl %ecx, %edx
movl %edx, 0x8(%rsp)
movl 0x4(%rsp), %edx
movl %edx, %edi
shrl $0x16, %edi
shrl $0xc, %edx
andl %ecx, %edx
movl %edx, 0x4(%rsp)
xorl %ecx, %ecx
jmp 0x6c99
testb %cl, %cl
jne 0x6d7b
cmpl %edi, %eax
jg 0x6d7b
andl $0xfff, %esi            # imm = 0xFFF
movl $0x1000, %ebp           # imm = 0x1000
subl %esi, %ebp
cltq
movslq %edi, %rcx
movq %rcx, 0x10(%rsp)
incl %edi
movl %edi, 0xc(%rsp)
movq %rax, 0x18(%rsp)
movq %rax, %rdx
cmpq 0x18(%rsp), %rdx
movl $0x0, %eax
cmovel 0x8(%rsp), %eax
cmpq 0x10(%rsp), %rdx
movl $0x3ff, %edi            # imm = 0x3FF
cmovel 0x4(%rsp), %edi
cmpl %edi, %eax
movq %rdx, 0x20(%rsp)
jg 0x6d69
leaq 0xc474(%rip), %rcx      # 0x13170
movq (%rcx,%rdx,8), %r13
movl %esi, %esi
movslq %eax, %rcx
leaq (,%rcx,8), %rcx
addq %r13, %rcx
movq %rcx, 0x30(%rsp)
subl %eax, %edi
incl %edi
xorl %r12d, %r12d
movq %rdi, 0x28(%rsp)
cmpl %r15d, %ebp
cmovael %r15d, %ebp
movl %ebp, %r14d
testq %r13, %r13
je 0x6d54
movq 0x30(%rsp), %rax
movq (%rax,%r12,8), %rax
testq %rax, %rax
je 0x6d54
addq %rsi, %rax
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x10e0
movq 0x28(%rsp), %rdi
addq %r14, %rbx
subl %ebp, %r15d
incq %r12
movl $0x1000, %ebp           # imm = 0x1000
xorl %esi, %esi
cmpl %r12d, %edi
jne 0x6d21
movq 0x20(%rsp), %rdx
incq %rdx
cmpl %edx, 0xc(%rsp)
jne 0x6cce
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
movq %rdi, %rbx
movl %edx, %eax
negl %eax
movl %esi, %r15d
negl %r15d
cmpl %esi, %eax
cmovael %edx, %r15d
testl %edx, %edx
cmovel %edx, %r15d
movb $0x1, %cl
testl %r15d, %r15d
je 0x6def
leal -0x1(%r15), %edx
addl %esi, %edx
movl %edx, 0x4(%rsp)
jb 0x6def
movl %esi, %eax
shrl $0x16, %eax
movl %esi, %edx
shrl $0xc, %edx
movl $0x3ff, %ecx            # imm = 0x3FF
andl %ecx, %edx
movl %edx, 0x8(%rsp)
movl 0x4(%rsp), %edx
movl %edx, %edi
shrl $0x16, %edi
shrl $0xc, %edx
andl %ecx, %edx
movl %edx, 0x4(%rsp)
xorl %ecx, %ecx
jmp 0x6def
testb %cl, %cl
jne 0x6ecc
cmpl %edi, %eax
jg 0x6ecc
andl $0xfff, %esi            # imm = 0xFFF
movl $0x1000, %ebp           # imm = 0x1000
subl %esi, %ebp
cltq
movslq %edi, %rcx
movq %rcx, 0x10(%rsp)
incl %edi
movl %edi, 0xc(%rsp)
movq %rax, 0x18(%rsp)
movq %rax, %rdx
cmpq 0x18(%rsp), %rdx
movl $0x0, %eax
cmovel 0x8(%rsp), %eax
cmpq 0x10(%rsp), %rdx
movl $0x3ff, %r13d           # imm = 0x3FF
cmovel 0x4(%rsp), %r13d
cmpl %r13d, %eax
movq %rdx, 0x20(%rsp)
jg 0x6eba
leaq 0xc31b(%rip), %rcx      # 0x13170
movq (%rcx,%rdx,8), %rdx
movl %esi, %esi
movslq %eax, %rcx
leaq (%rdx,%rcx,8), %rcx
movq %rcx, 0x30(%rsp)
subl %eax, %r13d
incl %r13d
xorl %r12d, %r12d
movq %rdx, 0x28(%rsp)
cmpl %r15d, %ebp
cmovael %r15d, %ebp
movl %ebp, %r14d
testq %rdx, %rdx
je 0x6ea5
movq 0x30(%rsp), %rax
movq (%rax,%r12,8), %rdi
testq %rdi, %rdi
je 0x6ea5
addq %rsi, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x10e0
movq 0x28(%rsp), %rdx
addq %r14, %rbx
subl %ebp, %r15d
incq %r12
movl $0x1000, %ebp           # imm = 0x1000
xorl %esi, %esi
cmpl %r12d, %r13d
jne 0x6e75
movq 0x20(%rsp), %rdx
incq %rdx
cmpl %edx, 0xc(%rsp)
jne 0x6e24
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 $0x18, %rsp
movb $0x1, %cl
testl %esi, %esi
je 0x6f1a
movl %esi, %ebx
movl %edi, %r13d
decl %ebx
addl %edi, %ebx
jb 0x6f1a
movl %r13d, %eax
shrl $0x16, %eax
shrl $0xc, %r13d
movl $0x3ff, %ecx            # imm = 0x3FF
andl %ecx, %r13d
movl %ebx, %esi
shrl $0x16, %esi
shrl $0xc, %ebx
andl %ecx, %ebx
xorl %ecx, %ecx
jmp 0x6f1a
cmpl %esi, %eax
setg %dl
orb %cl, %dl
jne 0x6ff3
movslq %eax, %r15
movslq %esi, %rax
movq %rax, 0x8(%rsp)
incl %esi
movq %r15, 0x10(%rsp)
movl %esi, 0x4(%rsp)
cmpq 0x10(%rsp), %r15
movl $0x0, %ebp
cmovel %r13d, %ebp
cmpq 0x8(%rsp), %r15
movl $0x3ff, %r14d           # imm = 0x3FF
cmovel %ebx, %r14d
leaq 0xc20f(%rip), %rax      # 0x13170
cmpq $0x0, (%rax,%r15,8)
jne 0x6f95
movl $0x2000, %edi           # imm = 0x2000
callq 0x1100
leaq 0xc1f7(%rip), %rcx      # 0x13170
movq %rax, (%rcx,%r15,8)
testq %rax, %rax
je 0x7007
movl $0x2000, %edx           # imm = 0x2000
movq %rax, %rdi
xorl %esi, %esi
callq 0x10a0
movl %r13d, %r12d
cmpl %r14d, %ebp
jg 0x6fe0
movslq %ebp, %r13
shlq $0x3, %r13
leaq 0xc1c5(%rip), %rax      # 0x13170
addq (%rax,%r15,8), %r13
subl %ebp, %r14d
incl %r14d
xorl %ebp, %ebp
cmpq $0x0, (%r13,%rbp,8)
jne 0x6fd8
movl $0x1, %edi
movl $0x1000, %esi           # imm = 0x1000
callq 0x10b0
movq %rax, (%r13,%rbp,8)
testq %rax, %rax
je 0x7002
incq %rbp
cmpl %ebp, %r14d
jne 0x6fb7
incq %r15
movl 0x4(%rsp), %esi
cmpl %r15d, %esi
movl %r12d, %r13d
jne 0x6f3d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1809
callq 0x181e
// File: /workspace/github_c_makefile_star2_O1/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
movb $0x1, %cl
testl %esi, %esi
je 0x704e
movl %esi, %r14d
movl %edi, %ebx
decl %r14d
addl %edi, %r14d
jb 0x704e
movl %ebx, %eax
shrl $0x16, %eax
shrl $0xc, %ebx
movl $0x3ff, %ecx            # imm = 0x3FF
andl %ecx, %ebx
movl %r14d, %r13d
shrl $0x16, %r13d
shrl $0xc, %r14d
andl %ecx, %r14d
xorl %ecx, %ecx
jmp 0x704e
cmpl %r13d, %eax
setg %dl
orb %cl, %dl
jne 0x7125
movslq %eax, %r12
movslq %r13d, %rax
movq %rax, 0x18(%rsp)
incl %r13d
movq %r12, 0x20(%rsp)
movl %ebx, 0xc(%rsp)
movl %r14d, 0x8(%rsp)
movl %r13d, 0x4(%rsp)
cmpq 0x20(%rsp), %r12
movl $0x0, %r15d
cmovel %ebx, %r15d
cmpq 0x18(%rsp), %r12
movl $0x3ff, %ebp            # imm = 0x3FF
cmovel %r14d, %ebp
leaq 0xc0cf(%rip), %rax      # 0x13170
movq (%rax,%r12,8), %rax
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x7119
cmpl %ebp, %r15d
jg 0x70e5
movslq %r15d, %rax
movq 0x10(%rsp), %rcx
leaq (%rcx,%rax,8), %r13
movl %ebp, %ebx
subl %r15d, %ebx
incl %ebx
xorl %r14d, %r14d
movq (%r13,%r14,8), %rdi
callq 0x1030
movq $0x0, (%r13,%r14,8)
incq %r14
cmpl %r14d, %ebx
jne 0x70ca
testl %r15d, %r15d
movl 0xc(%rsp), %ebx
movl 0x8(%rsp), %r14d
movl 0x4(%rsp), %r13d
jne 0x7119
cmpl $0x3ff, %ebp            # imm = 0x3FF
jne 0x7119
movq 0x10(%rsp), %rdi
callq 0x1030
leaq 0xc05f(%rip), %rax      # 0x13170
movq $0x0, (%rax,%r12,8)
incq %r12
cmpl %r12d, %r13d
jne 0x707d
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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:
testl %esi, %esi
je 0x7179
decl %esi
movl %edi, %r9d
notl %r9d
xorl %eax, %eax
cmpl %r9d, %esi
jbe 0x714e
xorl %ecx, %ecx
xorl %r8d, %r8d
jmp 0x716f
movl %edi, %ecx
shrl $0x16, %ecx
leal (%rsi,%rdi), %edx
shrl $0xc, %edi
movl $0x3ff, %r10d           # imm = 0x3FF
andl %r10d, %edi
movl %edx, %r8d
shrl $0x16, %r8d
shrl $0xc, %edx
andl %r10d, %edx
cmpl %r9d, %esi
ja 0x717e
cmpl %r8d, %ecx
jbe 0x717f
movl $0x1, %eax
retq
pushq %r14
pushq %rbx
leaq 0xbfe7(%rip), %rsi      # 0x13170
movq %rcx, %r9
cmpq %rcx, %r9
movl $0x0, %ebx
cmovel %edi, %ebx
cmpq %r8, %r9
movl $0x3ff, %r10d           # imm = 0x3FF
cmovel %edx, %r10d
cmpl %r10d, %ebx
jg 0x71d2
movq (%rsi,%r9,8), %r11
xorl %eax, %eax
testq %r11, %r11
je 0x71e3
movslq %ebx, %r14
leaq (%r11,%r14,8), %r11
subl %ebx, %r10d
incl %r10d
xorl %ebx, %ebx
cmpq $0x0, (%r11,%rbx,8)
je 0x71e3
incq %rbx
cmpl %ebx, %r10d
jne 0x71c3
leaq 0x1(%r9), %rax
cmpq %r8, %r9
movq %rax, %r9
jb 0x718c
movl $0x1, %eax
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O1/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 %r15d, %r15d
cmpl $0x4, %edx
ja 0x7242
movl %edx, %ebx
movl %esi, %r14d
movl %edi, %ebp
movl %edx, %esi
callq 0x7134
testl %eax, %eax
je 0x7242
testl %ebx, %ebx
je 0x722e
movl %ebx, %eax
shlq $0x3, %rax
leaq 0x4(%rsp), %rdx
xorl %ecx, %ecx
movl %r14d, %esi
shrl %cl, %esi
movb %sil, (%rdx)
addq $0x8, %rcx
incq %rdx
cmpq %rcx, %rax
jne 0x721a
leaq 0x4(%rsp), %rdi
movl %ebp, %esi
movl %ebx, %edx
callq 0x6d8a
movl $0x1, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x7270
movl $0x0, (%rbx)
xorl %ebp, %ebp
cmpl $0x4, %r15d
ja 0x72cd
movl %r12d, %edi
movl %r15d, %esi
callq 0x7134
testl %eax, %eax
je 0x72cd
leaq 0xc(%rsp), %r14
movq %r14, %rdi
movl %r12d, %esi
movl %r15d, %edx
callq 0x6c34
testl %r15d, %r15d
je 0x72c0
movl %r15d, %eax
shlq $0x3, %rax
xorl %ecx, %ecx
xorl %ebp, %ebp
movzbl (%r14), %edx
shll %cl, %edx
orl %edx, %ebp
addq $0x8, %rcx
incq %r14
cmpq %rcx, %rax
jne 0x72aa
jmp 0x72c2
xorl %ebp, %ebp
testq %rbx, %rbx
je 0x72cd
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_O1/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 %r12
pushq %rbx
subq $0x10, %rsp
movl %edi, %r14d
xorl %ebx, %ebx
leaq 0xf(%rsp), %r12
xorl %r15d, %r15d
leal (%r14,%r15), %ebp
movl %ebp, %edi
movl $0x1, %esi
callq 0x7134
testl %eax, %eax
je 0x734a
movq %r12, %rdi
movl %ebp, %esi
movl $0x1, %edx
callq 0x6c34
cmpl $-0x1, %r15d
je 0x734a
incl %r15d
cmpb $0x0, 0xf(%rsp)
jne 0x72f5
movl %r15d, %edi
callq 0x1100
testq %rax, %rax
je 0x7348
movq %rax, %rbx
movq %rax, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x6c34
jmp 0x734a
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
leaq 0x30(%rsp), %rsi
movq %rdx, 0x10(%rsi)
movq %rcx, 0x18(%rsi)
movq %r8, 0x20(%rsi)
movq %r9, 0x28(%rsi)
testb %al, %al
je 0x73c0
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)
movl $0x1, 0xc(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, 0x10(%rsp)
leaq 0x120(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %rsi, 0x20(%rsp)
movl $0x1, %r12d
testl %r12d, %r12d
sete %al
testl %ebx, %ebx
setle %cl
orb %al, %cl
jne 0x7479
movl %edi, %r14d
leaq 0xc(%rsp), %r15
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x7421
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x742f
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
cmpl $-0x4, %r14d
jae 0x7451
movq (%rax), %r13
leal 0x4(%r14), %ebp
movq %r15, %rdi
movl %ebp, %esi
movl $0x4, %edx
callq 0x7250
movl %eax, (%r13)
jmp 0x745c
movl $0x0, 0xc(%rsp)
movl %r14d, %ebp
cmpl $-0x4, %r14d
jae 0x7479
cmpl $0x0, 0xc(%rsp)
je 0x7479
leal 0x1(%r12), %eax
movl %ebp, %r14d
cmpl %ebx, %r12d
movl %eax, %r12d
jl 0x7406
movl 0xc(%rsp), %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rax
movl %edi, 0xdcd9(%rip)      # 0x15170
leaq 0xdce2(%rip), %rdi      # 0x15180
movl $0xc00, %edx            # imm = 0xC00
xorl %esi, %esi
callq 0x10a0
movq 0xbb27(%rip), %rax      # 0x12fd8
movq (%rax), %rax
movq %rax, 0xdcc5(%rip)      # 0x15180
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0xdcbc(%rip)      # 0x15188
movq 0xbafd(%rip), %rax      # 0x12fd0
movq (%rax), %rax
movq %rax, 0xdcbb(%rip)      # 0x15198
movl $0x1, %eax
movl %eax, 0xdcb8(%rip)      # 0x151a0
movl %eax, 0xdcba(%rip)      # 0x151a8
movq 0xbb03(%rip), %rcx      # 0x12ff8
movq (%rcx), %rcx
movq %rcx, 0xdcb1(%rip)      # 0x151b0
movl %eax, 0xdcb3(%rip)      # 0x151b8
movl %eax, 0xdcb5(%rip)      # 0x151c0
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %rbx
movl %edx, %r9d
leaq -0x8(%rsp), %r11
movl %esi, %edx
orl %r9d, %edx
je 0x91ba
movl %esi, %r10d
xorl %ebx, %ebx
xorl %esi, %esi
movl %r10d, %eax
xorl %edx, %edx
divl %ecx
movl %r9d, %ebp
movb (%r8,%rdx), %dl
movb %dl, -0x1(%r11)
decq %r11
subl $0x1, %r9d
cmovbl %ebx, %r9d
incl %esi
cmpl %ecx, %r10d
movl %eax, %r10d
jae 0x918c
cmpl $0x1, %ebp
ja 0x918c
jmp 0x91bc
xorl %esi, %esi
testl %esi, %esi
je 0x91d3
movl %esi, %eax
xorl %ecx, %ecx
movb (%r11,%rcx), %dl
movb %dl, (%rdi,%rcx)
incq %rcx
cmpq %rcx, %rax
jne 0x91c4
movl %esi, %eax
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x91ee
addl $-0x41, %ecx
xorl %eax, %eax
cmpl %edi, %ecx
jb 0x920e
andl $-0x40, %edi
addl $0x40, %edi
testl %edi, %edi
movl $0x40, %eax
cmovnel %edi, %eax
movl %eax, 0xcb82(%rip)      # 0x15d80
movq $0x0, 0xcb7f(%rip) # 0x15d88
movl $0x1, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/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
movq %rdi, %rbx
xorl %ebp, %ebp
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movl %esi, %edi
movl $0x2, %esi
xorl %eax, %eax
callq 0x735a
testl %eax, %eax
je 0x92d2
movl 0xc(%rsp), %r14d
testl %r14d, %r14d
je 0x925b
movl %r14d, %eax
mull 0x8(%rsp)
jno 0x925b
movl $0x0, (%rbx)
jmp 0x92cd
imull 0x8(%rsp), %r14d
movq %r14, %rdi
callq 0x1100
movq %rax, %r15
movl %r14d, %edi
callq 0x92e1
movl %eax, (%rbx)
testq %r15, %r15
je 0x92a1
movl %eax, %ebp
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x10a0
movq %r15, %rdi
movl %ebp, %esi
movl %r14d, %edx
callq 0x6d8a
movq %r15, %rdi
callq 0x1030
jmp 0x92cd
movb $0x0, 0x7(%rsp)
testq %r14, %r14
je 0x92cd
xorl %r12d, %r12d
leaq 0x7(%rsp), %r15
movl (%rbx), %esi
addl %r12d, %esi
movq %r15, %rdi
movl $0x1, %edx
callq 0x6d8a
incq %r12
cmpq %r12, %r14
jne 0x92b3
movl $0x1, %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq