// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x0, -0x60(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x329e2
cmpq $0x0, -0x20(%rbp)
je 0x329e2
movq -0x20(%rbp), %rax
movzwl 0x4(%rax), %eax
cmpl $0x1, %eax
jge 0x32a07
cmpq $0x0, -0x20(%rbp)
je 0x329fb
movq -0x20(%rbp), %rdi
callq 0x27870
movq -0x20(%rbp), %rdi
callq 0x3460
movl $0x0, -0x4(%rbp)
jmp 0x32c69
movq -0x20(%rbp), %rdi
callq 0x32910
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x32c80
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x32aad
jmp 0x32a2e
movb $0x0, %al
callq 0x242d0
cmpl $0x6, (%rax)
jl 0x32aa9
movq -0x38(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x20(%rbp), %rdi
callq 0x27de0
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movb $0x0, %al
callq 0x26e40
movq -0x78(%rbp), %r9
movq -0x70(%rbp), %r11
movq -0x68(%rbp), %r10
movq -0x40(%rbp), %rcx
subq 0x8(%rcx), %rax
movl $0x6, %edi
leaq 0x6141(%rip), %rsi      # 0x38bc2
leaq 0x3c61(%rip), %rdx      # 0x366e9
movl $0x1f6, %ecx            # imm = 0x1F6
leaq 0x7008(%rip), %r8       # 0x39a9c
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x32aab
jmp 0x32b0d
jmp 0x32aaf
movb $0x0, %al
callq 0x242d0
cmpl $0x6, (%rax)
jl 0x32b09
movq -0x38(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x20(%rbp), %rdi
callq 0x27de0
movq -0x80(%rbp), %r9
movq %rax, %r10
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl $0x6, %edi
leaq 0x60dc(%rip), %rsi      # 0x38bc2
leaq 0x3bfc(%rip), %rdx      # 0x366e9
movl $0x1f9, %ecx            # imm = 0x1F9
leaq 0x6fc2(%rip), %r8       # 0x39abb
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x32b0b
jmp 0x32b0d
movb $0x0, %al
callq 0x242d0
cmpl $0x7, (%rax)
jle 0x32b22
movq -0x20(%rbp), %rdi
callq 0x2a690
cmpq $0x0, -0x20(%rbp)
je 0x32b69
cmpl $0x0, -0x24(%rbp)
jne 0x32b69
cmpl $0x0, -0x28(%rbp)
je 0x32b69
movq 0xff34(%rip), %rdi      # 0x42a70
movq -0x38(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x40(%rbp), %r8
xorl %ecx, %ecx
movl $0x1, %eax
cmpq $0x0, %r8
cmovnel %eax, %ecx
callq 0xc700
cmpl $0x0, %eax
jne 0x32b67
movl $0x1, -0x60(%rbp)
jmp 0x32b69
cmpq $0x0, -0x40(%rbp)
jne 0x32b9b
cmpq $0x0, -0x20(%rbp)
je 0x32b8f
cmpl $0x0, -0x24(%rbp)
jne 0x32b8f
movq -0x20(%rbp), %rdi
callq 0x27870
movq -0x20(%rbp), %rdi
callq 0x3460
movl $0x0, -0x4(%rbp)
jmp 0x32c69
movq -0x40(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
xorl %eax, %eax
movq %rax, %rcx
addq $0x78, %rcx
subq %rcx, %rax
addq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
addq $0x38, %rcx
cmpq %rcx, %rax
sete %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x32be0
jmp 0x32c43
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
addq $0x38, %rcx
cmpq %rcx, %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x5c(%rbp)
movq -0x58(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x32cd0
movq -0x58(%rbp), %rdi
callq 0x32f60
cmpl $0x0, -0x5c(%rbp)
je 0x32c18
jmp 0x32c43
jmp 0x32c1a
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
xorl %eax, %eax
movq %rax, %rcx
addq $0x78, %rcx
subq %rcx, %rax
addq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x32bc6
cmpq $0x0, -0x20(%rbp)
je 0x32c62
cmpl $0x0, -0x24(%rbp)
jne 0x32c62
movq -0x20(%rbp), %rdi
callq 0x27870
movq -0x20(%rbp), %rdi
callq 0x3460
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)