// File: /workspace/github_c_makefile_star2_O1/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 0x208c7
cmpw $0x0, 0x4(%rbp)
je 0x208c7
movl %r8d, %r14d
movq %rdi, %r13
movl %ecx, 0x4(%rsp)
movq 0x10(%rbp), %rdi
testq %rdi, %rdi
je 0x208eb
callq 0x1a29d
movq %rax, %r15
jmp 0x208ee
testq %rbp, %rbp
je 0x208dc
movq %rbp, %rdi
callq 0x1a1dd
movq %rbp, %rdi
callq 0x3450
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
leaq 0xcdfb(%rip), %rdi      # 0x2d6f0
movq %r15, %rsi
callq 0x390c
movq %rax, %r12
leaq -0x10(%rax), %rbx
xorl %eax, %eax
callq 0x17d59
movl (%rax), %eax
testq %r12, %r12
cmoveq %r12, %rbx
je 0x20979
cmpl $0x6, %eax
jl 0x209bc
movq %rbp, %rdi
callq 0x1a4f0
movq %rax, 0x8(%rsp)
movq (%r13), %r13
xorl %eax, %eax
callq 0x19a24
movq %rax, %r10
subq 0x8(%rbx), %r10
subq $0x8, %rsp
leaq 0x4a49(%rip), %rsi      # 0x25392
leaq 0x2797(%rip), %rdx      # 0x230e7
leaq 0x5915(%rip), %r8       # 0x2626c
movl $0x6, %edi
movl $0x1f6, %ecx            # imm = 0x1F6
movq %r15, %r9
xorl %eax, %eax
pushq %r10
pushq %r13
pushq 0x20(%rsp)
callq 0x17d92
addq $0x20, %rsp
jmp 0x209bc
cmpl $0x6, %eax
jl 0x209bc
movq %rbp, %rdi
callq 0x1a4f0
movq %rax, %r10
leaq 0x4a02(%rip), %rsi      # 0x25392
leaq 0x2750(%rip), %rdx      # 0x230e7
leaq 0x58ed(%rip), %r8       # 0x2628b
movl $0x6, %edi
movl $0x1f9, %ecx            # imm = 0x1F9
movq %r15, %r9
xorl %eax, %eax
pushq (%r13)
pushq %r10
callq 0x17d92
addq $0x10, %rsp
xorl %eax, %eax
callq 0x17d59
cmpl $0x8, (%rax)
jl 0x209d0
movq %rbp, %rdi
callq 0x1c653
cmpl $0x0, 0x4(%rsp)
setne %al
testl %r14d, %r14d
sete %cl
orb %al, %cl
jne 0x209fc
xorl %ecx, %ecx
testq %r12, %r12
setne %cl
movq 0xdb8f(%rip), %rdi      # 0x2e580
movq %r15, %rsi
movq %rbp, %rdx
callq 0x8b29
testq %r12, %r12
je 0x20bf8
movq %rbx, %r14
movq 0x38(%rbx), %rbx
addq $0x38, %r14
movq %rbp, 0x18(%rsp)
movq %r14, 0x10(%rsp)
cmpq %r14, %rbx
je 0x20bf8
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 0x20acc
movq -0x60(%r15), %r14
leaq 0x20(%r14), %r12
movl 0x28(%r14), %r13d
movl 0x2c(%r14), %ebx
movl %r13d, 0x2c(%r14)
movq %r12, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1d916
movq %r12, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x1bdbb
testl %eax, %eax
jle 0x20b5c
movq %r12, %rdi
movl %r13d, %esi
movl %eax, %edx
movl $0x2, %ecx
callq 0x1da17
movl %ebx, 0x2c(%r14)
xorl %eax, %eax
callq 0x17d59
cmpl $0x8, (%rax)
jl 0x20abc
xorl %eax, %eax
callq 0x17d59
cmpl $0x7, (%rax)
jl 0x20abc
movslq 0x2c(%r14), %rdi
movl 0x28(%r14), %esi
subl %edi, %esi
addq 0x20(%r14), %rdi
callq 0x1ddbd
movl (%r14), %edi
movq %r12, %rsi
callq 0x19402
jmp 0x20b96
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 0x1bdbb
testl %eax, %eax
jle 0x20ba2
movl $0x0, 0x2c(%rsp)
xorl %eax, %eax
callq 0x17d59
cmpl $0x8, (%rax)
jl 0x20b2e
xorl %eax, %eax
callq 0x17d59
cmpl $0x7, (%rax)
jl 0x20b2e
movq 0x20(%rsp), %rdi
movl 0x28(%rsp), %esi
callq 0x1ddbd
leaq (%rbx,%rbx,8), %rax
shlq $0x4, %rax
leaq 0xda63(%rip), %rcx      # 0x2e5a0
movl 0x8c(%rax,%rcx), %edi
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
movl %r13d, %ecx
callq 0x19623
movq %rbx, %rdi
jmp 0x20bd9
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x20b8e
movl $0x3, %edi
leaq 0x481e(%rip), %rsi      # 0x25392
leaq 0x572b(%rip), %rdx      # 0x262a6
movl $0x16d, %ecx            # imm = 0x16D
leaq 0x1c05(%rip), %r8       # 0x2278c
xorl %eax, %eax
callq 0x17d92
movl %ebx, 0x2c(%r14)
movl %r13d, 0x28(%r14)
movq 0x18(%rsp), %rbp
movq 0x10(%rsp), %r14
jmp 0x20bde
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x20bd4
movl $0x3, %edi
leaq 0x47d8(%rip), %rsi      # 0x25392
leaq 0x56e5(%rip), %rdx      # 0x262a6
movl $0x186, %ecx            # imm = 0x186
leaq 0x1bbf(%rip), %r8       # 0x2278c
xorl %eax, %eax
callq 0x17d92
leaq 0x20(%rsp), %rdi
callq 0x1d5f9
movq 0x8(%rsp), %rbx
addq $-0x78, %r15
movq %r15, %rdi
callq 0x20c08
cmpq %r14, %rbx
jne 0x20a1a
cmpl $0x0, 0x4(%rsp)
jne 0x208dc
jmp 0x208cc