// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/main.c
// Function: query_cb
static int _query_cb(channel_t* ctx,
	int status,
	ns_msg_t* result,
	int fromcache,
	int trust,
	void* state)
{
	const char* key;
	rbn_t* rbn;
	dlitem_t* cur, * nxt;
	req_t* req;
	int is_last_one;
	int is_add_cache = FALSE;

	/* ignore failed result */
	if (status || !result || result->qdcount < 1) {
		if (result) {
			ns_msg_free(result);
			free(result);
		}
		return 0;
	}

	key = msg_key(result);

	rbn = reqdic_find(key);

	if (rbn) {
		logi("answer: %s - %s - %s (%lu ms)\n", key, msg_answers(result),
				ctx->name, OS_GetTickCount() - rbn->ctime);
	}
	else {
		logi("drop answer: %s - %s - %s\n", key, msg_answers(result), ctx->name);
	}

	if (loglevel > LOG_DEBUG) {
		ns_print(result);
	}

	if (result && !fromcache && trust) {
		if (cache_add(cache, key, result, rbn ? TRUE : FALSE) == 0) {
			is_add_cache = TRUE;
		}
	}

	if (!rbn) {
		if (result && !fromcache) {
			ns_msg_free(result);
			free(result);
		}
		return 0;
	}

	dllist_foreach(&rbn->reqs, cur, nxt,
		req_t, req, entry_rbn) {
		is_last_one = dllist_is_end(&rbn->reqs, nxt);

		req_send_result(req, result);

		req_remove(req);
		/* after removed the last one, rbn should be destroyed,
		so we break the loop, otherwise may access a NULL point. */
		if (is_last_one)
			break;
	}

	if (result && !fromcache) {
		ns_msg_free(result);
		free(result);
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %rbp
testl %esi, %esi
setne %al
testq %rdx, %rdx
sete %dl
orb %al, %dl
jne 0x200ed
cmpw $0x0, 0x4(%rbp)
je 0x200f6
movl %r8d, %r14d
movq %rdi, %r13
movl %ecx, 0x4(%rsp)
movq 0x10(%rbp), %rdi
testq %rdi, %rdi
je 0x20114
callq 0x19ba4
movq %rax, %r15
jmp 0x20117
testq %rbp, %rbp
je 0x2043c
movq %rbp, %rdi
callq 0x19ae0
movq %rbp, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3450
xorl %r15d, %r15d
leaq 0xd5d2(%rip), %rdi      # 0x2d6f0
movq %r15, %rsi
callq 0x39f8
movq %rax, %r12
xorl %eax, %eax
callq 0x176e5
movl (%rax), %eax
testq %r12, %r12
je 0x2019a
cmpl $0x6, %eax
jl 0x201dd
movq %rbp, %rdi
callq 0x19df7
movq %rax, 0x8(%rsp)
movq (%r13), %rbx
xorl %eax, %eax
callq 0x193ab
movq %rax, %r10
subq -0x8(%r12), %r10
subq $0x8, %rsp
leaq 0x5269(%rip), %rsi      # 0x253d4
leaq 0x2f7d(%rip), %rdx      # 0x230ef
leaq 0x6135(%rip), %r8       # 0x262ae
movl $0x6, %edi
movl $0x1f6, %ecx            # imm = 0x1F6
movq %r15, %r9
xorl %eax, %eax
pushq %r10
pushq %rbx
pushq 0x20(%rsp)
callq 0x1771e
addq $0x20, %rsp
jmp 0x201dd
cmpl $0x6, %eax
jl 0x201dd
movq %rbp, %rdi
callq 0x19df7
movq %rax, %r10
leaq 0x5223(%rip), %rsi      # 0x253d4
leaq 0x2f37(%rip), %rdx      # 0x230ef
leaq 0x610e(%rip), %r8       # 0x262cd
movl $0x6, %edi
movl $0x1f9, %ecx            # imm = 0x1F9
movq %r15, %r9
xorl %eax, %eax
pushq (%r13)
pushq %r10
callq 0x1771e
addq $0x10, %rsp
xorl %eax, %eax
callq 0x176e5
cmpl $0x8, (%rax)
jl 0x201f1
movq %rbp, %rdi
callq 0x1bd90
cmpl $0x0, 0x4(%rsp)
setne %al
testl %r14d, %r14d
sete %cl
orb %al, %cl
jne 0x2021d
xorl %ecx, %ecx
testq %r12, %r12
setne %cl
movq 0xe36e(%rip), %rdi      # 0x2e580
movq %r15, %rsi
movq %rbp, %rdx
callq 0x8810
testq %r12, %r12
je 0x20431
movq %r12, %r14
addq $0x28, %r14
movq 0x28(%r12), %rbx
movq %rbp, 0x18(%rsp)
movq %r14, 0x10(%rsp)
cmpq %r14, %rbx
je 0x20418
movq %rbx, %r15
movq (%rbx), %rax
movq %rax, 0x8(%rsp)
movq -0x70(%rbx), %rax
movzwl (%rax), %eax
movw %ax, (%rbp)
cmpl $0x0, -0x54(%rbx)
je 0x202ec
movq -0x60(%r15), %rbx
leaq 0x20(%rbx), %r12
movl 0x28(%rbx), %r13d
movl 0x2c(%rbx), %r14d
movl %r13d, 0x2c(%rbx)
movq %r12, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1d115
movq %r12, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x1b58c
testl %eax, %eax
jle 0x2037c
movq %r12, %rdi
movl %r13d, %esi
movl %eax, %edx
movl $0x2, %ecx
callq 0x1d224
movl %r14d, 0x2c(%rbx)
xorl %eax, %eax
callq 0x176e5
cmpl $0x8, (%rax)
jl 0x202dd
xorl %eax, %eax
callq 0x176e5
cmpl $0x7, (%rax)
jl 0x202dd
movslq 0x2c(%rbx), %rdi
movl 0x28(%rbx), %esi
subl %edi, %esi
addq 0x20(%rbx), %rdi
callq 0x1d5ca
movl (%rbx), %edi
movq %r12, %rsi
callq 0x18d8e
jmp 0x203b6
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq -0x60(%r15), %r12
movl -0x58(%r15), %r13d
movslq -0x68(%r15), %rbx
leaq 0x20(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x1b58c
testl %eax, %eax
jle 0x203c2
movl $0x0, 0x2c(%rsp)
xorl %eax, %eax
callq 0x176e5
cmpl $0x8, (%rax)
jl 0x2034e
xorl %eax, %eax
callq 0x176e5
cmpl $0x7, (%rax)
jl 0x2034e
movq 0x20(%rsp), %rdi
movl 0x28(%rsp), %esi
callq 0x1d5ca
leaq (%rbx,%rbx,8), %rax
shlq $0x4, %rax
leaq 0xe243(%rip), %rcx      # 0x2e5a0
movl 0x8c(%rax,%rcx), %edi
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
movl %r13d, %ecx
callq 0x18faf
movq %rbx, %rdi
jmp 0x203f9
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x203ae
movl $0x3, %edi
leaq 0x5040(%rip), %rsi      # 0x253d4
leaq 0x5f4d(%rip), %rdx      # 0x262e8
movl $0x16d, %ecx            # imm = 0x16D
leaq 0x23c5(%rip), %r8       # 0x2276c
xorl %eax, %eax
callq 0x1771e
movl %r14d, 0x2c(%rbx)
movl %r13d, 0x28(%rbx)
movq 0x18(%rsp), %rbp
movq 0x10(%rsp), %r14
jmp 0x203fe
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x203f4
movl $0x3, %edi
leaq 0x4ffa(%rip), %rsi      # 0x253d4
leaq 0x5f07(%rip), %rdx      # 0x262e8
movl $0x186, %ecx            # imm = 0x186
leaq 0x237f(%rip), %r8       # 0x2276c
xorl %eax, %eax
callq 0x1771e
leaq 0x20(%rsp), %rdi
callq 0x1cdc9
movq 0x8(%rsp), %rbx
addq $-0x78, %r15
movq %r15, %rdi
callq 0x2044b
cmpq %r14, %rbx
jne 0x2023c
cmpl $0x0, 0x4(%rsp)
jne 0x2043c
movq %rbp, %rdi
callq 0x19ae0
movq %rbp, %rdi
callq 0x3450
jmp 0x2043c
cmpl $0x0, 0x4(%rsp)
je 0x200f6
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq