LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/log.c
// Function: open_logfile
void open_logfile(const char* log_file)
{
	if (log_file && strlen(log_file)) {
		s_current_log_file = log_file;
		log_vprintf = log_vprintf_writefile;
		log_vprintf_with_timestamp = log_vprintf_writefile;
		s_is_use_logfile = 1;
	}
}

// Assembly:
testq %rdi, %rdi
je 0x313b
cmpb $0x0, (%rdi)
je 0x313b
movq %rdi, 0x9109(%rip)      # 0xc228
leaq -0x1df(%rip), %rax      # 0x2f47
movq %rax, 0x90c3(%rip)      # 0xc1f0
movq %rax, 0x90c4(%rip)      # 0xc1f8
movb $0x1, 0x90f5(%rip)      # 0xc230
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/log.c
// Function: close_logfile
void close_logfile()
{
	if (s_is_use_logfile) {
		log_vprintf = log_vprintf_default;
		log_vprintf_with_timestamp = log_vprintf_with_timestamp_default;
		s_is_use_logfile = 0;
	}
}

// Assembly:
cmpb $0x1, 0x90ed(%rip)      # 0xc230
jne 0x3168
leaq -0x3f0(%rip), %rax      # 0x2d5c
movq %rax, 0x909d(%rip)      # 0xc1f0
leaq -0x38d(%rip), %rax      # 0x2dcd
movq %rax, 0x9097(%rip)      # 0xc1f8
movb $0x0, 0x90c8(%rip)      # 0xc230
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/log.c
// Function: open_syslog
void open_syslog(const char *ident)
{
#ifdef WINDOWS
	logw("use_syslog(): not implemented in Windows port");
#else
	if (!s_is_use_syslog) {
		openlog(ident, LOG_CONS | LOG_PID, LOG_DAEMON);
		s_is_use_syslog = 1;
		log_vprintf = log_vprintf_syslog;
		log_vprintf_with_timestamp = log_vprintf_syslog;
	}
#endif
}

// Assembly:
cmpb $0x0, 0x90c4(%rip)      # 0xc234
jne 0x31a2
pushq %rax
movl $0x3, %esi
movl $0x18, %edx
callq 0x21c0
movb $0x1, 0x90ab(%rip)      # 0xc234
leaq -0xb8(%rip), %rax       # 0x30d8
movq %rax, 0x9059(%rip)      # 0xc1f0
movq %rax, 0x905a(%rip)      # 0xc1f8
addq $0x8, %rsp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/log.c
// Function: log_vmprintf
static char *log_vmprintf(const char *fmt, va_list args)
{
	int cnt, sz;
	char *buf;
	va_list ap_try;

	sz = 1024;
	buf = (char*)malloc(sz);
	if (!buf)
		return NULL;
try_print:
	va_copy(ap_try, args);
	cnt = vsnprintf(buf, sz, fmt, ap_try);
	va_end(ap_try);
	if (cnt >= sz) {
		char *newbuf;
		sz *= 2;
		newbuf = (char*)realloc(buf, sz);
		if (!newbuf) {
			free(buf);
			return NULL;
		}
		buf = newbuf;
		goto try_print;
	}
	if (cnt < 0) {
		free(buf);
		return NULL;
	}
	return buf;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r14
movq %rdi, %r15
movl $0x400, %edi            # imm = 0x400
callq 0x22e0
testq %rax, %rax
je 0x325e
movl $0x400, %ebp            # imm = 0x400
movq %rsp, %r12
movq %rax, %rbx
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movaps %xmm0, (%rsp)
movl %ebp, %esi
movq %rbx, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0x2130
cmpl %ebp, %eax
jl 0x3252
addl %ebp, %ebp
movslq %ebp, %rsi
movq %rbx, %rdi
callq 0x2350
testq %rax, %rax
jne 0x3216
jmp 0x3256
testl %eax, %eax
jns 0x3260
movq %rbx, %rdi
callq 0x2290
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: str2addr
int str2addr(
	const char* s, sockaddr_t* addr,
	const char* default_port)
{
	char* copy = strdup(s);
	char* host, * port;
	int ai_family;
	int r;

	if (parse_host_port(copy, &host, &port, &ai_family)) {
		free(copy);
		return -1;
	}

	if (!port || strlen(port) == 0)
		port = (char*)default_port;

	r = host2addr(addr, host, port, ai_family);

	free(copy);

	return r;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r15
movq %rsi, %r14
callq 0x2380
movq %rax, %rbx
leaq 0x10(%rsp), %rsi
leaq 0x8(%rsp), %rdx
leaq 0x4(%rsp), %rcx
movq %rax, %rdi
callq 0x3747
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x390e
movq 0x8(%rsp), %rdx
testq %rdx, %rdx
je 0x38f8
cmpb $0x0, (%rdx)
jne 0x38fb
movq %r15, %rdx
movq 0x10(%rsp), %rsi
movl 0x4(%rsp), %ecx
movq %r14, %rdi
callq 0x37dc
movl %eax, %ebp
movq %rbx, %rdi
callq 0x2290
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: str2addrs
int str2addrs(
	const char* str,
	sockaddr_t* addrs,
	int max_num,
	int element_size,
	const char* default_port)
{
	char* s, * p, *saveptr = NULL;
	int i;
	sockaddr_t* addr;

	s = strdup(str);

	for (i = 0, p = strtok_r(s, ",", &saveptr);
		p && *p && i < max_num;
		p = strtok_r(NULL, ",", &saveptr)) {

		addr = (sockaddr_t*)(((char*)addrs) + (size_t)element_size * i);

		if (str2addr(p, addr, default_port)) {
			free(s);
			loge("resolve \"%s\" failed\n", str);
			return -1;
		}

		i++;
	}

	free(s);

	return i;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r12
movl %ecx, %ebp
movl %edx, %ebx
movq %rsi, %r13
movq %rdi, %r15
leaq 0x10(%rsp), %r14
movq $0x0, (%r14)
callq 0x2380
leaq 0x3870(%rip), %rsi      # 0x71c6
movq %rax, (%rsp)
movq %rax, %rdi
movq %r14, %rdx
callq 0x2370
testq %rax, %rax
je 0x39b7
movq %r15, 0x8(%rsp)
movslq %ebp, %r15
movslq %ebx, %rbp
xorl %r14d, %r14d
leaq 0x10(%rsp), %rbx
cmpb $0x0, (%rax)
je 0x39ba
cmpq %rbp, %r14
jge 0x39ba
movq %rax, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x38b1
testl %eax, %eax
jne 0x39d5
incq %r14
xorl %edi, %edi
leaq 0x3821(%rip), %rsi      # 0x71c6
movq %rbx, %rdx
callq 0x2370
addq %r15, %r13
testq %rax, %rax
jne 0x397d
jmp 0x39ba
xorl %r14d, %r14d
movq (%rsp), %rdi
callq 0x2290
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rsp), %rdi
callq 0x2290
xorl %eax, %eax
callq 0x2e49
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x39c3
leaq 0x3731(%rip), %rsi      # 0x7128
leaq 0x37ca(%rip), %rdx      # 0x71c8
leaq 0x37cd(%rip), %r8       # 0x71d2
movl $0x3, %edi
movl $0x111, %ecx            # imm = 0x111
movq 0x8(%rsp), %r9
xorl %eax, %eax
callq 0x2e82
jmp 0x39c3
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: str2proxies
int str2proxies(
	const char* str,
	proxy_t* proxies,
	int max_num)
{
	char* s, * p, *saveptr = NULL;
	int i;
	proxy_t* proxy;

	s = strdup(str);

	for (i = 0, p = strtok_r(s, ",", &saveptr);
		p && *p && i < max_num;
		p = strtok_r(NULL, ",", &saveptr)) {

		proxy = proxies + i;

		if (str2proxy(p, proxy)) {
			free(s);
			loge("resolve \"%s\" failed\n", str);
			return -1;
		}

		i++;
	}

	free(s);

	return i;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x10(%rsp), %r14
movq $0x0, (%r14)
callq 0x2380
movq %rax, %r15
leaq 0x34f0(%rip), %rsi      # 0x71c6
movq %rax, %rdi
movq %r14, %rdx
callq 0x2370
testq %rax, %rax
je 0x3d34
movq %rbx, 0x8(%rsp)
movslq %ebp, %rbx
xorl %r14d, %r14d
leaq 0x34ce(%rip), %r13      # 0x71c6
leaq 0x10(%rsp), %rbp
cmpb $0x0, (%rax)
je 0x3d37
cmpq %rbx, %r14
jge 0x3d37
movq %rax, %rdi
movq %r12, %rsi
callq 0x3a1d
testl %eax, %eax
jne 0x3d51
incq %r14
xorl %edi, %edi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2370
addq $0xf8, %r12
testq %rax, %rax
jne 0x3cfd
jmp 0x3d37
xorl %r14d, %r14d
movq %r15, %rdi
callq 0x2290
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x2290
xorl %eax, %eax
callq 0x2e49
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x3d3f
leaq 0x33b6(%rip), %rsi      # 0x7128
leaq 0x349a(%rip), %rdx      # 0x7213
leaq 0x3452(%rip), %r8       # 0x71d2
movl $0x3, %edi
movl $0x1a8, %ecx            # imm = 0x1A8
movq 0x8(%rsp), %r9
xorl %eax, %eax
callq 0x2e82
jmp 0x3d3f
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: str2listens
int str2listens(
	const char* str,
	listen_t * listens,
	int max_num,
	int element_size,
	const char* default_port)
{
	int listen_num;

	memset(listens, 0, (size_t)element_size * max_num);

	listen_num = str2addrs(
		str,
		&listens[0].addr,
		max_num,
		element_size,
		default_port);

	if (listen_num == -1) {
		loge("parse \"%s\" failed\n",
			str);
		return -1;
	}

	return listen_num;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r14
movq %rsi, %r15
movq %rdi, %rbx
movslq %ecx, %r12
movslq %edx, %r13
movq %r12, %rdx
imulq %r13, %rdx
movq %rsi, %rdi
xorl %esi, %esi
callq 0x2110
movq %rbx, %rdi
movq %r15, %rsi
movl %r13d, %edx
movl %r12d, %ecx
movq %r14, %r8
callq 0x3923
movl %eax, %ebp
cmpl $-0x1, %eax
jne 0x3e13
xorl %eax, %eax
callq 0x2e49
cmpl $0x3, (%rax)
jl 0x3e13
leaq 0x3337(%rip), %rsi      # 0x7128
leaq 0x3427(%rip), %rdx      # 0x721f
leaq 0x342c(%rip), %r8       # 0x722b
movl $0x3, %edi
movl $0x1c8, %ecx            # imm = 0x1C8
movq %rbx, %r9
xorl %eax, %eax
callq 0x2e82
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: udp_listen
int udp_listen(listen_t* ctx)
{
	sockaddr_t* addr;
	struct sockaddr* sockaddr;
	sock_t sock;

	addr = &ctx->addr;
	sockaddr = (struct sockaddr*)(&addr->addr);

	sock = socket(sockaddr->sa_family, SOCK_DGRAM, IPPROTO_UDP);

	if (sock == -1) {
		loge("create socket error. errno=%d, %s\n", errno, strerror(errno));
		return -1;
	}

	if (setnonblock(sock) != 0) {
		loge("set sock non-block failed\n");
		close(sock);
		return -1;
	}

	if (setreuseaddr(sock) != 0) {
		loge("set sock reuse address failed\n");
		close(sock);
		return -1;
	}

#ifdef WINDOWS
	disable_udp_connreset(sock);
#endif

	if (bind(sock, sockaddr, addr->addrlen) != 0) {
		loge("bind() error: %s errno=%d, %s\n",
			get_sockaddrname(addr), errno, strerror(errno));
		close(sock);
		return -1;
	}

	ctx->usock = sock;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %r14
movzwl (%rdi), %edi
movl $0x2, %esi
movl $0x11, %edx
callq 0x20a0
cmpl $-0x1, %eax
je 0x407c
movl %eax, %ebx
movl %eax, %edi
callq 0x33cf
testl %eax, %eax
je 0x40d7
xorl %eax, %eax
callq 0x2e49
cmpl $0x3, (%rax)
jl 0x4114
leaq 0x30c9(%rip), %rsi      # 0x7128
leaq 0x325d(%rip), %rdx      # 0x72c3
leaq 0x31dc(%rip), %r8       # 0x7249
movl $0x3, %edi
movl $0x20f, %ecx            # imm = 0x20F
jmp 0x410d
xorl %eax, %eax
callq 0x2e49
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x4120
callq 0x2030
movl (%rax), %ebp
movl %ebp, %edi
callq 0x20c0
movq %rax, %r10
subq $0x8, %rsp
leaq 0x307b(%rip), %rsi      # 0x7128
leaq 0x320f(%rip), %rdx      # 0x72c3
leaq 0x3db2(%rip), %r8       # 0x7e6d
movl $0x3, %edi
movl $0x20a, %ecx            # imm = 0x20A
movl %ebp, %r9d
xorl %eax, %eax
pushq %r10
callq 0x2e82
addq $0x10, %rsp
jmp 0x4120
movl %ebx, %edi
callq 0x3477
testl %eax, %eax
je 0x4127
xorl %eax, %eax
callq 0x2e49
cmpl $0x3, (%rax)
jl 0x4114
leaq 0x3033(%rip), %rsi      # 0x7128
leaq 0x31c7(%rip), %rdx      # 0x72c3
leaq 0x3161(%rip), %r8       # 0x7264
movl $0x3, %edi
movl $0x215, %ecx            # imm = 0x215
xorl %eax, %eax
callq 0x2e82
movl %ebx, %edi
callq 0x23b0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
movl 0x80(%r14), %edx
movl %ebx, %edi
movq %r14, %rsi
callq 0x2070
testl %eax, %eax
je 0x419d
xorl %eax, %eax
callq 0x2e49
cmpl $0x3, (%rax)
jl 0x4114
movq %r14, %rdi
callq 0x35d9
callq 0x2030
movl (%rax), %r14d
movl %r14d, %edi
callq 0x20c0
movq %rax, %r10
leaq 0x2fbe(%rip), %rsi      # 0x7128
leaq 0x3152(%rip), %rdx      # 0x72c3
leaq 0x310b(%rip), %r8       # 0x7283
leaq 0x80f1(%rip), %r9       # 0xc270
movl $0x3, %edi
movl $0x220, %ecx            # imm = 0x220
xorl %eax, %eax
pushq %r10
pushq %r14
callq 0x2e82
addq $0x10, %rsp
jmp 0x4114
movl %ebx, 0x8c(%r14)
xorl %ebx, %ebx
jmp 0x4120
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: init_listens
int init_listens(listen_t* listens, int listen_num)
{
	int i, num = listen_num, n = 0;
	listen_t* listen;

	for (i = 0; i < num; i++) {
		listen = listens + i;
		if (tcp_listen(listen) == 0) {
			n++;
		}
		if (udp_listen(listen) == 0) {
			n++;
		}
	}

	if (n == 0)
		return -1;

	return 0;
}

// Assembly:
testl %esi, %esi
jle 0x41fb
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl %esi, %r14d
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x3e24
xorl %r15d, %r15d
testl %eax, %eax
sete %r15b
movq %rbx, %rdi
callq 0x4019
cmpl $0x1, %eax
adcl %r15d, %ebp
addq $0x90, %rbx
decq %r14
jne 0x41be
xorl %eax, %eax
cmpl $0x1, %ebp
sbbl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: print_listens
void print_listens(const listen_t* listens, int listen_num)
{
	int i;
	for (i = 0; i < listen_num; i++) {
		logn("listen on %s [tcp sock=%d, udp sock=%d]\n",
			get_sockaddrname(&listens[i].addr),
			(int)listens[i].sock,
			(int)listens[i].usock);
	}
}

// Assembly:
testl %esi, %esi
jle 0x4296
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl %esi, %ebp
leaq 0x2f08(%rip), %r14      # 0x7128
leaq 0x30a7(%rip), %r15      # 0x72ce
leaq 0x30ae(%rip), %r12      # 0x72dc
leaq 0x803b(%rip), %r13      # 0xc270
xorl %eax, %eax
callq 0x2e49
cmpl $0x5, (%rax)
jl 0x427c
movq %rbx, %rdi
callq 0x35d9
movl 0x88(%rbx), %r10d
movl 0x8c(%rbx), %r11d
movl $0x5, %edi
movq %r14, %rsi
movq %r15, %rdx
movl $0x246, %ecx            # imm = 0x246
movq %r12, %r8
movq %r13, %r9
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x2e82
addq $0x10, %rsp
addq $0x90, %rbx
decq %rbp
jne 0x4235
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: tcp_send
int tcp_send(sock_t sock, stream_t* s)
{
	int rsize = stream_rsize(s);
	int nsend;

	if (rsize == 0)
		return 0;

	nsend = send(sock, s->array + s->pos, rsize, 0);
	if (nsend == -1) {
		int err = errno;
		if (!is_eagain(err)) {
			loge("errno=%d, %s \n",
				err, strerror(err));
			return -1;
		}
		return 0;
	}
	else {
		s->pos += nsend;
		logv("send %d bytes\n", nsend);
		if (stream_quake(s)) {
			loge("stream_quake()\n");
			return -1;
		}
		return nsend;
	}
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movl 0x8(%rsi), %eax
movslq 0xc(%rsi), %rsi
xorl %ebx, %ebx
cmpl %esi, %eax
jne 0x4515
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
subl %esi, %eax
addq (%r14), %rsi
movslq %eax, %rdx
xorl %ecx, %ecx
callq 0x20f0
movq %rax, %rbx
cmpl $-0x1, %ebx
je 0x45b1
addl %ebx, 0xc(%r14)
xorl %eax, %eax
callq 0x2e49
cmpl $0x8, (%rax)
jl 0x4569
leaq 0x2be1(%rip), %rsi      # 0x7128
leaq 0x2e35(%rip), %rdx      # 0x7383
leaq 0x2e37(%rip), %r8       # 0x738c
movl $0x8, %edi
movl $0x292, %ecx            # imm = 0x292
movl %ebx, %r9d
xorl %eax, %eax
callq 0x2e82
movq %r14, %rdi
callq 0x4c65
testl %eax, %eax
je 0x450a
xorl %eax, %eax
callq 0x2e49
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x450a
leaq 0x2b9b(%rip), %rsi      # 0x7128
leaq 0x2def(%rip), %rdx      # 0x7383
leaq 0x2e00(%rip), %r8       # 0x739b
movl $0x3, %edi
movl $0x294, %ecx            # imm = 0x294
xorl %eax, %eax
callq 0x2e82
jmp 0x450a
callq 0x2030
movl (%rax), %ebp
cmpl $0xb, %ebp
je 0x4619
movl $0x0, %ebx
cmpl $0x73, %ebp
je 0x450a
xorl %eax, %eax
callq 0x2e49
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x450a
movl %ebp, %edi
callq 0x20c0
movq %rax, (%rsp)
leaq 0x2b36(%rip), %rsi      # 0x7128
leaq 0x2d8a(%rip), %rdx      # 0x7383
leaq 0x3995(%rip), %r8       # 0x7f95
movl $0x3, %edi
movl $0x28b, %ecx            # imm = 0x28B
movl %ebp, %r9d
xorl %eax, %eax
callq 0x2e82
jmp 0x450a
xorl %ebx, %ebx
jmp 0x450a
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: tcp_recv
int tcp_recv(sock_t sock, char* buf, int buflen)
{
	int nread;

	nread = recv(sock, buf, buflen, 0);
	if (nread == -1) {
		int err = errno;
		if (!is_eagain(err)) {
			loge("errno=%d, %s\n",
				err, strerror(err));
			return -1;
		}
		return 0;
	}
	else if (nread == 0) {
		logd("connection closed by peer\n");
		return -1;
	}
	else {
		logv("recv %d bytes\n", nread);

		return nread;
	}
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movslq %edx, %rdx
xorl %ecx, %ecx
callq 0x20b0
movq %rax, %rbx
testl %ebx, %ebx
je 0x469c
cmpl $-0x1, %ebx
jne 0x46d5
callq 0x2030
movl (%rax), %ebp
xorl %ebx, %ebx
cmpl $0xb, %ebp
je 0x470a
cmpl $0x73, %ebp
je 0x470a
xorl %eax, %eax
callq 0x2e49
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x470a
movl %ebp, %edi
callq 0x20c0
movq %rax, (%rsp)
leaq 0x2aa9(%rip), %rsi      # 0x7128
leaq 0x2d25(%rip), %rdx      # 0x73ab
leaq 0x39a9(%rip), %r8       # 0x8036
movl $0x3, %edi
movl $0x2a4, %ecx            # imm = 0x2A4
movl %ebp, %r9d
jmp 0x4703
xorl %eax, %eax
callq 0x2e49
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x7, (%rax)
jl 0x470a
leaq 0x2a74(%rip), %rsi      # 0x7128
leaq 0x2cf0(%rip), %rdx      # 0x73ab
leaq 0x2cf2(%rip), %r8       # 0x73b4
movl $0x7, %edi
movl $0x2aa, %ecx            # imm = 0x2AA
xorl %eax, %eax
callq 0x2e82
jmp 0x470a
xorl %eax, %eax
callq 0x2e49
cmpl $0x8, (%rax)
jl 0x470a
leaq 0x2a40(%rip), %rsi      # 0x7128
leaq 0x2cbc(%rip), %rdx      # 0x73ab
leaq 0x2cd9(%rip), %r8       # 0x73cf
movl $0x8, %edi
movl $0x2ae, %ecx            # imm = 0x2AE
movl %ebx, %r9d
xorl %eax, %eax
callq 0x2e82
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: udp_send
int udp_send(sock_t sock, stream_t* s,
	const struct sockaddr* to, int tolen)
{
	int nsend;
	int rsize = stream_rsize(s);

	nsend = sendto(sock, s->array + s->pos, rsize, 0, to, tolen);
	if (nsend == -1) {
		loge("to=%s, errno=%d, %s\n",
			get_addrname(to), errno, strerror(errno));
		return -1;
	}
	return nsend;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %r9d
movq %rdx, %r14
movslq 0x8(%rsi), %rdx
movslq 0xc(%rsi), %rax
subq %rax, %rdx
addq (%rsi), %rax
movq %rax, %rsi
xorl %ecx, %ecx
movq %r14, %r8
callq 0x2050
movq %rax, %rbx
cmpl $-0x1, %ebx
jne 0x479c
xorl %eax, %eax
callq 0x2e49
cmpl $0x3, (%rax)
jl 0x479c
movq %r14, %rdi
callq 0x35d9
callq 0x2030
movl (%rax), %r14d
movl %r14d, %edi
callq 0x20c0
movq %rax, %r10
leaq 0x29ba(%rip), %rsi      # 0x7128
leaq 0x2c69(%rip), %rdx      # 0x73de
leaq 0x38b3(%rip), %r8       # 0x802f
leaq 0x7aed(%rip), %r9       # 0xc270
movl $0x3, %edi
movl $0x2bd, %ecx            # imm = 0x2BD
xorl %eax, %eax
pushq %r10
pushq %r14
callq 0x2e82
addq $0x10, %rsp
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: udp_recv
int udp_recv(sock_t sock, char* buf, int buflen,
	struct sockaddr* from, int* fromlen)
{
	int nread;

	nread = recvfrom(sock, buf, buflen, 0, from, fromlen);
	if (nread > 0) {
		return nread;
	}
	else {
		loge("errno=%d, %s\n", errno, strerror(errno));
		return -1;
	}
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %r8, %r9
movq %rcx, %r8
movslq %edx, %rdx
xorl %ecx, %ecx
callq 0x2180
movq %rax, %rbx
testl %ebx, %ebx
jg 0x480c
xorl %eax, %eax
callq 0x2e49
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x480c
callq 0x2030
movl (%rax), %ebp
movl %ebp, %edi
callq 0x20c0
movq %rax, (%rsp)
leaq 0x293e(%rip), %rsi      # 0x7128
leaq 0x2bf6(%rip), %rdx      # 0x73e7
leaq 0x383e(%rip), %r8       # 0x8036
movl $0x3, %edi
movl $0x2cd, %ecx            # imm = 0x2CD
movl %ebp, %r9d
xorl %eax, %eax
callq 0x2e82
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: conn_new
conn_t* conn_new(sock_t sock)
{
	conn_t* conn = (conn_t*)malloc(sizeof(conn_t));
	if (!conn) {
		loge("alloc\n");
		return NULL;
	}

	if (conn_init(conn, sock)) {
		free(conn);
		loge("conn_init() error\n");
		return NULL;
	}

	return conn;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %edi, %ebp
movl $0x68, %edi
callq 0x22e0
testq %rax, %rax
je 0x4873
movq %rax, %rbx
movq %rax, %rdi
movl %ebp, %esi
callq 0x48b3
testl %eax, %eax
je 0x48a9
movq %rbx, %rdi
callq 0x2290
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2e49
cmpl $0x3, (%rax)
jl 0x48a9
leaq 0x28d1(%rip), %rsi      # 0x7128
leaq 0x2b92(%rip), %rdx      # 0x73f0
leaq 0x2b9b(%rip), %r8       # 0x7400
xorl %ebx, %ebx
movl $0x3, %edi
movl $0x2dc, %ecx            # imm = 0x2DC
jmp 0x48a2
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2e49
cmpl $0x3, (%rax)
jl 0x48a9
leaq 0x28a0(%rip), %rsi      # 0x7128
leaq 0x2b61(%rip), %rdx      # 0x73f0
leaq 0x2b63(%rip), %r8       # 0x73f9
xorl %ebx, %ebx
movl $0x3, %edi
movl $0x2d6, %ecx            # imm = 0x2D6
xorl %eax, %eax
callq 0x2e82
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: conn_init
int conn_init(conn_t* conn, sock_t sock)
{
	memset(conn, 0, sizeof(conn_t));

	if (stream_init(&conn->rs)) {
		loge("stream_init() error\n");
		return -1;
	}

	if (stream_init(&conn->ws)) {
		stream_free(&conn->rs);
		loge("stream_init() error\n");
		return -1;
	}

	conn->sock = sock;

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
movq $0x0, 0x60(%rdi)
leaq 0x8(%rdi), %r15
movq %r15, %rdi
callq 0x4b50
testl %eax, %eax
je 0x4921
xorl %eax, %eax
callq 0x2e49
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x4974
leaq 0x2821(%rip), %rsi      # 0x7128
leaq 0x2b05(%rip), %rdx      # 0x7413
leaq 0x2b08(%rip), %r8       # 0x741d
movl $0x3, %edi
movl $0x2e8, %ecx            # imm = 0x2E8
jmp 0x4966
leaq 0x20(%r14), %rdi
callq 0x4b50
testl %eax, %eax
je 0x496f
movq %r15, %rdi
callq 0x4b61
xorl %eax, %eax
callq 0x2e49
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x4974
leaq 0x27da(%rip), %rsi      # 0x7128
leaq 0x2abe(%rip), %rdx      # 0x7413
leaq 0x2ac1(%rip), %r8       # 0x741d
movl $0x3, %edi
movl $0x2ee, %ecx            # imm = 0x2EE
xorl %eax, %eax
callq 0x2e82
jmp 0x4974
movl %ebx, (%r14)
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: conn_free
void conn_free(conn_t* conn)
{
	if (conn == NULL)
		return;
	if (conn->sock) {
		close(conn->sock);
		conn->sock = 0;
	}
	stream_free(&conn->rs);
	stream_free(&conn->ws);
}

// Assembly:
testq %rdi, %rdi
je 0x49ac
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %edi
testl %edi, %edi
je 0x4996
callq 0x23b0
movl $0x0, (%rbx)
leaq 0x8(%rbx), %rdi
callq 0x4b61
addq $0x20, %rbx
movq %rbx, %rdi
popq %rbx
jmp 0x4b61
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: peer_new
peer_t* peer_new(sock_t sock, int listen)
{
	peer_t* peer = (peer_t*)malloc(sizeof(peer_t));
	if (!peer) {
		loge("alloc\n");
		return NULL;
	}

	if (peer_init(peer, sock, listen)) {
		free(peer);
		loge("peer_init() error\n");
		return NULL;
	}

	return peer;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movl %edi, %r14d
movl $0x80, %edi
callq 0x22e0
testq %rax, %rax
je 0x4a24
movq %rax, %rbx
movq %rax, %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x4a62
testl %eax, %eax
je 0x4a5a
movq %rbx, %rdi
callq 0x2290
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2e49
cmpl $0x3, (%rax)
jl 0x4a5a
leaq 0x2720(%rip), %rsi      # 0x7128
leaq 0x2a23(%rip), %rdx      # 0x7432
leaq 0x2a25(%rip), %r8       # 0x743b
xorl %ebx, %ebx
movl $0x3, %edi
movl $0x313, %ecx            # imm = 0x313
jmp 0x4a53
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2e49
cmpl $0x3, (%rax)
jl 0x4a5a
leaq 0x26ef(%rip), %rsi      # 0x7128
leaq 0x29f2(%rip), %rdx      # 0x7432
leaq 0x29b2(%rip), %r8       # 0x73f9
xorl %ebx, %ebx
movl $0x3, %edi
movl $0x30d, %ecx            # imm = 0x30D
xorl %eax, %eax
callq 0x2e82
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/netutils.c
// Function: peer_init
int peer_init(peer_t* peer, sock_t sock, int listen)
{
	memset(peer, 0, sizeof(peer_t));

	if (conn_init(&peer->conn, sock)) {
		loge("conn_init() error\n");
		return -1;
	}

	dllist_init(&peer->reqs);

	peer->listen = listen;

	return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rdi, %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x70(%rdi)
movups %xmm0, 0x60(%rdi)
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
callq 0x48b3
testl %eax, %eax
je 0x4acf
xorl %eax, %eax
callq 0x2e49
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x4ae1
leaq 0x267a(%rip), %rsi      # 0x7128
leaq 0x2999(%rip), %rdx      # 0x744e
leaq 0x2944(%rip), %r8       # 0x7400
movl $0x3, %edi
movl $0x31f, %ecx            # imm = 0x31F
xorl %eax, %eax
callq 0x2e82
jmp 0x4ae1
leaq 0x70(%r14), %rax
movq %rax, 0x70(%r14)
movq %rax, 0x78(%r14)
movl %ebx, 0x68(%r14)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/stream.c
// Function: stream_seek
int stream_seek(stream_t *stream, int offset, int whence)
{
	switch (whence) {
	case SEEK_CUR:
		offset += stream->pos;
		break;
	case SEEK_END:
		offset = stream->size - offset;
		break;
	case SEEK_SET:
	default:
		break;
	}
	if (offset < 0 || offset > stream->size)
		return -1;
	stream->pos = offset;
	return 0;
}

// Assembly:
cmpl $0x2, %edx
je 0x4b90
cmpl $0x1, %edx
jne 0x4b97
addl 0xc(%rdi), %esi
jmp 0x4b97
movl 0x8(%rdi), %eax
subl %esi, %eax
movl %eax, %esi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %esi, %esi
js 0x4baa
cmpl 0x8(%rdi), %esi
jg 0x4baa
movl %esi, 0xc(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/stream.c
// Function: stream_shrink
int stream_shrink(stream_t *stream)
{
	char *newarray;
	int rsize = stream_rsize(stream);
	if (rsize == 0)
	{
		free(stream->array);
		memset(stream, 0, sizeof(stream_t));
		return 0;
	}
	
	if (rsize == stream->cap)
		return 0;

	if (stream->pos == 0) {
		newarray = realloc(stream->array, rsize);
		if (newarray == NULL)
			return -1;
		stream->array = newarray;
		stream->cap = rsize;
		return 0;
	}

	newarray = (char*)malloc(rsize);
	if (newarray == NULL)
		return -1;
	memcpy(newarray, stream->array + stream->pos, rsize);
	free(stream->array);
	stream->array = newarray;
	stream->cap = rsize;
	stream->size = rsize;
	stream->pos = 0;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movl 0x8(%rdi), %ebp
movslq 0xc(%rdi), %r15
subl %r15d, %ebp
jne 0x4be0
movq (%r14), %rdi
callq 0x2290
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq $0x0, 0x10(%r14)
xorl %ebx, %ebx
jmp 0x4c54
xorl %ebx, %ebx
cmpl 0x10(%r14), %ebp
je 0x4c54
testl %r15d, %r15d
je 0x4c36
movslq %ebp, %r13
movq %r13, %rdi
callq 0x22e0
testq %rax, %rax
je 0x4c4f
movq %rax, %r12
movq (%r14), %rax
movq %rax, (%rsp)
addq %rax, %r15
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x21a0
movq (%rsp), %rdi
callq 0x2290
movq %r12, (%r14)
movl %ebp, 0x10(%r14)
movl %ebp, 0x8(%r14)
movl $0x0, 0xc(%r14)
jmp 0x4c54
movq (%r14), %rdi
movslq %ebp, %rsi
callq 0x2350
testq %rax, %rax
je 0x4c4f
movq %rax, (%r14)
movl %ebp, 0x10(%r14)
jmp 0x4c54
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/stream.c
// Function: stream_quake
int stream_quake(stream_t* stream)
{
	if (stream->pos > 0) {
		int size = stream_rsize(stream);
		if (size > 0) {
			memmove(stream->array, stream->array + stream->pos, size);
			stream->size = size;
			stream->pos = 0;
		}
		else {
			stream->size = 0;
			stream->pos = 0;
		}
	}

	return 0;
}

// Assembly:
movslq 0xc(%rdi), %rsi
testq %rsi, %rsi
jle 0x4c9c
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x8(%rdi), %ebp
subl %esi, %ebp
jle 0x4c8a
movq (%rbx), %rdi
addq %rdi, %rsi
movl %ebp, %edx
callq 0x2340
jmp 0x4c8c
xorl %ebp, %ebp
movl %ebp, 0x8(%rbx)
movl $0x0, 0xc(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/stream.c
// Function: stream_set_cap
int stream_set_cap(stream_t *stream, int cap)
{
	char *newarray;

	if (stream->cap == cap)
		return 0;

	if (stream->cap > cap && stream->cap <= (cap + cap * 4 / 10))
		return 0;

	newarray = realloc(stream->array, cap);
	if (newarray == NULL)
		return -1;
	stream->array = newarray;
	stream->cap = cap;
	if (stream->size > cap)
		stream->size = cap;
	if (stream->pos > cap)
		stream->pos = cap;
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl 0x10(%rdi), %eax
xorl %ebx, %ebx
cmpl %esi, %eax
je 0x4d0d
movl %esi, %r14d
movq %rdi, %r15
jle 0x4cdb
leal (,%r14,4), %ecx
movslq %ecx, %rcx
imulq $0x66666667, %rcx, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rcx
addl %edx, %ecx
addl %r14d, %ecx
cmpl %ecx, %eax
jle 0x4d0d
movq (%r15), %rdi
movslq %r14d, %rsi
callq 0x2350
testq %rax, %rax
je 0x4d08
movq %rax, (%r15)
movl %r14d, 0x10(%r15)
cmpl %r14d, 0x8(%r15)
jle 0x4cfc
movl %r14d, 0x8(%r15)
cmpl %r14d, 0xc(%r15)
jle 0x4d0d
movl %r14d, 0xc(%r15)
jmp 0x4d0d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/stream.c
// Function: stream_write
int stream_write(stream_t *stream, const char *s, int n)
{
	if (stream_rcap(stream) < n) {
		if (stream_set_cap(stream, stream->pos + align(n)))
			return -1;
	}
	memcpy(stream->array + stream->pos, s, n);
	stream->pos += n;
	stream->size += n;
	return n;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r14
movl 0xc(%rdi), %eax
movl 0x10(%rdi), %ecx
subl %eax, %ecx
cmpl %edx, %ecx
jge 0x4d4f
movl %ebx, %ecx
orl $0x3, %ecx
leal (%rcx,%rax), %esi
incl %esi
movq %r14, %rdi
callq 0x4c9f
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x4d7b
movl 0xc(%r14), %eax
movslq %eax, %rdi
addq (%r14), %rdi
movslq %ebx, %rdx
movq %r15, %rsi
callq 0x21a0
movq 0x8(%r14), %xmm0
movd %ebx, %xmm1
pshufd $0x50, %xmm1, %xmm1     # xmm1 = xmm1[0,0,1,1]
paddd %xmm0, %xmm1
movq %xmm1, 0x8(%r14)
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/stream.c
// Function: stream_writes
int stream_writes(stream_t* stream, const char* s, int n)
{
	if (stream_rcap(stream) < (n+1)) {
		if (stream_set_cap(stream, stream->pos + align(n+1)))
			return -1;
	}
	memcpy(stream->array + stream->pos, s, n);
	stream->pos += n;
	stream->size += n;
	stream->array[stream->pos] = '\0';
	return n;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r14
movl 0xc(%rdi), %eax
movl 0x10(%rdi), %ecx
subl %eax, %ecx
cmpl %edx, %ecx
jg 0x4dbf
leal 0x1(%rbx), %ecx
orl $0x3, %ecx
leal (%rcx,%rax), %esi
incl %esi
movq %r14, %rdi
callq 0x4c9f
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x4deb
movl 0xc(%r14), %eax
movslq %eax, %rdi
addq (%r14), %rdi
movslq %ebx, %r12
movq %r15, %rsi
movq %r12, %rdx
callq 0x21a0
movslq 0xc(%r14), %rax
addq %r12, %rax
movl %eax, 0xc(%r14)
addl %ebx, 0x8(%r14)
movq (%r14), %rcx
movb $0x0, (%rcx,%rax)
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/stream.c
// Function: stream_writess
int stream_writess(stream_t *dst, stream_t *src, int n)
{
	if (stream_rsize(src) < n)
		n = src->size - src->pos;

	if (stream_rcap(dst) < n) {
		if (stream_set_cap(dst, dst->pos + align(n)))
			return -1;
	}

	memcpy(dst->array + dst->pos, src->array + src->pos, n);
	dst->pos += n;
	dst->size += n;
	src->pos += n;
	return n;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movl 0x8(%rsi), %ebp
movl 0xc(%rsi), %eax
subl %eax, %ebp
cmpl %edx, %ebp
cmovgel %edx, %ebp
movl 0xc(%rdi), %ecx
movl 0x10(%rdi), %edx
subl %ecx, %edx
cmpl %ebp, %edx
jge 0x4e3e
movl %ebp, %eax
orl $0x3, %eax
leal (%rcx,%rax), %esi
incl %esi
movq %r14, %rdi
callq 0x4c9f
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x4e70
movl 0xc(%r14), %ecx
movl 0xc(%rbx), %eax
movslq %ecx, %rdi
addq (%r14), %rdi
movslq %eax, %rsi
addq (%rbx), %rsi
movslq %ebp, %rdx
callq 0x21a0
movq 0x8(%r14), %xmm0
movd %ebp, %xmm1
pshufd $0x50, %xmm1, %xmm1     # xmm1 = xmm1[0,0,1,1]
paddd %xmm0, %xmm1
movq %xmm1, 0x8(%r14)
addl %ebp, 0xc(%rbx)
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/stream.c
// Function: stream_writei
int stream_writei(stream_t *stream, int v, int nb)
{
	int i;
	if (stream_rcap(stream) < nb) {
		if (stream_set_cap(stream, stream->pos + align(nb)))
			return -1;
	}
	for (i = 0;
		i < nb && stream->size < stream->cap;
		i++, stream->size++) {
		stream->array[stream->pos++] = ((v >> ((nb - i - 1) * 8)) & 0xFF);
	}
	return i;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
movl 0xc(%rdi), %eax
movl 0x10(%rdi), %ecx
subl %eax, %ecx
cmpl %edx, %ecx
jge 0x4ee1
movl %ebx, %ecx
orl $0x3, %ecx
leal (%rcx,%rax), %esi
incl %esi
movq %r14, %rdi
callq 0x4c9f
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x4f27
testl %ebx, %ebx
jle 0x4f25
movl 0x8(%r14), %edx
leal -0x8(,%rbx,8), %ecx
xorl %eax, %eax
cmpl 0x10(%r14), %edx
jge 0x4f27
movl %ebp, %edx
sarl %cl, %edx
movq (%r14), %rsi
movslq 0xc(%r14), %rdi
leal 0x1(%rdi), %r8d
movl %r8d, 0xc(%r14)
movb %dl, (%rsi,%rdi)
incl %eax
movl 0x8(%r14), %edx
incl %edx
movl %edx, 0x8(%r14)
addl $-0x8, %ecx
cmpl %eax, %ebx
jne 0x4ef2
movl %ebx, %eax
jmp 0x4f27
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/stream.c
// Function: stream_writell
int stream_writell(stream_t *stream, long long v, int nb)
{
	int i;
	if (stream_rcap(stream) < nb) {
		if (stream_set_cap(stream, stream->pos + align(nb)))
			return -1;
	}
	for (i = 0;
		i < nb && stream->size < stream->cap;
		i++, stream->size++) {
		stream->array[stream->pos++] = (char)((v >> ((nb - i - 1) * 8)) & 0xFF);
	}
	return i;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edx, %r15d
movq %rsi, %rbx
movq %rdi, %r14
movl 0xc(%rdi), %eax
movl 0x10(%rdi), %ecx
subl %eax, %ecx
cmpl %edx, %ecx
jge 0x4f64
movl %r15d, %ecx
orl $0x3, %ecx
leal (%rcx,%rax), %esi
incl %esi
movq %r14, %rdi
callq 0x4c9f
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x4fb6
testl %r15d, %r15d
jle 0x4fb0
movl %r15d, %eax
movl 0x8(%r14), %esi
leal -0x8(,%r15,8), %ecx
xorl %edx, %edx
cmpl 0x10(%r14), %esi
jge 0x4fb4
movq %rbx, %rsi
sarq %cl, %rsi
movq (%r14), %rdi
movslq 0xc(%r14), %r8
leal 0x1(%r8), %r9d
movl %r9d, 0xc(%r14)
movb %sil, (%rdi,%r8)
incq %rdx
movl 0x8(%r14), %esi
incl %esi
movl %esi, 0x8(%r14)
addl $-0x8, %ecx
cmpq %rdx, %rax
jne 0x4f7a
jmp 0x4fb6
xorl %eax, %eax
jmp 0x4fb6
movl %edx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/stream.c
// Function: stream_seti
int stream_seti(stream_t *stream, int position, int v, int nb)
{
	int i;
	for (i = 0;
		i < nb && position < stream->cap;
		i++, position++) {
		stream->array[position] = ((v >> ((nb - i - 1) * 8)) & 0xFF);
	}
	return i;
}

// Assembly:
testl %ecx, %ecx
jle 0x4ff7
movl %ecx, %r8d
movslq %esi, %rsi
leal -0x8(,%r8,8), %ecx
xorl %eax, %eax
movslq 0x10(%rdi), %r9
cmpq %r9, %rsi
jge 0x4ff9
movl %edx, %r9d
sarl %cl, %r9d
movq (%rdi), %r10
movb %r9b, (%r10,%rsi)
incl %eax
incq %rsi
addl $-0x8, %ecx
cmpl %eax, %r8d
jne 0x4fd0
movl %r8d, %eax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/stream.c
// Function: stream_geti
int stream_geti(stream_t* stream, int position, int nb)
{
	int i, v = 0;
	for (i = 0; i < nb; i++, position++) {
		v <<= 8;
		v |= (stream->array[position] & 0xFF);
	}
	return v;
}

// Assembly:
testl %edx, %edx
jle 0x501b
movslq %esi, %rcx
addq (%rdi), %rcx
movl %edx, %edx
xorl %esi, %esi
xorl %eax, %eax
shll $0x8, %eax
movzbl (%rcx,%rsi), %edi
orl %edi, %eax
incq %rsi
cmpl %esi, %edx
jne 0x500a
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/stream.c
// Function: stream_vwritef
int stream_vwritef(stream_t *stream, const char *fmt, va_list args)
{
	int cnt, sz;
	char *buf;
	va_list ap_try;

	sz = 128;
	buf = (char*)alloca(sz);
	if (!buf) return -1;
try_print:
	va_copy(ap_try, args);
	cnt = vsnprintf(buf, sz, fmt, ap_try);
	va_end(ap_try);
	if (cnt >= sz) {
		sz *= 2;
		buf = (char*)alloca(sz);
		if (!buf) return -1;
		goto try_print;
	}
	if (cnt < 0)
		return -1;

	if (stream_writes(stream, buf, cnt) != cnt) {
		return -1;
	}

	return cnt;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r15
movq 0x10(%rdx), %rax
leaq -0x50(%rbp), %rcx
movq %rax, 0x10(%rcx)
movups (%rdx), %xmm0
movaps %xmm0, (%rcx)
leaq -0xd0(%rbp), %r12
movl $0x80, %esi
movq %r12, %rdi
movq %r13, %rdx
callq 0x2130
cmpl $0x80, %eax
jge 0x506f
movl %eax, %ebx
jmp 0x50c2
movq %r15, -0x30(%rbp)
movq %r13, -0x38(%rbp)
movl $0x80, %r13d
addl %r13d, %r13d
movslq %r13d, %r15
movq %rsp, %r12
leaq 0xf(%r15), %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movq 0x10(%r14), %rax
movq %rax, -0x40(%rbp)
movups (%r14), %xmm0
movaps %xmm0, -0x50(%rbp)
movq %r12, %rdi
movq %r13, %rsi
movq -0x38(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0x2130
cmpl %r15d, %eax
jge 0x507d
movl %eax, %ebx
movq -0x30(%rbp), %r15
testl %ebx, %ebx
js 0x50df
movq %r15, %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0x4d81
cmpl %ebx, %eax
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovel %ebx, %eax
jmp 0x50e4
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/stream.c
// Function: stream_append
int stream_append(stream_t* stream, const char* s, int n)
{
	int pos = stream->pos;
	int nwrite;

	stream->pos = stream->size;
	nwrite = stream_write(stream, s, n);
	stream->pos = pos;

	return nwrite;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x8(%rdi), %eax
movl 0xc(%rdi), %ebp
movl %eax, 0xc(%rdi)
callq 0x4d15
movl %ebp, 0xc(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/stream.c
// Function: stream_appends
int stream_appends(stream_t* stream, const char* s, int n)
{
	int pos = stream->pos;
	int nwrite;

	stream->pos = stream->size;
	nwrite = stream_writes(stream, s, n);
	stream->pos = pos;

	return nwrite;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x8(%rdi), %eax
movl 0xc(%rdi), %ebp
movl %eax, 0xc(%rdi)
callq 0x4d81
movl %ebp, 0xc(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/stream.c
// Function: stream_readi
int stream_readi(stream_t *stream, int nb)
{
	int v = 0;
	int i;
	for (i = 0;
		i < nb && stream->pos < stream->size;
		i++, stream->pos++) {
		v <<= 8;
		v |= (stream->array[stream->pos] & 0xff);
	}
	return v;
}

// Assembly:
testl %esi, %esi
jle 0x535f
movl 0x8(%rdi), %ecx
movslq 0xc(%rdi), %rdx
cmpl %ecx, %edx
cmovgl %edx, %ecx
leal 0x1(%rdx), %r8d
negl %ecx
xorl %eax, %eax
leal (%rcx,%r8), %r9d
cmpl $0x1, %r9d
je 0x535e
shll $0x8, %eax
movq (%rdi), %r9
movzbl (%r9,%rdx), %r9d
orl %r9d, %eax
incq %rdx
movl %r8d, 0xc(%rdi)
incl %r8d
decl %esi
jne 0x5338
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/utils.c
// Function: ltrim
char* ltrim(char* s)
{
	char* p = s;
	while (p && (*p) && isspace((int)(*((unsigned char*)p))))
		p++;
	return p;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x5b76
movq %rdi, %rbx
movb (%rdi), %bpl
testb %bpl, %bpl
je 0x5b78
callq 0x2230
movq (%rax), %rax
movzbl %bpl, %ecx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x5b78
movb 0x1(%rbx), %bpl
incq %rbx
testb %bpl, %bpl
jne 0x5b5d
jmp 0x5b78
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/utils.c
// Function: rtrim
char* rtrim(char* s)
{
	size_t len;
	char* p;

	len = strlen(s);
	p = s + len - 1;

	while (p >= s && isspace((int)(*((unsigned char*)p)))) (*(p--)) = '\0';

	return s;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x20e0
leaq (%rbx,%rax), %r14
decq %r14
cmpq %rbx, %r14
jb 0x5bb9
callq 0x2230
movq (%rax), %rcx
movzbl (%r14), %edx
testb $0x20, 0x1(%rcx,%rdx,2)
je 0x5bb9
movb $0x0, (%r14)
decq %r14
cmpq %rbx, %r14
jae 0x5b9f
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/utils.c
// Function: trim_quote
char* trim_quote(char* s)
{
	char* start, * end;
	size_t len;

	len = strlen(s);
	start = s;
	end = s + len - 1;

	while ((*start) && ((*start) == '\'' || (*start) == '"'))
		start++;

	while (end >= start && ((*end) == '\'' || (*end) == '"')) (*(end--)) = '\0';

	return start;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x20e0
movq %rax, %rcx
movq %rbx, %rax
movzbl (%rax), %edx
cmpl $0x22, %edx
je 0x5be0
cmpl $0x27, %edx
jne 0x5be5
incq %rax
jmp 0x5bd3
addq %rbx, %rcx
decq %rcx
cmpq %rax, %rcx
jb 0x5c05
movzbl (%rcx), %edx
cmpl $0x27, %edx
je 0x5bfd
cmpl $0x22, %edx
jne 0x5c05
movb $0x0, (%rcx)
decq %rcx
jmp 0x5beb
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/utils.c
// Function: urldecode
char *urldecode(char *s)
{
	unsigned char *src  = (unsigned char *)s,
				  *dest = (unsigned char *)s;
	while (*src) {
		if (*src == '%') {
			int a = (int)src[1] & 0xFF;
			int b = a ? ((int)src[2] & 0xFF) : 0;
			int ch = b ? hex2dec(src + 1) : -1;
			if (ch == -1) {
				*dest++ = *src++;
			}
			else {
				*dest++ = (char)ch;
				src += 3;
			}
		}
		else if (*src == '+') {
			*dest++ = ' ';
			src++;
		}
		else {
			*dest++ = *src++;
		}
	}
	*dest = '\0';
	return s;
}

// Assembly:
movq %rdi, %rax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rdi, %rcx
movq %rdi, %rsi
movzbl (%rsi), %edi
cmpl $0x25, %edi
je 0x5c40
cmpl $0x2b, %edi
je 0x5c35
testl %edi, %edi
je 0x5cdd
incq %rsi
movb %dil, (%rcx)
jmp 0x5cd5
movb $0x20, (%rcx)
incq %rsi
jmp 0x5cd5
movzbl 0x1(%rsi), %r9d
testl %r9d, %r9d
je 0x5ccf
movzbl 0x2(%rsi), %edi
testl %edi, %edi
je 0x5ccf
leal -0x30(%r9), %r8d
cmpl $0xa, %r8d
jb 0x5c83
leal -0x61(%r9), %r8d
cmpl $0x5, %r8d
ja 0x5c70
addl $-0x57, %r9d
jmp 0x5c80
leal -0x41(%r9), %r8d
addl $-0x37, %r9d
cmpl $0x6, %r8d
cmovael %edx, %r9d
movl %r9d, %r8d
leal -0x30(%rdi), %r9d
cmpl $0xa, %r9d
jb 0x5cad
leal -0x61(%rdi), %r9d
cmpl $0x5, %r9d
ja 0x5c9c
addl $-0x57, %edi
jmp 0x5caa
leal -0x41(%rdi), %r9d
addl $-0x37, %edi
cmpl $0x6, %r9d
cmovael %edx, %edi
movl %edi, %r9d
cmpl $-0x1, %r8d
je 0x5ccf
cmpl $-0x1, %r9d
je 0x5ccf
shll $0x4, %r8d
orl %r8d, %r9d
cmpl $-0x1, %r9d
je 0x5ccf
movb %r9b, (%rcx)
addq $0x3, %rsi
jmp 0x5cd5
incq %rsi
movb $0x25, (%rcx)
incq %rcx
jmp 0x5c15
movb $0x0, (%rcx)
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/utils.c
// Function: urlencode
int urlencode(char *buf, int buflen, const char *s)
{
	unsigned char *src  = (unsigned char *)s,
				  *dest = (unsigned char *)buf,
				  *end  = dest + buflen;
	int n = 0;
	while ((*src) && dest < end) {
		int ch = *src++;
		if (ch <= ' ' || ch > '~' ||
				ch == ':' || ch ==  '/' || ch == '?' || ch == '#' ||
				ch == '[' || ch ==  ']' || ch == '@' || ch == '!' ||
				ch == '$' || ch ==  '&' || ch == '\''|| ch == '(' ||
				ch == ')' || ch ==  '*' || ch == '+' || ch == ',' ||
				ch == ';' || ch ==  '=' || ch ==  '%') {
			if (ch == ' ') {
				*dest++ = '+';
			}
			else {
				int h = dec2ch((ch >> 4) & 0xf);
				int l = dec2ch(ch & 0xf);
				*dest++ = '%';
				if (dest < end) {
					*dest++ = h;
					if (dest < end) {
						*dest++ = l;
					}
				}
			}
		}
		else {
			*dest++ = ch;
		}
	}
	if (dest < end) {
		*dest = '\0';
	}
	return (int)(dest - (unsigned char*)buf);
}

// Assembly:
pushq %rbx
movb (%rdx), %r9b
testb %r9b, %r9b
sete %al
testl %esi, %esi
setg %r11b
setle %cl
orb %al, %cl
movq %rdi, %rax
jne 0x5db9
movslq %esi, %rcx
addq %rdi, %rcx
incq %rdx
movl $0x30, %esi
movabsq $0x14000000d6004ffd, %r8 # imm = 0x14000000D6004FFD
movq %rdi, %r10
leal -0x7f(%r9), %eax
cmpb $-0x5e, %al
jae 0x5d31
cmpb $0x20, %r9b
jne 0x5d43
movb $0x2b, (%r10)
incq %r10
jmp 0x5d8e
movzbl %r9b, %eax
addl $-0x21, %eax
cmpl $0x3c, %eax
ja 0x5db1
btq %rax, %r8
jae 0x5db1
movl %r9d, %r11d
andb $0xf, %r11b
cmpb $0xa, %r11b
movl $0x37, %ebx
cmovbl %esi, %ebx
leaq 0x1(%r10), %rax
movb $0x25, (%r10)
cmpq %rcx, %rax
jae 0x5d91
cmpb $-0x60, %r9b
movl $0x37, %eax
cmovbl %esi, %eax
shrb $0x4, %r9b
addb %al, %r9b
leaq 0x2(%r10), %rax
movb %r9b, 0x1(%r10)
cmpq %rcx, %rax
jae 0x5d91
addb %r11b, %bl
movb %bl, 0x2(%r10)
addq $0x3, %r10
movq %r10, %rax
movb (%rdx), %r9b
cmpq %rcx, %rax
setb %r11b
testb %r9b, %r9b
je 0x5db9
incq %rdx
movq %rax, %r10
cmpq %rcx, %rax
jb 0x5d1a
jmp 0x5db9
movb %r9b, (%r10)
jmp 0x5d2c
testb %r11b, %r11b
je 0x5dc1
movb $0x0, (%rax)
subl %edi, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/utils.c
// Function: parse_querystring
int parse_querystring(const char *query,
	int (*callback)(char *name, char *value, void *state),
	void *state)
{
	char *cpy, *saveptr = NULL;
	char *p;
	char *v;
	int r;

	if (!query || !*query) return 0;

	cpy = strdup(query);

	for (p = strtok_r(cpy, "&", &saveptr);
		p && *p;
		p = strtok_r(NULL, "&", &saveptr)) {

		v = strchr(p, '=');
		if (!v) continue;

		*v = '\0';
		v++;

		urldecode(v);

		if ((r = callback(p, v, state)) != 0) {
			return r;
		}
	}

	free(cpy);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq $0x0, 0x8(%rsp)
xorl %eax, %eax
testq %rdi, %rdi
je 0x5e83
cmpb $0x0, (%rdi)
je 0x5e83
movq %rdx, %r14
movq %rsi, %r15
callq 0x2380
leaq 0x18b7(%rip), %rsi      # 0x76b9
leaq 0x8(%rsp), %rdx
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0x2370
testq %rax, %rax
je 0x5e77
movq %rax, %r12
leaq 0x1896(%rip), %r13      # 0x76b9
leaq 0x8(%rsp), %rbp
cmpb $0x0, (%r12)
je 0x5e77
movq %r12, %rdi
movl $0x3d, %esi
callq 0x20d0
testq %rax, %rax
je 0x5e62
movq %rax, %rbx
movb $0x0, (%rax)
incq %rbx
movq %rbx, %rdi
callq 0x5c07
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq *%r15
testl %eax, %eax
jne 0x5e83
xorl %edi, %edi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2370
movq %rax, %r12
testq %rax, %rax
jne 0x5e28
movq 0x10(%rsp), %rdi
callq 0x2290
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop