LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/http.c
// Function: http_conn_close
static void http_conn_close(http_conn_t* conn)
{
	conn->conn.status = cs_closing;
	http_move_to_fly(conn);
	if (conn->conn.sock) {
		shutdown(conn->conn.sock, SHUT_RDWR);
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl $0x3, 0x48(%rdi)
xorl %eax, %eax
callq 0x17d59
cmpl $0x8, (%rax)
jl 0x16c37
leaq 0xd110(%rip), %rsi      # 0x23d28
leaq 0xd8d4(%rip), %rdx      # 0x244f3
leaq 0xd8de(%rip), %r8       # 0x24504
movl $0x8, %edi
movl $0x361, %ecx            # imm = 0x361
xorl %eax, %eax
callq 0x17d92
movq %rbx, %rdi
callq 0x17707
movq 0x88(%rbx), %rax
leaq 0xb0(%rax), %rcx
leaq 0x90(%rbx), %rdx
movq %rcx, 0x90(%rbx)
movq 0xb8(%rax), %rcx
movq %rcx, 0x98(%rbx)
movq %rdx, (%rcx)
movq %rdx, 0xb8(%rax)
incl 0xc8(%rax)
movl $0x1, 0x84(%rbx)
movl 0x10(%rbx), %edi
testl %edi, %edi
je 0x16c95
movl $0x2, %esi
popq %rbx
jmp 0x34c0
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/http.c
// Function: http_pool_item_free_conns
static void http_pool_item_free_conns(dllist_t *conns)
{
	dlitem_t* cur, * nxt;
	http_conn_t* conn;
	dllist_foreach(conns, cur, nxt,
		http_conn_t, conn, entry) {
		dllist_remove(&conn->entry);
		http_conn_free(conn);
	}
}

// Assembly:
movq (%rdi), %rax
cmpq %rdi, %rax
je 0x16efb
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq -0x90(%rax), %rdi
movq (%rax), %r14
movq 0x8(%rax), %rcx
movq %r14, (%rcx)
movq (%rax), %rax
movq %rcx, 0x8(%rax)
callq 0x16efc
movq %r14, %rax
cmpq %rbx, %r14
jne 0x16ecf
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/http.c
// Function: http_conn_free
static void http_conn_free(http_conn_t *conn)
{
	if (conn->request) {
		http_call_callback(conn->request, HTTP_ABORT, conn->response);
	}
	if (conn->response) {
		conn->response->conn = NULL;
		conn->response = NULL;
	}
	if (conn->ssl) {
		SSL_free(conn->ssl);
	}
	conn_free(&conn->conn);
	stream_free(&conn->field.name);
	stream_free(&conn->field.value);
	stream_free(&conn->proxy_stream);
	free(conn->tag);
	free(conn);

	logv("free http connection\n");
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0xa0(%rdi), %rsi
testq %rsi, %rsi
je 0x16f4b
movq 0xa8(%rbx), %rdx
movq 0x38(%rsi), %rax
testq %rax, %rax
je 0x16f2c
xorl %ecx, %ecx
movq %rcx, 0xa0(%rax)
movq %rcx, 0x38(%rsi)
movq 0x40(%rsi), %rax
testq %rax, %rax
je 0x16f4b
leaq 0x40(%rsi), %r14
movq 0x48(%rsi), %rcx
movl $0x1, %edi
callq *%rax
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq 0xa8(%rbx), %rax
testq %rax, %rax
je 0x16f64
xorl %ecx, %ecx
movq %rcx, 0x38(%rax)
movq %rcx, 0xa8(%rbx)
movq 0x78(%rbx), %rdi
testq %rdi, %rdi
je 0x16f72
callq 0x31f0
leaq 0x10(%rbx), %rdi
callq 0x19891
leaq 0xd0(%rbx), %rdi
callq 0x1d5f9
leaq 0xe8(%rbx), %rdi
callq 0x1d5f9
leaq 0x110(%rbx), %rdi
callq 0x1d5f9
movq 0x128(%rbx), %rdi
callq 0x3450
movq %rbx, %rdi
callq 0x3450
xorl %eax, %eax
callq 0x17d59
cmpl $0x8, (%rax)
jl 0x16fec
leaq 0xcd62(%rip), %rsi      # 0x23d28
leaq 0xd14f(%rip), %rdx      # 0x2411c
leaq 0xd157(%rip), %r8       # 0x2412b
movl $0x8, %edi
movl $0xba, %ecx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x17d92
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/http.c
// Function: http_remove_conn
static void http_remove_conn(http_conn_t* conn)
{
	dllist_remove(&conn->entry);
	if (conn->status == HTTP_CONN_ST_FLY)
		conn->pool->fly_count--;
	else if (conn->status == HTTP_CONN_ST_IDLE)
		conn->pool->idle_count--;
	else if (conn->status == HTTP_CONN_ST_BUSY)
		conn->pool->busy_count--;
	conn->status = HTTP_CONN_ST_NONE;
}

// Assembly:
movq 0x90(%rdi), %rax
movq 0x98(%rdi), %rcx
movq %rax, (%rcx)
movq 0x90(%rdi), %rax
movq %rcx, 0x8(%rax)
movl 0x84(%rdi), %eax
cmpl $0x3, %eax
je 0x17756
cmpl $0x2, %eax
je 0x17747
cmpl $0x1, %eax
jne 0x17763
movq 0x88(%rdi), %rax
decl 0xc8(%rax)
jmp 0x17763
movq 0x88(%rdi), %rax
decl 0xc0(%rax)
jmp 0x17763
movq 0x88(%rdi), %rax
decl 0xc4(%rax)
movl $0x0, 0x84(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/http.c
// Function: on_status
static int on_status(http_parser* parser, const char* at, size_t length)
{
	http_conn_t* conn = (http_conn_t*)parser->data;
	http_response_t* response = conn->response;
	response->status_code = parser->status_code;
	response->status_text = http_strdup(at, length);
	response->http_major = parser->http_major;
	response->http_minor = parser->http_minor;
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
movq 0x18(%rdi), %rax
movq 0xa8(%rax), %r13
movzwl 0x14(%rdi), %eax
movl %eax, 0x4(%r13)
leal 0x1(%rdx), %eax
movslq %eax, %rdi
callq 0x34b0
testq %rax, %rax
je 0x177df
movq %rax, %r14
movslq %r12d, %r12
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x32b0
movb $0x0, (%r14,%r12)
jmp 0x17817
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x17817
leaq 0xc533(%rip), %rsi      # 0x23d28
leaq 0xca83(%rip), %rdx      # 0x2427f
leaq 0xc0a0(%rip), %r8       # 0x238a3
xorl %r14d, %r14d
movl $0x3, %edi
movl $0xf7, %ecx
xorl %eax, %eax
callq 0x17d92
movq %r14, 0x8(%r13)
movzwl 0x10(%rbx), %eax
movw %ax, (%r13)
movzwl 0x12(%rbx), %eax
movw %ax, 0x2(%r13)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/http.c
// Function: on_header_field
static int on_header_field(http_parser* parser, const char* at, size_t length)
{
	http_conn_t* conn = (http_conn_t*)parser->data;

	if (conn->field.status == fs_value) {
		if (on_header_field_complete(parser))
			return -1;
	}

	conn->field.status = fs_name;

	if (stream_writes(&conn->field.name, at, (int)length) == -1) {
		loge("stream_writes()\n");
		return -1;
	}

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq 0x18(%rdi), %r12
leaq 0xd0(%r12), %r15
cmpl $0x2, 0x100(%r12)
jne 0x17899
movq 0xa8(%r12), %rdi
movq 0xd0(%r12), %rsi
movq 0xe8(%r12), %rdx
callq 0x14c46
xorl %eax, %eax
movq %rax, 0xd8(%r12)
movq %rax, 0xf0(%r12)
movl $0x0, 0x100(%r12)
movl $0x1, 0x100(%r12)
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x1d805
xorl %ebx, %ebx
cmpl $-0x1, %eax
jne 0x178f0
xorl %eax, %eax
callq 0x17d59
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x178f0
leaq 0xc457(%rip), %rsi      # 0x23d28
leaq 0xc9b3(%rip), %rdx      # 0x2428b
leaq 0xc9bc(%rip), %r8       # 0x2429b
movl $0x3, %edi
movl $0x604, %ecx            # imm = 0x604
xorl %eax, %eax
callq 0x17d92
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/http.c
// Function: on_header_value
static int on_header_value(http_parser* parser, const char* at, size_t length)
{
	http_conn_t* conn = (http_conn_t*)parser->data;

	conn->field.status = fs_value;

	if (stream_writes(&conn->field.value, at, (int)length) == -1) {
		loge("stream_writes()\n");
		return -1;
	}

	return 0;
}

// Assembly:
pushq %rbx
movq 0x18(%rdi), %rdi
movl $0x2, 0x100(%rdi)
addq $0xe8, %rdi
callq 0x1d805
xorl %ebx, %ebx
cmpl $-0x1, %eax
jne 0x17957
xorl %eax, %eax
callq 0x17d59
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x17957
leaq 0xc3f0(%rip), %rsi      # 0x23d28
leaq 0xc96d(%rip), %rdx      # 0x242ac
leaq 0xc955(%rip), %r8       # 0x2429b
movl $0x3, %edi
movl $0x612, %ecx            # imm = 0x612
xorl %eax, %eax
callq 0x17d92
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/http.c
// Function: on_headers_complete
static int on_headers_complete(http_parser* parser)
{
	http_conn_t* conn = (http_conn_t*)parser->data;

	if (conn->field.status != fs_none) {
		if (on_header_field_complete(parser))
			return -1;
	}

	conn->keep_alive = http_should_keep_alive(parser);

	return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x18(%rdi), %r14
cmpl $0x0, 0x100(%r14)
je 0x179a5
movq 0xa8(%r14), %rdi
movq 0xd0(%r14), %rsi
movq 0xe8(%r14), %rdx
callq 0x14c46
xorl %eax, %eax
movq %rax, 0xd8(%r14)
movq %rax, 0xf0(%r14)
movl $0x0, 0x100(%r14)
movq %rbx, %rdi
callq 0x7853
movl %eax, 0x108(%r14)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/http.c
// Function: on_body
static int on_body(http_parser* parser, const char* at, size_t length)
{
	http_conn_t* conn = (http_conn_t*)parser->data;
	http_response_t* response = conn->response;

	if (http_response_append_data(response, at, (int)length) == -1) {
		loge("http_response_append_data()\n");
		return -1;
	}
	return 0;
}

// Assembly:
pushq %rbx
movq 0x18(%rdi), %rax
movq 0xa8(%rax), %rdi
callq 0x14de4
xorl %ebx, %ebx
cmpl $-0x1, %eax
jne 0x17a0d
xorl %eax, %eax
callq 0x17d59
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0x17a0d
leaq 0xc33a(%rip), %rsi      # 0x23d28
leaq 0xc8c7(%rip), %rdx      # 0x242bc
leaq 0xc8c8(%rip), %r8       # 0x242c4
movl $0x3, %edi
movl $0x62d, %ecx            # imm = 0x62D
xorl %eax, %eax
callq 0x17d92
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/http.c
// Function: on_message_complete
static int on_message_complete(http_parser* parser)
{
	http_conn_t* conn = (http_conn_t*)parser->data;
	http_request_t* request = conn->request;
	http_response_t* response = conn->response;

	if (loglevel > LOG_DEBUG) {
		stream_t s = STREAM_INIT();
		http_request_headers_serialize(&s, request);
		logv("Request Headers:\r\n%s\r\n", s.array);
		stream_reset(&s);
		http_response_headers_serialize(&s, response);
		logv("Response:\r\n%s\r\n%s%s",
			s.array,
			response->status_code != 200 ? (const char*)response->data.array : "",
			response->status_code != 200 ? "\r\n" : "");
		stream_free(&s);
	}

	http_call_callback(request, HTTP_OK, response);

	if (conn->keep_alive) {
		http_move_to_idle(conn);
	}
	else {
		http_conn_close(conn);
	}
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x18(%rdi), %rbx
movq 0xa0(%rbx), %r14
movq 0xa8(%rbx), %r15
xorl %eax, %eax
callq 0x17d59
cmpl $0x8, (%rax)
jl 0x17b07
xorps %xmm0, %xmm0
movq %rsp, %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq %r14, %rsi
callq 0x1471a
xorl %eax, %eax
callq 0x17d59
cmpl $0x8, (%rax)
jl 0x17a8d
movq (%rsp), %r9
leaq 0xc2ba(%rip), %rsi      # 0x23d28
leaq 0xc86c(%rip), %rdx      # 0x242e1
leaq 0xc879(%rip), %r8       # 0x242f5
movl $0x8, %edi
movl $0x63c, %ecx            # imm = 0x63C
xorl %eax, %eax
callq 0x17d92
movq %rsp, %rdi
movq $0x0, 0x8(%rdi)
movq %r15, %rsi
callq 0x14e30
xorl %eax, %eax
callq 0x17d59
cmpl $0x8, (%rax)
jl 0x17aff
movq (%rsp), %r9
cmpl $0xc8, 0x4(%r15)
jne 0x17ac6
leaq 0xc331(%rip), %r11      # 0x23df2
movq %r11, %r10
jmp 0x17ad1
movq 0x20(%r15), %r10
leaq 0xc31f(%rip), %r11      # 0x23df0
leaq 0xc250(%rip), %rsi      # 0x23d28
leaq 0xc802(%rip), %rdx      # 0x242e1
leaq 0xc826(%rip), %r8       # 0x2430c
movl $0x8, %edi
movl $0x642, %ecx            # imm = 0x642
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x17d92
addq $0x10, %rsp
movq %rsp, %rdi
callq 0x1d5f9
testq %r14, %r14
je 0x17b45
movq 0x38(%r14), %rax
testq %rax, %rax
je 0x17b22
xorl %ecx, %ecx
movq %rcx, 0xa0(%rax)
movq %rcx, 0x38(%r14)
movq 0x40(%r14), %rax
testq %rax, %rax
je 0x17b45
leaq 0x40(%r14), %r12
movq 0x48(%r14), %rcx
xorl %edi, %edi
movq %r14, %rsi
movq %r15, %rdx
callq *%rax
xorps %xmm0, %xmm0
movups %xmm0, (%r12)
cmpl $0x0, 0x108(%rbx)
je 0x17bcc
xorl %eax, %eax
callq 0x17d59
cmpl $0x8, (%rax)
jl 0x17b80
leaq 0xc1c7(%rip), %rsi      # 0x23d28
leaq 0xc7b8(%rip), %rdx      # 0x24320
leaq 0xc7c3(%rip), %r8       # 0x24332
movl $0x8, %edi
movl $0x35a, %ecx            # imm = 0x35A
xorl %eax, %eax
callq 0x17d92
movq %rbx, %rdi
callq 0x17707
movq 0x88(%rbx), %rax
movl $0x90, %ecx
leaq (%rax,%rcx), %rdx
addq %rbx, %rcx
movq %rdx, 0x90(%rbx)
movq 0x98(%rax), %rdx
movq %rdx, 0x98(%rbx)
movq %rcx, (%rdx)
movq %rcx, 0x98(%rax)
incl 0xc0(%rax)
movl $0x2, 0x84(%rbx)
jmp 0x17bd4
movq %rbx, %rdi
callq 0x16bfa
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_get_flags
ns_flags_t ns_get_flags(ns_msg_t *msg)
{
	ns_flags_t f;
	int v = msg->flags;
	f.qr = (v >> 15) & 1;
	f.opcode = (v >> 11) & 0xf;
	f.aa = (v >> 10) & 1;
	f.tc = (v >> 9) & 1;
	f.rd = (v >> 8) & 1;
	f.ra = (v >> 7) & 1;
	f.z = (v >> 4) & 0x7;
	f.rcode = v & 0xf;
	return f;
}

// Assembly:
movzwl 0x2(%rdi), %eax
movl %eax, %ecx
shrl $0xf, %ecx
movl %eax, %edx
shrl $0xa, %edx
andl $0x1e, %edx
movl %eax, %esi
shrl $0x5, %esi
andl $0x20, %esi
movl %eax, %edi
shrl $0x3, %edi
andl $0x40, %edi
movl %eax, %r8d
shrl %r8d
andl $0x80, %r8d
leal (%rax,%rax), %r9d
andl $0x100, %r9d            # imm = 0x100
movl %eax, %r10d
andl $0x70, %r10d
shll $0x5, %r10d
orl %r9d, %r10d
shll $0xc, %eax
orl %ecx, %eax
orl %edx, %eax
orl %esi, %eax
orl %edi, %eax
orl %r8d, %eax
orl %r10d, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_set_flags
uint16_t ns_set_flags(ns_msg_t *msg, const ns_flags_t *flags)
{
	int32_t rv = 0;
	rv |= ((int)flags->qr & 1) << 15;
	rv |= ((int)flags->opcode & 0xf) << 11;
	rv |= ((int)flags->aa & 1) << 10;
	rv |= ((int)flags->tc & 1) << 9;
	rv |= ((int)flags->rd & 1) << 8;
	rv |= ((int)flags->ra & 1) << 7;
	rv |= ((int)flags->z & 7) << 4;
	rv |= ((int)flags->rcode & 0xf);
	if (msg)
		msg->flags = (uint16_t)(rv & 0xffff);
	return (uint16_t)(rv & 0xffff);
}

// Assembly:
movzwl (%rsi), %eax
movl %eax, %ecx
shll $0xf, %ecx
movl %eax, %edx
andl $0x1e, %edx
shll $0xa, %edx
orl %ecx, %edx
movl %eax, %ecx
andl $0x20, %ecx
shll $0x5, %ecx
orl %edx, %ecx
movl %eax, %edx
andl $0x40, %edx
leal (%rcx,%rdx,8), %ecx
movl $0x80, %edx
movl %eax, %esi
andl %edx, %esi
leal (%rcx,%rsi,2), %ecx
movl %eax, %esi
shrl %esi
andl %edx, %esi
orl %ecx, %esi
movl %eax, %ecx
shrl $0x5, %ecx
andl $0x70, %ecx
orl %esi, %ecx
shrl $0xc, %eax
orl %ecx, %eax
testq %rdi, %rdi
je 0x19b11
movw %ax, 0x2(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_get_ttl
uint32_t ns_get_ttl(const ns_msg_t* msg)
{
	int i, rrcount;
	uint32_t ttl = 0;
	ns_rr_t* rr;

	rrcount = ns_rrcount(msg);
	for (i = 0; i < rrcount; i++) {
		rr = msg->rrs + i;
		if (rr->ttl > 0 && rr->type != NS_TYPE_OPT) {
			if (ttl == 0 || ttl > rr->ttl) ttl = rr->ttl;
		}
	}

	return ttl;
}

// Assembly:
movzwl 0x6(%rdi), %ecx
movzwl 0x8(%rdi), %eax
leal (%rax,%rcx), %edx
movzwl 0xa(%rdi), %esi
addl %esi, %edx
je 0x19b67
movq 0x18(%rdi), %rdx
addl %esi, %eax
addl %eax, %ecx
shll $0x5, %ecx
xorl %esi, %esi
xorl %eax, %eax
movl 0xc(%rdx,%rsi), %edi
testl %edi, %edi
je 0x19b5d
cmpw $0x29, 0x8(%rdx,%rsi)
je 0x19b5d
leal -0x1(%rax), %r8d
cmpl %edi, %r8d
cmovbl %eax, %edi
movl %edi, %eax
addq $0x20, %rsi
cmpq %rsi, %rcx
jne 0x19b41
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_qr_clone
ns_qr_t* ns_qr_clone(const ns_qr_t* array, int num)
{
	ns_qr_t* copy, * dst;
	const ns_qr_t* src;
	int i;
	if (!array)
		return NULL;
	copy = (ns_qr_t*)malloc(sizeof(ns_qr_t) * num);
	if (!copy) {
		loge("alloc \n");
		return NULL;
	}
	memset(copy, 0, sizeof(ns_qr_t) * num);
	for (i = 0; i < num; i++) {
		src = array + i;
		dst = copy + i;
		dst->qname = src->qname ? strdup(src->qname) : NULL;
		dst->qtype = src->qtype;
		dst->qclass = src->qclass;
	}
	return copy;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x19be7
movl %esi, %ebp
movq %rdi, %r14
movslq %esi, %r15
shlq $0x4, %r15
movq %r15, %rdi
callq 0x34b0
testq %rax, %rax
je 0x19beb
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x31e0
testl %ebp, %ebp
jle 0x19c21
movl %ebp, %r15d
shlq $0x4, %r15
xorl %r12d, %r12d
movq (%r14,%r12), %rdi
testq %rdi, %rdi
je 0x19bbe
callq 0x3610
jmp 0x19bc0
xorl %eax, %eax
movq %rax, (%rbx,%r12)
movzwl 0x8(%r14,%r12), %eax
movw %ax, 0x8(%rbx,%r12)
movzwl 0xa(%r14,%r12), %eax
movw %ax, 0xa(%rbx,%r12)
addq $0x10, %r12
cmpq %r12, %r15
jne 0x19bae
jmp 0x19c21
xorl %ebx, %ebx
jmp 0x19c21
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x19c21
leaq 0xafd4(%rip), %rsi      # 0x24bd4
leaq 0xafda(%rip), %rdx      # 0x24be1
leaq 0x89e8(%rip), %r8       # 0x225f6
xorl %ebx, %ebx
movl $0x3, %edi
movl $0x6c, %ecx
xorl %eax, %eax
callq 0x17d92
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_msg_clone
ns_msg_t* ns_msg_clone(const ns_msg_t *msg)
{
	ns_msg_t* copy;
	copy = (ns_msg_t*)malloc(sizeof(ns_msg_t));
	if (!copy) {
		loge("alloc \n");
		return NULL;
	}

	memset(copy, 0, sizeof(ns_msg_t));
	
	copy->id = msg->id;
	copy->flags = msg->flags;
	if (msg->qrs) {
		copy->qrs = ns_qr_clone(msg->qrs, msg->qdcount);
		if (!copy->qrs) {
			loge("ns_qr_clone() error\n");
			free(copy);
			return NULL;
		}
	}
	copy->qdcount = msg->qdcount;

	if (msg->rrs) {
		copy->rrs = ns_rr_clone(msg->rrs, ns_rrcount(msg));
		if (!copy->rrs) {
			loge("ns_rr_clone() error\n");
			ns_msg_free(copy);
			return NULL;
		}
	}

	copy->ancount = msg->ancount;
	copy->nscount = msg->nscount;
	copy->arcount = msg->arcount;

	return copy;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movl $0x20, %edi
callq 0x34b0
testq %rax, %rax
je 0x1a11e
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movzwl (%r14), %eax
movw %ax, (%rbx)
movzwl 0x2(%r14), %eax
movw %ax, 0x2(%rbx)
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x1a0c7
movzwl 0x4(%r14), %esi
callq 0x19b6a
movq %rax, 0x10(%rbx)
testq %rax, %rax
je 0x1a15a
movzwl 0x4(%r14), %eax
movw %ax, 0x4(%rbx)
movq 0x18(%r14), %rdi
testq %rdi, %rdi
je 0x1a0fe
movzwl 0x6(%r14), %eax
movzwl 0x8(%r14), %ecx
addl %eax, %ecx
movzwl 0xa(%r14), %esi
addl %ecx, %esi
callq 0x19c2d
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x1a196
movzwl 0x6(%r14), %eax
movw %ax, 0x6(%rbx)
movzwl 0x8(%r14), %eax
movw %ax, 0x8(%rbx)
movzwl 0xa(%r14), %eax
movw %ax, 0xa(%rbx)
jmp 0x1a1d2
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x1a1d2
leaq 0xaa9d(%rip), %rsi      # 0x24bd4
leaq 0xaabb(%rip), %rdx      # 0x24bf9
leaq 0x84b1(%rip), %r8       # 0x225f6
xorl %ebx, %ebx
movl $0x3, %edi
movl $0x11f, %ecx            # imm = 0x11F
xorl %eax, %eax
callq 0x17d92
jmp 0x1a1d2
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x1a18c
leaq 0xaa67(%rip), %rsi      # 0x24bd4
leaq 0xaa85(%rip), %rdx      # 0x24bf9
leaq 0x8466(%rip), %r8       # 0x225e1
movl $0x3, %edi
movl $0x12a, %ecx            # imm = 0x12A
xorl %eax, %eax
callq 0x17d92
movq %rbx, %rdi
callq 0x3450
jmp 0x1a1d0
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x1a1c8
leaq 0xaa2b(%rip), %rsi      # 0x24bd4
leaq 0xaa49(%rip), %rdx      # 0x24bf9
leaq 0xaa4f(%rip), %r8       # 0x24c06
movl $0x3, %edi
movl $0x134, %ecx            # imm = 0x134
xorl %eax, %eax
callq 0x17d92
movq %rbx, %rdi
callq 0x1a1dd
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_msg_free
void ns_msg_free(ns_msg_t *msg)
{
	int i, rrcount;
	if (msg) {
        if (msg->qrs) {
            for (i = 0; i < msg->qdcount; i++) {
                ns_msg_free_qr(msg->qrs + i);
            }
            free(msg->qrs);
        }

        if (msg->rrs) {
            for (i = 0, rrcount = ns_rrcount(msg);
                    i < rrcount; i++) {
                ns_msg_free_rr(msg->rrs + i);
            }
            free(msg->rrs);
        }
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x1a293
movq %rdi, %rbx
cmpq $0x0, 0x10(%rdi)
je 0x1a22c
cmpw $0x0, 0x4(%rbx)
je 0x1a223
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x10(%rbx), %rax
movq (%rax,%r14), %rdi
callq 0x3450
incq %r15
movzwl 0x4(%rbx), %eax
addq $0x10, %r14
cmpq %rax, %r15
jb 0x1a206
movq 0x10(%rbx), %rdi
callq 0x3450
cmpq $0x0, 0x18(%rbx)
je 0x1a293
movzwl 0x6(%rbx), %r15d
movzwl 0x8(%rbx), %eax
leal (%rax,%r15), %edx
movzwl 0xa(%rbx), %ecx
addl %ecx, %edx
je 0x1a281
addl %ecx, %eax
addl %eax, %r15d
shll $0x5, %r15d
xorl %r12d, %r12d
movq 0x18(%rbx), %r13
leaq (%r12,%r13), %r14
movq (%r13,%r12), %rdi
callq 0x3450
movq %r14, %rdi
callq 0x1a01c
movq 0x18(%r13,%r12), %rdi
callq 0x3450
addq $0x20, %r12
cmpq %r12, %r15
jne 0x1a254
movq 0x18(%rbx), %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x3450
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: qr_key
const char* qr_key(const ns_qr_t* qr)
{
	static char key[REQ_KEY_SIZE];
	int n;

	if (!qr)
		return NULL;

	n = snprintf(key, sizeof(key), "%s %s %s",
		ns_typename(qr->qtype),
		ns_classname(qr->qclass),
		qr->qname ? qr->qname : "");

	if (n <= 0 || n >= sizeof(key)) {
		loge("snprintf() error\n");
		return NULL;
	}

	return key;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x1a339
movq %rdi, %rbx
movzwl 0x8(%rdi), %edi
callq 0x1a346
movq %rax, %r14
movzwl 0xa(%rbx), %edi
callq 0x1a47d
movq (%rbx), %rcx
testq %rcx, %rcx
leaq 0x9b23(%rip), %r9       # 0x23df2
cmovneq %rcx, %r9
leaq 0x13506(%rip), %rbx     # 0x2d7e0
leaq 0xac11(%rip), %rdx      # 0x24ef2
movl $0x10f, %esi            # imm = 0x10F
movq %rbx, %rdi
movq %r14, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x3590
movl $0xfffffef1, %ecx       # imm = 0xFFFFFEF1
addl %ecx, %eax
cmpl %ecx, %eax
ja 0x1a33b
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x1a33b
leaq 0xa8be(%rip), %rsi      # 0x24bd4
leaq 0xa8fe(%rip), %rdx      # 0x24c1b
leaq 0xa8fe(%rip), %r8       # 0x24c22
xorl %ebx, %ebx
movl $0x3, %edi
movl $0x14f, %ecx            # imm = 0x14F
xorl %eax, %eax
callq 0x17d92
jmp 0x1a33b
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_typename
const char *ns_typename(uint16_t type)
{
	static char num[20] = {0};
    switch (type) {
        case NS_QTYPE_A		: return "A";
        case NS_QTYPE_NS	: return "NS";
        case NS_QTYPE_MD	: return "MD";	
        case NS_QTYPE_MF	: return "MF";	
        case NS_QTYPE_CNAME	: return "CNAME";
        case NS_QTYPE_SOA	: return "SOA";
        case NS_QTYPE_MB	: return "MB";	
        case NS_QTYPE_MG	: return "MG";	
        case NS_QTYPE_MR	: return "MR";	
        case NS_QTYPE_NULL	: return "NULL";
        case NS_QTYPE_WKS	: return "WKS";
        case NS_QTYPE_PTR	: return "PTR";
        case NS_QTYPE_HINFO	: return "HINFO";
        case NS_QTYPE_MINFO	: return "MINFO";
        case NS_QTYPE_MX	: return "MX";	
        case NS_QTYPE_TXT	: return "TXT";
        case NS_QTYPE_AAAA	: return "AAAA";
        case NS_QTYPE_OPT	: return "OPT";
        case NS_QTYPE_AXFR	: return "AXFR";
        case NS_QTYPE_MAILB	: return "MAILB";
        case NS_QTYPE_MAILA	: return "MAILA";
        case NS_QTYPE_ANY	: return "ANY";
        default:
			snprintf(num, sizeof(num) - 1, "QTYPE(%d)", (int)type);
			return num;
    }

}

// Assembly:
pushq %rbx
leal -0x1(%rdi), %eax
cmpl $0x28, %eax
ja 0x1a36b
leaq 0xa6da(%rip), %rcx      # 0x24a30
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x8a62(%rip), %rbx      # 0x22dc8
jmp 0x1a478
leal -0xfc(%rdi), %eax
cmpl $0x3, %eax
ja 0x1a392
leaq 0xa757(%rip), %rcx      # 0x24ad4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xab2d(%rip), %rbx      # 0x24eba
jmp 0x1a478
movzwl %di, %ecx
leaq 0x13554(%rip), %rbx     # 0x2d8f0
leaq 0xab2c(%rip), %rdx      # 0x24ecf
movl $0x13, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3590
jmp 0x1a478
leaq 0xaaf8(%rip), %rbx      # 0x24eb6
jmp 0x1a478
leaq 0xaab9(%rip), %rbx      # 0x24e83
jmp 0x1a478
leaq 0xaab3(%rip), %rbx      # 0x24e89
jmp 0x1a478
leaq 0xaac7(%rip), %rbx      # 0x24ea9
jmp 0x1a478
leaq 0xaaad(%rip), %rbx      # 0x24e9b
jmp 0x1a478
leaq 0xaa83(%rip), %rbx      # 0x24e7d
jmp 0x1a478
leaq 0xaa7d(%rip), %rbx      # 0x24e80
jmp 0x1a478
leaq 0xaa81(%rip), %rbx      # 0x24e8d
jmp 0x1a478
leaq 0x79db(%rip), %rbx      # 0x21df0
jmp 0x1a478
leaq 0xaa72(%rip), %rbx      # 0x24e90
jmp 0x1a478
leaq 0x899e(%rip), %rbx      # 0x22dc5
jmp 0x1a478
leaq 0xaa63(%rip), %rbx      # 0x24e93
jmp 0x1a478
leaq 0xaa66(%rip), %rbx      # 0x24e9f
jmp 0x1a478
leaq 0xaa54(%rip), %rbx      # 0x24e96
jmp 0x1a478
leaq 0xaa58(%rip), %rbx      # 0x24ea3
jmp 0x1a478
leaq 0xaa5e(%rip), %rbx      # 0x24eb2
jmp 0x1a478
leaq 0xaa52(%rip), %rbx      # 0x24eaf
jmp 0x1a478
leaq 0xaa5f(%rip), %rbx      # 0x24ec5
jmp 0x1a478
leaq 0xaa5c(%rip), %rbx      # 0x24ecb
jmp 0x1a478
leaq 0xaa47(%rip), %rbx      # 0x24ebf
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_classname
const char *ns_classname(uint16_t cls)
{
	static char num[20] = {0};
    switch (cls) {
        case NS_QCLASS_IN: return "IN";
        case NS_QCLASS_CS: return "CS";
        case NS_QCLASS_CH: return "CH";
        case NS_QCLASS_HS: return "HS";
        case NS_QCLASS_ANY:return "ANY";
        default:
			snprintf(num, sizeof(num) - 1, "QCLASS(%d)", (int)cls);
			return num;
    }
}

// Assembly:
pushq %rbx
leal -0x1(%rdi), %eax
cmpl $0x3, %eax
ja 0x1a49f
leaq 0xa657(%rip), %rcx      # 0x24ae4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xaa3c(%rip), %rbx      # 0x24ed9
jmp 0x1a4eb
cmpl $0xff, %edi
jne 0x1a4b0
leaq 0xaa1d(%rip), %rbx      # 0x24ecb
jmp 0x1a4eb
movzwl %di, %ecx
leaq 0x13456(%rip), %rbx     # 0x2d910
leaq 0xaa1e(%rip), %rdx      # 0x24edf
movl $0x13, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3590
jmp 0x1a4eb
leaq 0x7983(%rip), %rbx      # 0x21e5c
jmp 0x1a4eb
leaq 0xa9fa(%rip), %rbx      # 0x24edc
jmp 0x1a4eb
leaq 0x8901(%rip), %rbx      # 0x22dec
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_find_rr
ns_rr_t *ns_find_rr(ns_msg_t *msg, int type)
{
	int i, rrcount;
	ns_rr_t *rr;

	rrcount = ns_rrcount(msg);
	for (i = rrcount - 1; i >= 0; i--) {
		rr = msg->rrs + i;
		if (rr->type == type) {
			return rr;
		}
	}

	return NULL;
}

// Assembly:
movzwl 0x6(%rdi), %eax
movzwl 0x8(%rdi), %edx
addq %rax, %rdx
movzwl 0xa(%rdi), %eax
leaq (%rdx,%rax), %rcx
shll $0x5, %ecx
addq %rax, %rdx
incq %rdx
xorl %eax, %eax
decq %rdx
testq %rdx, %rdx
jle 0x1b570
movq 0x18(%rdi), %r8
movzwl -0x18(%r8,%rcx), %r9d
addq $-0x20, %rcx
cmpl %esi, %r9d
jne 0x1b54f
addq %rcx, %r8
movq %r8, %rax
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_remove_rr
int ns_remove_rr(ns_msg_t* msg, ns_rr_t *rr)
{
	int i, rrcount;
	ns_rr_t* p;

	rrcount = ns_rrcount(msg);
	for (i = rrcount - 1; i >= 0; i--) {
		p = msg->rrs + i;
		if (p == rr) {
			ns_rdata_free_opts(rr);
			free(rr->rdata);
			memmove(msg->rrs + i, msg->rrs + i + 1,
				(rrcount - i - 1) * sizeof(ns_rr_t));
			msg->arcount--;
			return 0;
		}
	}

	return -1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movzwl 0x6(%rdi), %eax
movzwl 0x8(%rdi), %ecx
addl %eax, %ecx
movzwl 0xa(%rdi), %r12d
addl %ecx, %r12d
leaq 0x1(%r12), %rax
shll $0x5, %r12d
movq $-0x20, %r15
decq %rax
jle 0x1b5eb
addq $0x20, %r15
addq $-0x20, %r12
movq 0x18(%rbx), %rcx
addq %r12, %rcx
cmpq %r14, %rcx
jne 0x1b5a1
movq %r14, %rdi
callq 0x1b5fc
movq 0x18(%r14), %rdi
callq 0x3450
movq 0x18(%rbx), %rax
leaq (%rax,%r12), %rdi
leaq (%rax,%r12), %rsi
addq $0x20, %rsi
movq %r15, %rdx
callq 0x35a0
decw 0xa(%rbx)
xorl %eax, %eax
jmp 0x1b5f0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_rdata_free_opts
static void ns_rdata_free_opts(ns_rr_t *rr)
{
	ns_optlist_t *opts = rr->rdata;
    ns_opt_t *opt;
    
	if (opts != NULL && opts->opts != NULL) {
        int i;
        for (i = 0; i < opts->optcount; i++) {
            opt = opts->opts + i;
            ns_free_opt(opt);
        }
        free(opts->opts);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq 0x18(%rdi), %rbx
testq %rbx, %rbx
je 0x1b64d
cmpq $0x0, (%rbx)
je 0x1b64d
cmpl $0x0, 0x8(%rbx)
jle 0x1b640
movl $0x8, %r14d
xorl %r15d, %r15d
movq (%rbx), %rax
testq %rax, %rax
je 0x1b630
movq (%rax,%r14), %rdi
callq 0x3450
incq %r15
movslq 0x8(%rbx), %rax
addq $0x10, %r14
cmpq %rax, %r15
jl 0x1b61f
movq (%rbx), %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x3450
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_add_optrr
ns_rr_t *ns_add_optrr(ns_msg_t *msg)
{
    ns_rr_t *rr, *rrs;

    rrs = realloc(msg->rrs, ((int)ns_rrcount(msg) + 1) * sizeof(ns_rr_t));
    if (rrs == NULL) {
        loge("alloc\n");
        return NULL;
    }
    msg->rrs = rrs;
    rr = msg->rrs + ns_rrcount(msg);
    msg->arcount++;
    memset(rr, 0, sizeof(ns_rr_t));
    rr->type = NS_TYPE_OPT;
    rr->cls = NS_PAYLOAD_SIZE;
    rr->ttl = (NS_EDNS_VERSION << 16) & 0xFF0000;
    return rr;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
movzwl 0x6(%rbx), %eax
movzwl 0x8(%rbx), %ecx
addl %eax, %ecx
movzwl 0xa(%rbx), %esi
addl %ecx, %esi
shll $0x5, %esi
addq $0x20, %rsi
callq 0x35b0
testq %rax, %rax
je 0x1b6c1
movq %rax, 0x18(%rbx)
movzwl 0x6(%rbx), %ecx
movzwl 0x8(%rbx), %edx
movzwl 0xa(%rbx), %esi
shll $0x5, %ecx
shll $0x5, %edx
addq %rcx, %rdx
addq %rax, %rdx
movl %esi, %eax
shll $0x5, %eax
leaq (%rdx,%rax), %r14
incl %esi
movw %si, 0xa(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rax,%rdx)
movups %xmm0, 0x10(%rax,%rdx)
movq $0x4000029, 0x8(%rax,%rdx) # imm = 0x4000029
jmp 0x1b6f9
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x1b6f9
leaq 0x94fd(%rip), %rsi      # 0x24bd4
leaq 0x95b4(%rip), %rdx      # 0x24c92
leaq 0x81be(%rip), %r8       # 0x238a3
xorl %r14d, %r14d
movl $0x3, %edi
movl $0x416, %ecx            # imm = 0x416
xorl %eax, %eax
callq 0x17d92
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_remove_optrr
int ns_remove_optrr(ns_msg_t *msg)
{
    int i, rrcount;
    ns_rr_t *rr;

    rrcount = ns_rrcount(msg);
    for (i = rrcount - 1; i >= 0; i--) {
        rr = msg->rrs + i;
        if (rr->type == NS_TYPE_OPT) {
            break;
        }
    }
    if (i >= 0) {
        ns_rdata_free_opts(rr);
        free(rr->rdata);
        memmove(msg->rrs + i, msg->rrs + i + 1,
                (rrcount - i - 1) * sizeof(ns_rr_t));
        msg->arcount--;
        return 0;
    }
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movzwl 0x6(%rdi), %eax
movzwl 0x8(%rdi), %ecx
addl %eax, %ecx
movzwl 0xa(%rdi), %ebp
addl %ecx, %ebp
movl %ebp, %r12d
addl $-0x1, %r12d
setb %cl
jae 0x1b747
movq 0x18(%rbx), %rax
movl %r12d, %edx
shlq $0x5, %rdx
leaq (%rax,%rdx), %r14
cmpw $0x29, 0x8(%rax,%rdx)
jne 0x1b74c
movl %ebp, %r15d
jmp 0x1b77f
movl %ebp, %r15d
jmp 0x1b77f
movl %ebp, %edx
leal -0x1(%rdx), %r15d
testl %r15d, %r15d
setg %cl
jle 0x1b776
addl $-0x2, %edx
shlq $0x5, %rdx
leaq (%rax,%rdx), %r14
cmpw $0x29, 0x8(%rax,%rdx)
movl %r15d, %edx
jne 0x1b74e
leal -0x1(%r15), %r12d
jmp 0x1b77f
xorl %r15d, %r15d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb %cl, %cl
je 0x1b7c5
movq %r14, %rdi
callq 0x1b5fc
movq 0x18(%r14), %rdi
callq 0x3450
movq 0x18(%rbx), %rax
movl %r12d, %ecx
shlq $0x5, %rcx
leaq (%rax,%rcx), %rdi
leaq (%rax,%rcx), %rsi
addq $0x20, %rsi
subl %r15d, %ebp
movslq %ebp, %rdx
shlq $0x5, %rdx
callq 0x35a0
decw 0xa(%rbx)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_optrr_find_opt
ns_opt_t *ns_optrr_find_opt(ns_rr_t *rr, uint16_t code)
{
	ns_optlist_t *opts = rr->rdata;
    ns_opt_t *opt;
    int i;
    if (opts != NULL) {
        for (i = 0; i < opts->optcount; i++) {
            opt = opts->opts + i;
            if (opt->code == code) {
                return opt;
            }
        }
    }
    return NULL;
}

// Assembly:
movq 0x18(%rdi), %rax
testq %rax, %rax
je 0x1b7f1
movslq 0x8(%rax), %rcx
testq %rcx, %rcx
jle 0x1b7f1
movq (%rax), %rax
cmpw %si, (%rax)
je 0x1b7f3
addq $0x10, %rax
decq %rcx
jne 0x1b7e3
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_optrr_remove_opt
int ns_optrr_remove_opt(ns_rr_t *rr, uint16_t code)
{
	ns_optlist_t *opts = rr->rdata;
    ns_opt_t *opt;
    int i;
    if (opts != NULL) {
        for (i = 0; i < opts->optcount; i++) {
            opt = opts->opts + i;
			if (opt->code != code)
				continue;
			ns_free_opt(opt);
			memmove(opts->opts + i, opts->opts + i + 1,
				(opts->optcount - i - 1) * sizeof(ns_opt_t));
			opts->optcount--;
			return 0;
		}
    }
    return -1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq 0x18(%rdi), %rbx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rbx, %rbx
je 0x1b861
movslq 0x8(%rbx), %rcx
testq %rcx, %rcx
jle 0x1b861
movq (%rbx), %rdx
shlq $0x4, %rcx
movl $0x1, %ebp
xorl %r14d, %r14d
cmpw %si, (%rdx,%r14)
je 0x1b832
addq $0x10, %r14
incl %ebp
cmpq %r14, %rcx
jne 0x1b81e
jmp 0x1b861
movq 0x8(%rdx,%r14), %rdi
callq 0x3450
movq (%rbx), %rax
leaq (%rax,%r14), %rdi
leaq (%rax,%r14), %rsi
addq $0x10, %rsi
movl 0x8(%rbx), %eax
subl %ebp, %eax
movslq %eax, %rdx
shlq $0x4, %rdx
callq 0x35a0
decl 0x8(%rbx)
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_optrr_new_opt
ns_opt_t *ns_optrr_new_opt(ns_optlist_t *opts, int optcode)
{
	ns_opt_t *newlist, * opt;

	newlist = realloc(opts->opts, (opts->optcount + 1) * sizeof(ns_opt_t));
	if (newlist == NULL)
		return NULL;
	opts->opts = newlist;
	opt = newlist + opts->optcount;
	opts->optcount++;
	memset(opt, 0, sizeof(ns_opt_t));
	opt->code = optcode;

	return opt;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movq (%rdi), %rdi
movslq 0x8(%r14), %rsi
shlq $0x4, %rsi
addq $0x10, %rsi
callq 0x35b0
testq %rax, %rax
je 0x1b8b0
movq %rax, (%r14)
movslq 0x8(%r14), %rcx
leal 0x1(%rcx), %edx
movq %rcx, %rsi
shlq $0x4, %rsi
movq %rax, %rcx
addq %rsi, %rcx
movl %edx, 0x8(%r14)
xorps %xmm0, %xmm0
movups %xmm0, (%rax,%rsi)
movw %bx, (%rax,%rsi)
jmp 0x1b8b2
xorl %ecx, %ecx
movq %rcx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_optrr_set_opt
ns_opt_t* ns_optrr_set_opt(ns_rr_t* rr, uint16_t code, uint16_t len, const char *data)
{
	ns_optlist_t* opts = rr->rdata;
	ns_opt_t* opt;

	if (opts == NULL) {
		opts = malloc(sizeof(ns_optlist_t));
		if (opts == NULL)
			return NULL;
		memset(opts, 0, sizeof(ns_optlist_t));
		rr->rdata = opts;
	}

	opt = ns_optrr_find_opt(rr, code);

	if (opt == NULL) {
		opt = ns_optrr_new_opt(opts, code);
		if (opt == NULL)
			return NULL;
	}

	ns_free_opt(opt);

	opt->code = code;
	opt->length = len;
	opt->data = malloc(len);

	if (opt->data == NULL)
		return NULL;

	memcpy(opt->data, data, opt->length);

	return opt;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rcx, %rbx
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
movq 0x18(%rdi), %rax
testq %rax, %rax
jne 0x1b8f5
movl $0x10, %edi
callq 0x34b0
testq %rax, %rax
je 0x1b96c
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rax, 0x18(%r15)
movq 0x18(%r15), %rdx
testq %rdx, %rdx
je 0x1b919
movslq 0x8(%rdx), %rcx
testq %rcx, %rcx
jle 0x1b919
movq (%rdx), %r15
cmpw %r14w, (%r15)
je 0x1b91c
addq $0x10, %r15
decq %rcx
jne 0x1b90a
xorl %r15d, %r15d
testq %r15, %r15
jne 0x1b935
movzwl %r14w, %esi
movq %rax, %rdi
callq 0x1b866
movq %rax, %r15
testq %rax, %rax
je 0x1b96c
movq 0x8(%r15), %rdi
callq 0x3450
movw %r14w, (%r15)
movw %bp, 0x2(%r15)
movzwl %bp, %r14d
movq %r14, %rdi
callq 0x34b0
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0x1b96c
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x32b0
jmp 0x1b96f
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_ecs_parse_subnet
int ns_ecs_parse_subnet(struct sockaddr *addr /*out*/, int *pmask /*out*/, const char *str /*in*/)
{
	char buf[INET6_ADDRSTRLEN], *sp_pos;
	int mask = -1;
	int is_ipv6;

	strncpy(buf, str, INET6_ADDRSTRLEN);
	buf[INET6_ADDRSTRLEN - 1] = '\0';

	sp_pos = strrchr(buf, '/');
	if (sp_pos) {
		*sp_pos = 0;
		mask = atoi(sp_pos + 1);
	}

	is_ipv6 = buf[0] =='[' || strchr(buf, ':');

	if (is_ipv6) {
		struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr;
		struct in6_addr *ip = &(addr6->sin6_addr);
		if (inet_pton(AF_INET6, buf, ip) != 1) {
			loge("invalid addr %s: errno=%d, %s\n",
				str, errno, strerror(errno));
			return -1;
		}
		addr6->sin6_family = AF_INET6;
		if (mask == -1) mask = 128;
	}
	else {
		struct sockaddr_in *addr4 = (struct sockaddr_in *)addr;
		struct in_addr *ip = &(addr4->sin_addr);
		if (inet_pton(AF_INET, buf, ip) != 1) {
			loge("invalid addr %s: errno=%d, %s\n",
				str, errno, strerror(errno));
			return -1;
		}
		addr4->sin_family = AF_INET;
		if (mask == -1) mask = 32;
	}

	*pmask = mask;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq %rsp, %r12
movl $0x2e, %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x31d0
movb $0x0, 0x2d(%r12)
movq %r12, %rdi
movl $0x2f, %esi
callq 0x33f0
testq %rax, %rax
je 0x1b9cf
movb $0x0, (%rax)
incq %rax
movq %rax, %rdi
callq 0x3570
movl %eax, %ebp
jmp 0x1b9d4
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpb $0x5b, (%rsp)
je 0x1b9f0
movq %rsp, %rdi
movl $0x3a, %esi
callq 0x3150
testq %rax, %rax
je 0x1ba88
leaq 0x8(%r15), %rdx
movq %rsp, %rsi
movl $0xa, %edi
callq 0x3630
movl %eax, %r12d
cmpl $0x1, %eax
jne 0x1ba1c
movw $0xa, (%r15)
cmpl $-0x1, %ebp
movl $0x80, %eax
cmovel %eax, %ebp
jmp 0x1ba6c
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x1ba6c
callq 0x3040
movl (%rax), %r15d
movl %r15d, %edi
callq 0x3140
movq %rax, %r10
leaq 0x9192(%rip), %rsi      # 0x24bd4
leaq 0x9256(%rip), %rdx      # 0x24c9f
leaq 0x9263(%rip), %r8       # 0x24cb3
movl $0x3, %edi
movl $0x4a7, %ecx            # imm = 0x4A7
movq %r14, %r9
xorl %eax, %eax
pushq %r10
pushq %r15
callq 0x17d92
addq $0x10, %rsp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $0x1, %r12d
jne 0x1ba7b
movl %ebp, (%rbx)
xorl %eax, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4(%r15), %rdx
movq %rsp, %rsi
movl $0x2, %edi
callq 0x3630
movl %eax, %r12d
cmpl $0x1, %eax
jne 0x1bab4
movw $0x2, (%r15)
cmpl $-0x1, %ebp
movl $0x20, %eax
jmp 0x1ba17
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x1ba6c
callq 0x3040
movl (%rax), %r15d
movl %r15d, %edi
callq 0x3140
movq %rax, %r10
leaq 0x90fa(%rip), %rsi      # 0x24bd4
leaq 0x91be(%rip), %rdx      # 0x24c9f
leaq 0x91cb(%rip), %r8       # 0x24cb3
movl $0x3, %edi
movl $0x4b2, %ecx            # imm = 0x4B2
jmp 0x1ba5a
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_optrr_set_ecs
int ns_optrr_set_ecs(ns_rr_t *rr, struct sockaddr *addr, int srcprefix, int scopeprefix)
{
	ns_optlist_t *opts = rr->rdata;
	ns_opt_t *opt;

	if (opts == NULL) {
		opts = malloc(sizeof(ns_optlist_t));
        if (opts == NULL)
            return -1;
		memset(opts, 0, sizeof(ns_optlist_t));
		rr->rdata = opts;
    }

	opt = ns_optrr_find_ecs(rr);

	if (opt == NULL) {
		opt = ns_optrr_new_opt(opts, NS_OPTCODE_ECS);
		if (opt == NULL)
			return -1;
	}
    
    return ns_set_ecs(opt, addr, srcprefix, scopeprefix);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
movq 0x18(%rdi), %rax
testq %rax, %rax
jne 0x1bd55
movl $0x10, %edi
callq 0x34b0
testq %rax, %rax
je 0x1bdab
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rax, 0x18(%r15)
movq 0x18(%r15), %rdx
testq %rdx, %rdx
je 0x1bd79
movslq 0x8(%rdx), %rcx
testq %rcx, %rcx
jle 0x1bd79
movq (%rdx), %rdi
cmpw $0x8, (%rdi)
je 0x1bd7b
addq $0x10, %rdi
decq %rcx
jne 0x1bd6a
xorl %edi, %edi
testq %rdi, %rdi
jne 0x1bd95
movq %rax, %rdi
movl $0x8, %esi
callq 0x1b866
movq %rax, %rdi
testq %rax, %rax
je 0x1bdab
movq %r14, %rsi
movl %ebp, %edx
movl %ebx, %ecx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1baf7
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_parse_ect
ns_ecs_t* ns_parse_ect(ns_ecs_t *ecs, char *data, int len)
{
	int addrlen, i;
	stream_t ns = STREAM_INIT();
	ns.array = data;
	ns.cap = len;
	ns.size = len;
	ns.pos = 0;

#define check_size(n) \
        if (stream_rsize(&ns) < (n)) { \
            return NULL; \
        }

	memset(ecs, 0, sizeof(ns_ecs_t));

	check_size(2);
	ecs->family = stream_readi16(&ns);
	check_size(2);
	ecs->src_prefix_len = stream_readi8(&ns);
	ecs->scope_prefix_len = stream_readi8(&ns);

	addrlen = ecs->src_prefix_len / 8;
	if (ecs->src_prefix_len % 8)
		addrlen++;

	if (ecs->family == ADDR_FAMILY_NUM_IP) {
		if (addrlen > 4) {
			/* invalid src_prefix_len */
			return NULL;
		}
	}
	else if (ecs->family == ADDR_FAMILY_NUM_IP6) {
		if (addrlen > 16) {
			/* invalid src_prefix_len */
			return NULL;
		}
	}
	else {
		/* invalid family */
		return NULL;
	}

	check_size(addrlen);

	for (i = 0; i < addrlen; i++) {
		((uint8_t *)(&ecs->subnet))[i] = stream_readi8(&ns);
	}

#undef check_size

	return ecs;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq %rsi, (%rsp)
movl %edx, 0x10(%rsp)
movl %edx, 0x8(%rsp)
xorl %eax, %eax
movl %eax, 0xc(%rsp)
movl %eax, 0x10(%rdi)
movups %xmm0, (%rdi)
cmpl $0x2, %edx
jl 0x1c619
movq %rdi, %rbx
movq %rsp, %r14
movq %r14, %rdi
movl $0x2, %esi
callq 0x1dd7b
movw %ax, (%rbx)
movl 0x8(%r14), %eax
subl 0xc(%r14), %eax
cmpl $0x2, %eax
jl 0x1c619
movq %rsp, %r14
movq %r14, %rdi
movl $0x1, %esi
callq 0x1dd7b
movb %al, 0x2(%rbx)
movq %r14, %rdi
movl $0x1, %esi
callq 0x1dd7b
movb %al, 0x3(%rbx)
movzbl 0x2(%rbx), %ecx
movl %ecx, %eax
shrl $0x3, %eax
andl $0x7, %ecx
cmpl $0x1, %ecx
sbbl $-0x1, %eax
movzwl (%rbx), %ecx
cmpl $0x2, %ecx
je 0x1c608
cmpl $0x1, %ecx
jne 0x1c619
cmpl $0x4, %eax
jbe 0x1c60d
jmp 0x1c619
cmpl $0x10, %eax
ja 0x1c619
movl 0x8(%rsp), %ecx
subl 0xc(%rsp), %ecx
cmpl %eax, %ecx
jge 0x1c62a
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
testl %eax, %eax
je 0x1c61b
movl %eax, %r15d
xorl %r12d, %r12d
movq %rsp, %r14
movq %r14, %rdi
movl $0x1, %esi
callq 0x1dd7b
movb %al, 0x4(%rbx,%r12)
incq %r12
cmpq %r12, %r15
jne 0x1c637
jmp 0x1c61b
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_read_cstring
static int ns_read_cstring(stream_t *dst, stream_t *s)
{
	int spos = s->pos, dpos = dst->pos, len;

#define do_return(r) \
	s->pos = spos; \
	dst->pos = dpos; \
	return (r);

#define check_len(n) \
	if (stream_rsize(s) < (n)) { \
		loge("truncated stream\n"); \
		do_return(-1); \
	}

	check_len(1);
	len = stream_readi8(s);

	check_len(len);
	if (stream_writess(dst, s, len) != len) {
		loge("write stream\n");
		do_return(-1);
	}

	if (stream_writei8(dst, 0) != 1) {
		loge("write stream\n");
		do_return(-1);
	}

	stream_seek(dst, -1, SEEK_CUR);


#undef check_len
#undef do_return

	return dst->pos - dpos;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movl 0xc(%rsi), %r12d
movl 0xc(%rdi), %r15d
cmpl %r12d, 0x8(%rsi)
jle 0x1cfc5
movq %r14, %rdi
movl $0x1, %esi
callq 0x1dd7b
movl %eax, %ebp
movl 0x8(%r14), %eax
subl 0xc(%r14), %eax
cmpl %ebp, %eax
jge 0x1d00d
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x1cff7
leaq 0x7c29(%rip), %rsi      # 0x24bd4
leaq 0x7fce(%rip), %rdx      # 0x24f80
leaq 0x7c84(%rip), %r8       # 0x24c3d
movl $0x3, %edi
movl $0x251, %ecx            # imm = 0x251
jmp 0x1cff0
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x1cff7
leaq 0x7bfc(%rip), %rsi      # 0x24bd4
leaq 0x7fa1(%rip), %rdx      # 0x24f80
leaq 0x7c57(%rip), %r8       # 0x24c3d
movl $0x3, %edi
movl $0x24e, %ecx            # imm = 0x24E
xorl %eax, %eax
callq 0x17d92
movl %r12d, 0xc(%r14)
movl %r15d, 0xc(%rbx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x1d878
cmpl %ebp, %eax
jne 0x1d04c
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x1d916
cmpl $0x1, %eax
jne 0x1d07c
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0x1d619
movl 0xc(%rbx), %eax
subl %r15d, %eax
jmp 0x1d004
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x1cff7
leaq 0x7b75(%rip), %rsi      # 0x24bd4
leaq 0x7f1a(%rip), %rdx      # 0x24f80
leaq 0x7f05(%rip), %r8       # 0x24f72
movl $0x3, %edi
movl $0x253, %ecx            # imm = 0x253
jmp 0x1cff0
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x1cff7
leaq 0x7b41(%rip), %rsi      # 0x24bd4
leaq 0x7ee6(%rip), %rdx      # 0x24f80
leaq 0x7ed1(%rip), %r8       # 0x24f72
movl $0x3, %edi
movl $0x258, %ecx            # imm = 0x258
jmp 0x1cff0
// File: /workspace/github_c_makefile_star2_O1/GangZhuo[P]dohclient/src/ns_msg.c
// Function: free_label_childs
static void free_label_childs(label_t *label)
{
	label_t *child = label->childs, *tmp;
	while (child) {
		tmp = child;
		child = child->next;
		free_label_childs(tmp);
		free(tmp);
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x20(%rdi), %rbx
testq %rbx, %rbx
je 0x1d0d9
movq 0x28(%rbx), %r14
movq %rbx, %rdi
callq 0x1d0b0
movq %rbx, %rdi
callq 0x3450
movq %r14, %rbx
testq %r14, %r14
jne 0x1d0bd
addq $0x8, %rsp
popq %rbx
popq %r14
retq