LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/VeeeectorPan[P]MyNetdisk/clientSrc/put.c
// Function: put
int put(int sock_fd,char* path,int user_id,int file_id)
{
    
    char file_name[128] = {0};
    get_file_name(file_name,path);
    int ctl_num = CTL_PUT;
    send(sock_fd,&ctl_num,sizeof(int),0);
    int len = strlen(file_name);
    send(sock_fd,&user_id,sizeof(int),0);
    send(sock_fd,&file_id,sizeof(int),0);
    send(sock_fd,&len,sizeof(int),0);
    send(sock_fd,file_name,len,0);
    recv(sock_fd,&ctl_num,sizeof(int),0);
    if(ctl_num == PUT_FAIL)
    {
        puts("在当前目录有同名文件，不可上传");
        close(sock_fd);
        return -1;
    }
    char* buf = (char*)malloc(4096);
    memset(buf,0,4096);
    memcpy(buf,&sock_fd,sizeof(int));
    memcpy(buf + sizeof(int),&file_id,sizeof(int));
    strcpy(buf + sizeof(int) * 2,path);
    pthread_t id;
    pthread_create(&id,NULL,pthread_upload_func,(void*)buf);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %edi, %ebx
leaq -0x44(%rbp), %r15
movl %edx, (%r15)
leaq -0x2c(%rbp), %rax
movl %ecx, (%rax)
xorps %xmm0, %xmm0
leaq -0xd0(%rbp), %r12
movaps %xmm0, 0x70(%r12)
movaps %xmm0, 0x60(%r12)
movaps %xmm0, 0x50(%r12)
movaps %xmm0, 0x40(%r12)
movaps %xmm0, 0x30(%r12)
movaps %xmm0, 0x20(%r12)
movaps %xmm0, 0x10(%r12)
movaps %xmm0, (%r12)
movq %r12, %rdi
movq %rsi, -0x38(%rbp)
callq 0x2c10
leaq -0x40(%rbp), %r13
movl $0x4, (%r13)
movl $0x4, %edx
movl %ebx, %edi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x20c0
movq %r12, %rdi
callq 0x2080
leaq -0x3c(%rbp), %r14
movl %eax, (%r14)
movl $0x4, %edx
movl %ebx, %edi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x20c0
movl $0x4, %edx
movl %ebx, %edi
leaq -0x2c(%rbp), %rsi
xorl %ecx, %ecx
callq 0x20c0
movl $0x4, %edx
movl %ebx, %edi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x20c0
movslq (%r14), %rdx
movl %ebx, %edi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x20c0
movl $0x4, %edx
movl %ebx, %edi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x2070
cmpl $0x0, (%r13)
je 0x3de4
movl $0x1, %edi
movl $0x1000, %esi           # imm = 0x1000
callq 0x20f0
movq %rax, %r14
movl %ebx, (%rax)
movl -0x2c(%rbp), %eax
movl %eax, 0x4(%r14)
leaq 0x8(%r14), %rdi
movq -0x38(%rbp), %rsi
callq 0x2160
leaq -0x166(%rip), %rdx      # 0x3c6c
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movq %r14, %rcx
callq 0x22b0
xorl %eax, %eax
jmp 0x3dfc
leaq 0x1390(%rip), %rdi      # 0x517b
callq 0x2250
movl %ebx, %edi
callq 0x22d0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O3/VeeeectorPan[P]MyNetdisk/clientSrc/recv_client_all.c
// Function: recv_client_all
int recv_client_all(int fd,void* buf,int len)
{
    int total = 0;
    int ret;
    while(total < len)
    {
        ret = recv(fd,(char*)buf + total,len - total,MSG_WAITALL);
        if(ret == 0)
        {
            return -1;
        }
        total += ret;
    }
    return 0;
}

// Assembly:
testl %edx, %edx
jle 0x3e55
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebx
movq %rsi, %r14
movl %edi, %r15d
xorl %r12d, %r12d
movslq %r12d, %rax
leaq (%r14,%rax), %rsi
movl %ebx, %ecx
subl %eax, %ecx
movslq %ecx, %rdx
movl %r15d, %edi
movl $0x100, %ecx            # imm = 0x100
callq 0x2070
testl %eax, %eax
je 0x3e58
addl %eax, %r12d
cmpl %ebx, %r12d
jl 0x3e2a
xorl %eax, %eax
jmp 0x3e5d
xorl %eax, %eax
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O3/VeeeectorPan[P]MyNetdisk/clientSrc/recv_file.c
// Function: recv_file
int recv_file(int sock_fd,int file_fd, int file_size)
{
    int total = 0;
    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 %edx, %r12d
movl %esi, -0x2c(%rbp)
movl %edi, -0x30(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x21d0
cmpl $-0x1, %eax
je 0x3fad
testl %r12d, %r12d
jle 0x3f70
movslq %r12d, %rax
imulq $0x68db8bad, %rax, %rcx # imm = 0x68DB8BAD
movq %rcx, %rax
shrq $0x3f, %rax
sarq $0x2c, %rcx
addl %eax, %ecx
movq %rcx, -0x48(%rbp)
cvtsi2sd %r12d, %xmm0
movsd %xmm0, -0x38(%rbp)
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %r15d, %r15d
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 0x3fa4
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 0x3fa4
addl %r13d, %r14d
movl %r14d, %eax
subl %ebx, %eax
cmpl -0x48(%rbp), %eax
jl 0x3f55
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
divsd -0x38(%rbp), %xmm0
mulsd 0x127b(%rip), %xmm0     # 0x51b0
leaq 0x1288(%rip), %rdi      # 0x51c4
movb $0x1, %al
callq 0x2030
movq 0x3076(%rip), %rax      # 0x6fc0
movq (%rax), %rdi
callq 0x2190
movl %r14d, %ebx
addl %r13d, %r15d
cmpl %r12d, %r15d
jl 0x3eca
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
movsd -0x38(%rbp), %xmm1
jmp 0x3f79
cvtsi2sd %r12d, %xmm1
xorpd %xmm0, %xmm0
divsd %xmm1, %xmm0
mulsd 0x122b(%rip), %xmm0     # 0x51b0
leaq 0x124a(%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 0x1212(%rip), %rdi      # 0x51bd
jmp 0x3fb4
leaq 0x1204(%rip), %rdi      # 0x51b8
callq 0x2130
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x3f95
// File: /workspace/github_c_makefile_star2_O3/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, %r14d
movl %edx, %r15d
movl %esi, -0x2c(%rbp)
movl %edi, -0x30(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x21d0
cmpl $-0x1, %eax
je 0x40fc
cmpl %r15d, %r14d
jge 0x40c8
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)
cvtsi2sd %r15d, %xmm0
movsd %xmm0, -0x38(%rbp)
xorl %ebx, %ebx
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 0x4105
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 0x4105
addl %r13d, %r12d
movl %r12d, %eax
subl %ebx, %eax
cmpl -0x48(%rbp), %eax
jl 0x40ad
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
divsd -0x38(%rbp), %xmm0
mulsd 0x1123(%rip), %xmm0     # 0x51b0
leaq 0x1130(%rip), %rdi      # 0x51c4
movb $0x1, %al
callq 0x2030
movq 0x2f1e(%rip), %rax      # 0x6fc0
movq (%rax), %rdi
callq 0x2190
movl %r12d, %ebx
addl %r13d, %r14d
cmpl %r15d, %r14d
jl 0x4022
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movsd -0x38(%rbp), %xmm1
jmp 0x40d1
cvtsi2sd %r15d, %xmm1
xorpd %xmm0, %xmm0
divsd %xmm1, %xmm0
mulsd 0x10d3(%rip), %xmm0     # 0x51b0
leaq 0x10f2(%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 0x10b5(%rip), %rdi      # 0x51b8
jmp 0x410c
leaq 0x10b1(%rip), %rdi      # 0x51bd
callq 0x2130
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x40ed
// File: /workspace/github_c_makefile_star2_O3/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 0x42d0(%rip), %rdi      # 0x6560
callq 0x1fed
testb %al, %al
je 0x22a9
movq 0x42c0(%rip), %rdi      # 0x6560
callq 0x2015
testb %al, %al
je 0x22b2
cmpb $0x1, 0x42b8(%rip)      # 0x6568
jne 0x22d1
movq 0x42a7(%rip), %rdi      # 0x6560
callq 0x2196
movq %rax, %rdi
callq 0x1805
movl %eax, %ebx
callq 0x1d59
subl %eax, %ebx
ja 0x22d3
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/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 %r12
pushq %rbx
movq %rdi, %rbx
movq 0x4277(%rip), %rdi      # 0x6560
callq 0x223a
testq %rax, %rax
je 0x23a4
movq %rax, %r14
xorl %r12d, %r12d
leaq 0xf55(%rip), %r15       # 0x3259
movq %r14, %rdi
callq 0x1801
movl %eax, %ebp
movq %rbx, %rdi
callq 0x1801
cmpb %al, %bpl
jae 0x237b
movq 0x423e(%rip), %rdi      # 0x6560
callq 0x2251
cmpq %r14, %rax
jne 0x2418
movq %r14, %rdi
callq 0x1801
movzbl %al, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x1220
movq %r14, %rdi
callq 0x1805
movl %eax, %ebp
movq %rbx, %rdi
callq 0x1805
cmpl %eax, %ebp
sete %al
orb %al, %r12b
movq %r14, %rdi
callq 0x14bb
movq 0x41f2(%rip), %rdi      # 0x6560
callq 0x223a
movq %rax, %r14
testq %rax, %rax
jne 0x2304
movq 0x41de(%rip), %r14      # 0x6560
movq %rbx, %rdi
callq 0x1801
movzbl %al, %esi
movq %r14, %rdi
callq 0x1f08
testb $0x1, %r12b
je 0x23be
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x41b5(%rip), %r14      # 0x6560
movq %rbx, %rdi
callq 0x1801
movzbl %al, %esi
movq %r14, %rdi
callq 0x1f08
movq 0x419b(%rip), %r14      # 0x6560
movq %rbx, %rdi
callq 0x1805
movq %r14, %rdi
movl %eax, %esi
callq 0x20d8
movq %rax, %rbx
testq %rax, %rax
je 0x23fa
movq %rbx, %rdi
callq 0x1801
movzbl %al, %esi
leaq 0xeb5(%rip), %rdi       # 0x32a6
xorl %eax, %eax
callq 0x1220
jmp 0x2408
leaq 0xe78(%rip), %rdi       # 0x3279
xorl %eax, %eax
callq 0x1220
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x14bb
leaq 0xded(%rip), %rdi       # 0x320c
leaq 0xe0d(%rip), %rsi       # 0x3233
leaq 0xe13(%rip), %rcx       # 0x3240
movl $0x39, %edx
callq 0x10e0
// File: /workspace/github_c_makefile_star2_O3/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 0x411b(%rip), %r14      # 0x6560
callq 0x1801
movzbl %al, %esi
movq %r14, %rdi
callq 0x1f32
testb %al, %al
je 0x2491
movq 0x4100(%rip), %r14      # 0x6560
movq %rbx, %rdi
callq 0x1801
movzbl %al, %esi
movq %r14, %rdi
callq 0x201e
testq %rax, %rax
je 0x249a
movq %rax, %rbx
callq 0x1d59
movq %rbx, %rdi
movl %eax, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x18bb
leaq 0xe4b(%rip), %rdi       # 0x32e3
jmp 0x24a1
leaq 0xe5b(%rip), %rdi       # 0x32fc
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1220
// File: /workspace/github_c_makefile_star2_O3/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 0x1d59
movl %eax, %ebx
movq 0x4098(%rip), %rdi      # 0x6560
callq 0x2196
testq %rax, %rax
je 0x257a
movq %rax, %r13
leaq 0xe69(%rip), %r15       # 0x3349
leaq 0xe67(%rip), %r12       # 0x334e
movq %r13, %rdi
callq 0x1805
cmpl %ebx, %eax
ja 0x257a
callq 0x1d59
movl %eax, %ebp
movq 0x405b(%rip), %r14      # 0x6560
movq %r13, %rdi
callq 0x1805
addl $0x44aa20, %ebp         # imm = 0x44AA20
movq %r14, %rdi
movl %eax, %esi
movl %ebp, %edx
callq 0x205c
cmpl $-0x1, %eax
jne 0x2532
leaq 0xdfb(%rip), %rdi       # 0x3326
xorl %eax, %eax
callq 0x195c
movl 0x3be0(%rip), %edi      # 0x6118
movq %r13, %rsi
callq 0x1d05
cmpl $-0x1, %eax
jne 0x254d
movq %r15, %rdi
callq 0x19fe
movq %r13, %rdi
callq 0x1a6a
movq %r12, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x1220
movq 0x3ff7(%rip), %rdi      # 0x6560
callq 0x2196
movq %rax, %r13
testq %rax, %rax
jne 0x24e7
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x3a64(%rip), %rdx      # 0x6578
leaq 0x3a65(%rip), %rcx      # 0x6580
leaq 0x3a66(%rip), %r8       # 0x6588
callq 0x1b2b
movl $0x1, %edi
movl $0x1f, %esi
movl $0xff, %edx
callq 0x1e60
movq %rax, 0x3a1e(%rip)      # 0x6560
testq %rax, %rax
jne 0x2b55
leaq 0xa0e(%rip), %rdi       # 0x355c
xorl %eax, %eax
callq 0x195c
movq 0x3a1c(%rip), %rdi      # 0x6578
leaq 0xc(%rsp), %rsi
callq 0x1bdc
testq %rax, %rax
je 0x2b7c
leaq 0xa03(%rip), %rdi       # 0x3575
movq %rax, %rsi
xorl %eax, %eax
callq 0x195c
movzwl 0x39fd(%rip), %ecx      # 0x6580
leaq 0xc(%rsp), %rdx
xorl %edi, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x1c51
movl %eax, 0x357e(%rip)      # 0x6118
cmpl $-0x1, %eax
jne 0x2bad
leaq 0x9e1(%rip), %rdi       # 0x3587
xorl %eax, %eax
callq 0x195c
movq 0x39d4(%rip), %rdi      # 0x6588
testq %rdi, %rdi
je 0x2bdf
leaq 0x9e0(%rip), %rsi       # 0x35a0
callq 0x1150
movq %rax, 0x39a4(%rip)      # 0x6570
testq %rax, %rax
jne 0x2bf7
leaq 0x9cb(%rip), %rdi       # 0x35a3
callq 0x19fe
jmp 0x2bf7
movq 0x33e2(%rip), %rax      # 0x5fc8
movq (%rax), %rax
movq %rax, 0x3980(%rip)      # 0x6570
jmp 0x2bf7
callq 0x2589
cmpb $0x1, 0x396a(%rip)      # 0x6568
jne 0x2bf2
movq 0x3959(%rip), %rdi      # 0x6560
callq 0x2015
testb %al, %al
je 0x2bf2
leaq 0x992(%rip), %rdi       # 0x35a9
xorl %eax, %eax
callq 0x1220
movq 0x393b(%rip), %rdi      # 0x6560
callq 0x1e9f
movq 0x393f(%rip), %rdi      # 0x6570
callq 0x10b0
xorl %eax, %eax
addq $0x28, %rsp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x11163(%rip), %edx     # 0x13100
movl 0x11169(%rip), %ecx     # 0x1310c
movl 0x1115a(%rip), %r8d     # 0x13104
movl 0x11157(%rip), %r9d     # 0x13108
leaq 0xb3c4(%rip), %rsi      # 0xd37c
xorl %eax, %eax
callq 0x10d0
movl 0x11153(%rip), %edx     # 0x13118
movl 0x11151(%rip), %ecx     # 0x1311c
movl 0x1113e(%rip), %r8d     # 0x13110
movl 0x1113b(%rip), %r9d     # 0x13114
leaq 0xb3c4(%rip), %rsi      # 0xd3a4
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10d0
movl 0x11130(%rip), %edx     # 0x13120
leaq 0xb3d5(%rip), %rsi      # 0xd3cc
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10d0
movl 0x1111d(%rip), %edx     # 0x13124
movd %edx, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
movdqa 0xaff8(%rip), %xmm1     # 0xd010
pand %xmm0, %xmm1
pand 0xaffc(%rip), %xmm0     # 0xd020
pxor %xmm2, %xmm2
pcmpeqd %xmm2, %xmm0
pcmpeqd %xmm2, %xmm1
packssdw %xmm0, %xmm1
packsswb %xmm1, %xmm1
pmovmskb %xmm1, %eax
testb $-0x80, %al
movl $0x20, %esi
movl $0x78, %ecx
cmovnel %esi, %ecx
testb $0x40, %al
movl $0x78, %r8d
cmovnel %esi, %r8d
testb $0x20, %al
movl $0x78, %r9d
cmovnel %esi, %r9d
testb $0x10, %al
movl $0x78, %r10d
cmovnel %esi, %r10d
testb $0x8, %al
movl $0x78, %r11d
cmovnel %esi, %r11d
testb $0x4, %al
movl $0x78, %r14d
cmovnel %esi, %r14d
testb $0x2, %al
movl $0x78, %r15d
cmovnel %esi, %r15d
movl $0x78, %r12d
testb $0x1, %al
cmovnel %esi, %r12d
subq $0x8, %rsp
leaq 0xb32f(%rip), %rsi      # 0xd3d9
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_O3/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 0x6ec9
testl %eax, %eax
je 0x2118
testl %ebp, %ebp
je 0x2102
leaq 0xf(%rsp), %rdi
movl %ebx, %esi
movl $0x1, %edx
callq 0x6b71
movl $0x1, %ebp
movq %r14, %rdi
movl %ebx, %esi
movl $0x1, %edx
callq 0x6a34
jmp 0x211a
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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
movslq %edx, %rbx
leaq 0xd212(%rip), %rax      # 0x13150
movl (%rax,%rbx,4), %eax
movq %rcx, 0x20(%rsp)
addl %ecx, %eax
setb %cl
testl %r8d, %r8d
setle %dl
orb %cl, %dl
jne 0x5f61
movl %r8d, %r12d
leal -0x1(%r12), %ecx
addl %ecx, %eax
jae 0x5f6e
movl $0x0, (%rdi)
xorl %ebp, %ebp
jmp 0x6007
movl %ecx, 0x1c(%rsp)
movl %esi, 0x18(%rsp)
movq %rdi, 0x10(%rsp)
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %ebp, %ebp
movq 0x20(%rsp), %rax
leal (%rax,%r14), %r13d
leaq 0xd1bd(%rip), %rax      # 0x13150
addl (%rax,%rbx,4), %r13d
leaq 0xf(%rsp), %rdi
movl %r13d, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x20ca
testl %eax, %eax
je 0x6018
movzbl 0xf(%rsp), %eax
movl %r15d, %ecx
shll %cl, %eax
orl %eax, %ebp
incl %r14d
addl $0x8, %r15d
cmpl %r14d, %r12d
jne 0x5f83
cmpl $0x3, %r12d
jg 0x5ff0
movl 0x1c(%rsp), %ecx
shll $0x3, %ecx
movl %ebp, %eax
shrl %cl, %eax
shll $0x3, %r12d
testb %al, %al
movq 0x10(%rsp), %rdx
jns 0x5ff7
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %r12d, %ecx
shll %cl, %eax
orl %eax, %ebp
jmp 0x6001
movq 0x10(%rsp), %rdx
jmp 0x6001
negb %r12b
movl %r12d, %ecx
shll %cl, %ebp
shrl %cl, %ebp
movl $0x1, (%rdx)
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xcfd9(%rip), %rbx      # 0x12ff8
movq (%rbx), %rdi
leaq 0x7b49(%rip), %rsi      # 0xdb72
xorl %ebp, %ebp
movl %r13d, %edx
movl 0x18(%rsp), %ecx
xorl %eax, %eax
callq 0x10d0
movq (%rbx), %rdi
callq 0x1f8c
movq 0x10(%rsp), %rax
movl $0x0, (%rax)
jmp 0x6007
// File: /workspace/github_c_makefile_star2_O3/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 0xd0e7(%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 0x60d1
movl %r8d, %ebp
movl %r8d, %ecx
negl %ecx
cmpl %ecx, %eax
ja 0x60d1
movl %edi, 0x4(%rsp)
xorl %r12d, %r12d
leaq 0xd0b7(%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 0x20ca
testl %eax, %eax
je 0x60e3
addl $0x8, %r12d
incl %r15d
decl %ebp
jne 0x6092
movl $0x1, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xcf0e(%rip), %r14      # 0x12ff8
movq (%r14), %rdi
leaq 0x7aa3(%rip), %rsi      # 0xdb97
xorl %r12d, %r12d
movl %ebx, %edx
movl 0x4(%rsp), %ecx
xorl %eax, %eax
callq 0x10d0
movq (%r14), %rdi
callq 0x1f8c
jmp 0x60d1
// File: /workspace/github_c_makefile_star2_O3/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 0xcff2(%rip), %eax      # 0x13110
testl %ebx, %ebx
movzwl %ax, %ebp
cmovel %eax, %ebp
subl %edx, %ebp
movl $0x2, %esi
movl %ebp, %edx
callq 0x604e
testl %eax, %eax
je 0x6159
movzwl 0xcfd3(%rip), %eax      # 0x13112
shll $0x10, %eax
movzwl %bp, %ecx
orl %eax, %ecx
testl %ebx, %ebx
cmovel %ebp, %ecx
movl %ecx, 0xcfbe(%rip)      # 0x13110
movl $0x1, %eax
jmp 0x615b
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0xcf8b(%rip), %eax      # 0x13110
movzwl %ax, %ecx
cmovel %eax, %ecx
movq %r15, %rdi
movl $0x2, %edx
movl %ebp, %r8d
callq 0x5f26
cmpl $0x0, (%r15)
je 0x61c7
movl 0xcf69(%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, 0xcf50(%rip)      # 0x13110
movl $0x1, %ecx
jmp 0x61cb
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_O3/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:
movb (%rsi), %al
movl $0xa, %edx
cmpb $0x30, %al
jne 0x6229
leaq 0x1(%rsi), %r8
movb 0x1(%rsi), %al
movzbl %al, %r9d
movl $0x8, %ecx
cmpl $0x57, %r9d
jle 0x6212
movl $0x10, %edx
cmpl $0x58, %r9d
je 0x6222
cmpl $0x78, %r9d
je 0x6222
cmpl $0x62, %r9d
je 0x621d
jmp 0x6232
testl %r9d, %r9d
je 0x6291
cmpl $0x42, %r9d
jne 0x6232
movl $0x2, %edx
movb 0x2(%rsi), %al
addq $0x2, %rsi
movl %edx, %ecx
movq %rsi, %r8
testb %al, %al
je 0x628e
incq %r8
xorl %r10d, %r10d
xorl %esi, %esi
leal -0x30(%rax), %edx
cmpb $0x9, %dl
ja 0x6248
movzbl %dl, %r9d
jmp 0x626a
leal -0x61(%rax), %edx
cmpb $0x19, %dl
ja 0x625a
movzbl %al, %r9d
addl $-0x57, %r9d
jmp 0x626a
leal -0x41(%rax), %edx
cmpb $0x19, %dl
ja 0x629c
movzbl %al, %r9d
addl $-0x37, %r9d
cmpl %ecx, %r9d
jae 0x6299
movl %ecx, %eax
mull %r10d
jo 0x6299
imull %ecx, %r10d
addl %r10d, %r9d
jb 0x6299
movb (%r8), %al
incq %r8
movl %r9d, %r10d
testb %al, %al
jne 0x623a
jmp 0x6291
xorl %r9d, %r9d
movl %r9d, (%rdi)
movl $0x1, %esi
movl %esi, %eax
retq
xorl %esi, %esi
jmp 0x6299
// File: /workspace/github_c_makefile_star2_O3/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
testl %edx, %edx
sete %al
movl %edx, %ecx
negl %ecx
movl %esi, %r15d
negl %r15d
cmpl %esi, %ecx
cmovael %edx, %r15d
testl %r15d, %r15d
sete %cl
orb %al, %cl
jne 0x6b62
leal -0x1(%r15), %ecx
addl %esi, %ecx
jb 0x6b62
movl %esi, %edx
shrl $0x16, %edx
movl %ecx, %eax
shrl $0x16, %eax
cmpl %eax, %edx
ja 0x6b62
movq %rdi, %rbx
movq %rax, %rdi
movl %esi, %r8d
shrl $0xc, %r8d
movl $0x3ff, %eax            # imm = 0x3FF
andl %eax, %r8d
movl %r8d, 0x8(%rsp)
shrl $0xc, %ecx
andl %eax, %ecx
movl %ecx, 0xc(%rsp)
andl $0xfff, %esi            # imm = 0xFFF
movl $0x1000, %r13d          # imm = 0x1000
subl %esi, %r13d
movl %edx, %eax
movq %rax, 0x18(%rsp)
movl %edi, %eax
movq %rax, 0x10(%rsp)
addl %edx, %edi
subl %edx, %edi
incl %edi
movq %rdi, 0x20(%rsp)
cmpq 0x18(%rsp), %rdx
movl $0x0, %eax
cmovel 0x8(%rsp), %eax
cmpq 0x10(%rsp), %rdx
movl $0x3ff, %edi            # imm = 0x3FF
cmovel 0xc(%rsp), %edi
cmpl %edi, %eax
movq %rdx, 0x28(%rsp)
ja 0x6b4f
leaq 0xc674(%rip), %rcx      # 0x13170
movq (%rcx,%rdx,8), %r12
movl %esi, %esi
movl %eax, %ebp
incl %edi
movq %rdi, 0x30(%rsp)
cmpl %r15d, %r13d
cmovael %r15d, %r13d
movl %r13d, %r14d
testq %r12, %r12
je 0x6b39
movq (%r12,%rbp,8), %rax
testq %rax, %rax
je 0x6b39
addq %rsi, %rax
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x10e0
movq 0x30(%rsp), %rdi
addq %r14, %rbx
subl %r13d, %r15d
incq %rbp
movl $0x1000, %r13d          # imm = 0x1000
xorl %esi, %esi
cmpq %rbp, %rdi
jne 0x6b0b
movq 0x28(%rsp), %rdx
incq %rdx
cmpq 0x20(%rsp), %rdx
jne 0x6ace
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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
testl %edx, %edx
sete %al
movl %edx, %ecx
negl %ecx
movl %esi, %r15d
negl %r15d
cmpl %esi, %ecx
cmovael %edx, %r15d
testl %r15d, %r15d
sete %cl
orb %al, %cl
jne 0x6ca0
leal -0x1(%r15), %ecx
addl %esi, %ecx
jb 0x6ca0
movl %esi, %edx
shrl $0x16, %edx
movl %ecx, %eax
shrl $0x16, %eax
cmpl %eax, %edx
ja 0x6ca0
movq %rdi, %rbx
movq %rax, %rdi
movl %esi, %r8d
shrl $0xc, %r8d
movl $0x3ff, %eax            # imm = 0x3FF
andl %eax, %r8d
movl %r8d, 0x8(%rsp)
shrl $0xc, %ecx
andl %eax, %ecx
movl %ecx, 0xc(%rsp)
andl $0xfff, %esi            # imm = 0xFFF
movl $0x1000, %r13d          # imm = 0x1000
subl %esi, %r13d
movl %edx, %eax
movq %rax, 0x18(%rsp)
movl %edi, %eax
movq %rax, 0x10(%rsp)
addl %edx, %edi
subl %edx, %edi
incl %edi
movq %rdi, 0x20(%rsp)
cmpq 0x18(%rsp), %rdx
movl $0x0, %eax
cmovel 0x8(%rsp), %eax
cmpq 0x10(%rsp), %rdx
movl $0x3ff, %r8d            # imm = 0x3FF
cmovel 0xc(%rsp), %r8d
cmpl %r8d, %eax
movq %rdx, 0x28(%rsp)
ja 0x6c8d
leaq 0xc534(%rip), %rcx      # 0x13170
movq (%rcx,%rdx,8), %r12
movl %esi, %esi
movl %eax, %ebp
incl %r8d
movq %r8, 0x30(%rsp)
cmpl %r15d, %r13d
cmovael %r15d, %r13d
movl %r13d, %r14d
testq %r12, %r12
je 0x6c77
movq (%r12,%rbp,8), %rdi
testq %rdi, %rdi
je 0x6c77
addq %rsi, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x10e0
movq 0x30(%rsp), %r8
addq %r14, %rbx
subl %r13d, %r15d
incq %rbp
movl $0x1000, %r13d          # imm = 0x1000
xorl %esi, %esi
cmpq %rbp, %r8
jne 0x6c4c
movq 0x28(%rsp), %rdx
incq %rdx
cmpq 0x20(%rsp), %rdx
jne 0x6c0b
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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
testl %esi, %esi
je 0x6da1
movl %esi, %ebx
decl %ebx
addl %edi, %ebx
jb 0x6da1
movl %edi, %r15d
shrl $0x16, %r15d
movl %ebx, %r12d
shrl $0x16, %r12d
cmpl %r12d, %r15d
ja 0x6da1
shrl $0xc, %edi
movl $0x3ff, %eax            # imm = 0x3FF
andl %eax, %edi
movl %edi, 0x4(%rsp)
shrl $0xc, %ebx
andl %eax, %ebx
movl %r15d, %eax
movq %rax, 0x10(%rsp)
movl %r12d, %eax
movq %rax, 0x8(%rsp)
addl %r15d, %r12d
subl %r15d, %r12d
incl %r12d
cmpq 0x10(%rsp), %r15
movl $0x0, %ebp
cmovel 0x4(%rsp), %ebp
cmpq 0x8(%rsp), %r15
movl $0x3ff, %r13d           # imm = 0x3FF
cmovel %ebx, %r13d
leaq 0xc437(%rip), %rax      # 0x13170
movq (%rax,%r15,8), %r14
testq %r14, %r14
jne 0x6d64
movl $0x1, %edi
movl $0x2000, %esi           # imm = 0x2000
callq 0x10b0
movq %rax, %r14
leaq 0xc415(%rip), %rax      # 0x13170
movq %r14, (%rax,%r15,8)
testq %r14, %r14
je 0x6db5
cmpl %r13d, %ebp
ja 0x6d95
movl %ebp, %ebp
incl %r13d
cmpq $0x0, (%r14,%rbp,8)
jne 0x6d8d
movl $0x1, %edi
movl $0x1000, %esi           # imm = 0x1000
callq 0x10b0
movq %rax, (%r14,%rbp,8)
testq %rax, %rax
je 0x6db0
incq %rbp
cmpq %rbp, %r13
jne 0x6d6e
incq %r15
cmpq %r12, %r15
jne 0x6d14
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_O3/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:
testl %esi, %esi
je 0x6ec8
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebx
movl %edi, %r12d
decl %ebx
addl %edi, %ebx
jb 0x6eba
movl %r12d, %r15d
shrl $0x16, %r15d
movl %ebx, %eax
shrl $0x16, %eax
cmpl %eax, %r15d
ja 0x6eba
movq %rax, %rcx
shrl $0xc, %r12d
movl $0x3ff, %eax            # imm = 0x3FF
andl %eax, %r12d
shrl $0xc, %ebx
andl %eax, %ebx
movl %r15d, %eax
movq %rax, 0x18(%rsp)
movl %ecx, %eax
movq %rax, 0x10(%rsp)
addl %r15d, %ecx
subl %r15d, %ecx
incl %ecx
movq %rcx, 0x20(%rsp)
movl %ebx, 0xc(%rsp)
movl %r12d, 0x8(%rsp)
cmpq 0x18(%rsp), %r15
movl $0x0, %ebp
cmovel %r12d, %ebp
cmpq 0x10(%rsp), %r15
movl $0x3ff, %r13d           # imm = 0x3FF
cmovel %ebx, %r13d
leaq 0xc31f(%rip), %rax      # 0x13170
movq (%rax,%r15,8), %r14
testq %r14, %r14
je 0x6eac
cmpl %r13d, %ebp
ja 0x6eac
movl %ebp, %r12d
leal 0x1(%r13), %ebx
movq (%r14,%r12,8), %rdi
callq 0x1030
movq $0x0, (%r14,%r12,8)
incq %r12
cmpq %r12, %rbx
jne 0x6e66
testl %ebp, %ebp
movl 0xc(%rsp), %ebx
movl 0x8(%rsp), %r12d
jne 0x6eac
cmpl $0x3ff, %r13d           # imm = 0x3FF
jne 0x6eac
movq %r14, %rdi
callq 0x1030
leaq 0xc2cc(%rip), %rax      # 0x13170
movq $0x0, (%rax,%r15,8)
incq %r15
cmpq 0x20(%rsp), %r15
jne 0x6e2d
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x6ee3
decl %esi
xorl %eax, %eax
addl %edi, %esi
jb 0x6ee8
movl %edi, %ecx
shrl $0x16, %ecx
movl %esi, %edx
shrl $0x16, %edx
cmpl %edx, %ecx
jbe 0x6ee9
movl $0x1, %eax
retq
pushq %rbx
shrl $0xc, %edi
movl $0x3ff, %eax            # imm = 0x3FF
andl %eax, %edi
shrl $0xc, %esi
andl %eax, %esi
movl %ecx, %r8d
leaq 0xc26d(%rip), %r9       # 0x13170
cmpq %rcx, %r8
movl $0x0, %ebx
cmovel %edi, %ebx
cmpq %rdx, %r8
movl $0x3ff, %r10d           # imm = 0x3FF
cmovel %esi, %r10d
cmpl %r10d, %ebx
ja 0x6f3f
movq (%r9,%r8,8), %r11
xorl %eax, %eax
testq %r11, %r11
je 0x6f50
movl %ebx, %ebx
incl %r10d
cmpq $0x0, (%r11,%rbx,8)
je 0x6f50
incq %rbx
cmpq %rbx, %r10
jne 0x6f30
leaq 0x1(%r8), %rax
cmpq %rdx, %r8
movq %rax, %r8
jb 0x6f03
movl $0x1, %eax
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O3/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 0x703f
movl %edx, %ebx
movl %esi, %r14d
movl %edi, %ebp
movl %edx, %esi
callq 0x6ec9
testl %eax, %eax
je 0x703f
testl %ebx, %ebx
je 0x702b
movl %ebx, %eax
decq %rax
movq %rax, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq 0x5(%rsp), %rdx
leal 0x8(,%rbx,8), %esi
andl $0x70, %esi
movdqa 0x6cc5(%rip), %xmm1     # 0xdc70
xorl %eax, %eax
movdqa 0x6ccb(%rip), %xmm2     # 0xdc80
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0x6ccb(%rip), %xmm4     # 0xdc90
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %ecx
notl %ecx
testb $0x1, %cl
je 0x7001
movl %r14d, %edi
movl %eax, %ecx
shrl %cl, %edi
movb %dil, -0x1(%rdx)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %ecx
testb $0x1, %cl
je 0x701a
leal 0x8(%rax), %ecx
movl %r14d, %edi
shrl %cl, %edi
movb %dil, (%rdx)
paddq %xmm4, %xmm1
addq $0x2, %rdx
addq $0x10, %rax
cmpq %rax, %rsi
jne 0x6fc5
leaq 0x4(%rsp), %rdi
movl %ebp, %esi
movl %ebx, %edx
callq 0x6b71
movl $0x1, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/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 0x706d
movl $0x0, (%rbx)
xorl %ebp, %ebp
cmpl $0x4, %r15d
ja 0x70ca
movl %r12d, %edi
movl %r15d, %esi
callq 0x6ec9
testl %eax, %eax
je 0x70ca
leaq 0xc(%rsp), %r14
movq %r14, %rdi
movl %r12d, %esi
movl %r15d, %edx
callq 0x6a34
testl %r15d, %r15d
je 0x70bd
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 0x70a7
jmp 0x70bf
xorl %ebp, %ebp
testq %rbx, %rbx
je 0x70ca
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_O3/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 0x6ec9
testl %eax, %eax
je 0x7147
movq %r12, %rdi
movl %ebp, %esi
movl $0x1, %edx
callq 0x6a34
cmpl $-0x1, %r15d
je 0x7147
incl %r15d
cmpb $0x0, 0xf(%rsp)
jne 0x70f2
movl %r15d, %edi
callq 0x1100
testq %rax, %rax
je 0x7145
movq %rax, %rbx
movq %rax, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x6a34
jmp 0x7147
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_O3/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 %r12
pushq %rbx
subq $0xe0, %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 0x71bb
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 0x110(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %rsi, 0x20(%rsp)
testl %ebx, %ebx
jle 0x7259
movl %edi, %ebp
movl $0x1, %r15d
leaq 0xc(%rsp), %r14
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0x7210
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x721e
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
cmpl $-0x4, %ebp
jae 0x7251
movq (%rax), %r12
addl $0x4, %ebp
movq %r14, %rdi
movl %ebp, %esi
movl $0x4, %edx
callq 0x704d
movl %eax, (%r12)
cmpl $0x0, 0xc(%rsp)
je 0x7259
leal 0x1(%r15), %eax
cmpl %ebx, %r15d
movl %eax, %r15d
jl 0x71f5
jmp 0x7259
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
addq $0xe0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)