// File: /workspace/github_c_makefile_star2_O2/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
testl %esi, %esi
setne %al
testq %rdx, %rdx
sete %sil
orb %al, %sil
jne 0x1e8f6
cmpw $0x0, 0x4(%rdx)
je 0x1e8ff
movl %r8d, %r14d
movq %rdi, %r13
movl %ecx, 0x8(%rsp)
movq %rdx, (%rsp)
movq %rdx, %rdi
callq 0x1e80e
movq %rax, %r12
leaq 0xfe83(%rip), %rdi      # 0x2e700
movq %rax, %rsi
callq 0x38ef
movq %rax, %r15
xorl %eax, %eax
callq 0x165f5
movl (%rax), %eax
testq %r15, %r15
je 0x1e920
cmpl $0x6, %eax
jl 0x1e960
movq (%rsp), %rdi
callq 0x18bcb
movq %rax, %rbp
movq (%r13), %rbx
xorl %eax, %eax
callq 0x181bb
movq %rax, %r10
subq -0x8(%r15), %r10
subq $0x8, %rsp
leaq 0x4af6(%rip), %rsi      # 0x233c2
leaq 0x281c(%rip), %rdx      # 0x210ef
leaq 0x59c2(%rip), %r8       # 0x2429c
pushq $0x6
popq %rdi
movl $0x1f6, %ecx            # imm = 0x1F6
movq %r12, %r9
xorl %eax, %eax
pushq %r10
pushq %rbx
pushq %rbp
callq 0x1662e
addq $0x20, %rsp
jmp 0x1e960
testq %rdx, %rdx
je 0x1ebc4
movq %rdx, %rdi
movq %rdx, %rbx
callq 0x188ce
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3460
cmpl $0x6, %eax
jl 0x1e960
movq (%rsp), %rdi
callq 0x18bcb
movq %rax, %r10
leaq 0x4a8a(%rip), %rsi      # 0x233c2
leaq 0x27b0(%rip), %rdx      # 0x210ef
leaq 0x5975(%rip), %r8       # 0x242bb
pushq $0x6
popq %rdi
movl $0x1f9, %ecx            # imm = 0x1F9
movq %r12, %r9
xorl %eax, %eax
pushq (%r13)
pushq %r10
callq 0x1662e
popq %rax
popq %rcx
xorl %eax, %eax
callq 0x165f5
cmpl $0x8, (%rax)
jl 0x1e975
movq (%rsp), %rdi
callq 0x1aa39
movl 0x8(%rsp), %edx
testl %edx, %edx
setne %al
testl %r14d, %r14d
sete %cl
orb %al, %cl
movq (%rsp), %rcx
jne 0x1e9af
xorl %ecx, %ecx
testq %r15, %r15
setne %cl
movq 0x10bf5(%rip), %rdi     # 0x2f590
movq %r12, %rsi
movq (%rsp), %rdx
callq 0x846f
movl 0x8(%rsp), %edx
movq (%rsp), %rcx
testq %r15, %r15
je 0x1ebc0
movq %r15, %r14
addq $0x28, %r14
movq 0x28(%r15), %r12
pushq $0x2
popq %rdx
movq %r14, 0x10(%rsp)
cmpq %r14, %r12
je 0x1eba4
movq %r12, %r13
movq (%r12), %r12
movq -0x70(%r13), %rax
movzwl (%rax), %eax
movw %ax, (%rcx)
cmpl $0x0, -0x54(%r13)
je 0x1ea7e
movq %r12, 0x18(%rsp)
movq -0x60(%r13), %rbx
leaq 0x20(%rbx), %r15
movl 0x28(%rbx), %ebp
movl 0x2c(%rbx), %eax
movl %eax, 0xc(%rsp)
movl %ebp, 0x2c(%rbx)
movq %r15, %rdi
xorl %esi, %esi
movq %rcx, %r12
movl %edx, %r14d
callq 0x1bbcd
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x1a2cd
testl %eax, %eax
jle 0x1eb06
movq %r15, %rdi
movl %ebp, %esi
movl %eax, %edx
movl %r14d, %ecx
callq 0x1bcd8
movl 0xc(%rsp), %eax
movl %eax, 0x2c(%rbx)
xorl %eax, %eax
callq 0x165f5
cmpl $0x8, (%rax)
jl 0x1ea6f
xorl %eax, %eax
callq 0x165f5
cmpl $0x7, (%rax)
jl 0x1ea6f
movslq 0x2c(%rbx), %rdi
movl 0x28(%rbx), %esi
subl %edi, %esi
addq 0x20(%rbx), %rdi
callq 0x1bfda
movl (%rbx), %edi
movq %r15, %rsi
callq 0x17be2
jmp 0x1eb42
andq $0x0, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq -0x60(%r13), %r15
movl -0x58(%r13), %ebp
movslq -0x68(%r13), %rbx
leaq 0x20(%rsp), %rdi
movq %rcx, %rsi
xorl %edx, %edx
callq 0x1a2cd
testl %eax, %eax
jle 0x1eb4e
andl $0x0, 0x2c(%rsp)
xorl %eax, %eax
callq 0x165f5
cmpl $0x8, (%rax)
jl 0x1eada
xorl %eax, %eax
callq 0x165f5
cmpl $0x7, (%rax)
jl 0x1eada
movq 0x20(%rsp), %rdi
movl 0x28(%rsp), %esi
callq 0x1bfda
imulq $0x90, %rbx, %rax
leaq 0x10ac8(%rip), %rcx     # 0x2f5b0
movl 0x8c(%rax,%rcx), %edi
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
movq %r15, %rdx
movl %ebp, %ecx
callq 0x17deb
movq %rbx, %rdi
jmp 0x1eb83
movl 0xc(%rsp), %r14d
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0x1eb3b
pushq $0x3
popq %rdi
leaq 0x48a1(%rip), %rsi      # 0x233c2
leaq 0x57ae(%rip), %rdx      # 0x242d6
movl $0x16d, %ecx            # imm = 0x16D
leaq 0x1c38(%rip), %r8       # 0x2076c
xorl %eax, %eax
callq 0x1662e
movl %r14d, 0x2c(%rbx)
movl %ebp, 0x28(%rbx)
movq 0x10(%rsp), %r14
movq 0x18(%rsp), %r12
jmp 0x1eb88
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0x1eb7e
pushq $0x3
popq %rdi
leaq 0x485e(%rip), %rsi      # 0x233c2
leaq 0x576b(%rip), %rdx      # 0x242d6
movl $0x186, %ecx            # imm = 0x186
leaq 0x1bf5(%rip), %r8       # 0x2076c
xorl %eax, %eax
callq 0x1662e
leaq 0x20(%rsp), %rdi
callq 0x1b8a6
addq $-0x78, %r13
movq %r13, %rdi
callq 0x1ebde
cmpq %r14, %r12
movq (%rsp), %rcx
pushq $0x2
popq %rdx
jne 0x1e9cb
cmpl $0x0, 0x8(%rsp)
jne 0x1ebc4
movq %rcx, %rdi
movq %rcx, %rbx
callq 0x188ce
movq %rbx, %rdi
callq 0x3460
jmp 0x1ebc4
testl %edx, %edx
je 0x1ebd3
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, %rdi
movq %rcx, %rbx
jmp 0x1e905