// File: /workspace/github_c_makefile_star2_O2/GangZhuo[P]dohclient/src/channel_doh.c
// Function: doh_query
static int doh_query(channel_req_t* rq)
{
	channel_doh_t* c = rq->ctx;
	int r = 0;

	if (c->ecs) {
		if (rq->qr.qtype == NS_QTYPE_AAAA) {
			if (c->china_net6.is_set) {
				r = doh_http_query(rq, &c->china_net6);
				if (r) {
					loge("doh_http_query() error\n");
					return -1;
				}
				rq->wait_num++;
			}
			/* Just query once when no chnroute */
			if (c->foreign_net6.is_set && (rq->wait_num == 0 || c->chnr)) {
				r = doh_http_query(rq, &c->foreign_net6);
				if (r) {
					loge("doh_http_query() error\n");
					return -1;
				}
				rq->wait_num++;
			}
		}
		else if (rq->qr.qtype == NS_QTYPE_A) {
			if (c->china_net.is_set) {
				r = doh_http_query(rq, &c->china_net);
				if (r) {
					loge("doh_http_query() error\n");
					return -1;
				}
				rq->wait_num++;
			}
			/* Just query once when no chnroute */
			if (c->foreign_net.is_set && (rq->wait_num == 0 || c->chnr)) {
				r = doh_http_query(rq, &c->foreign_net);
				if (r) {
					loge("doh_http_query() error\n");
					return -1;
				}
				rq->wait_num++;
			}
		}
	}

	if (rq->wait_num == 0) {
		r = doh_http_query(rq, NULL);
		if (r) {
			loge("doh_http_query() error\n");
			return -1;
		}
		rq->wait_num++;
	}

	return r;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x60(%rdi), %rbx
cmpl $0x0, 0x138(%rbx)
je 0xcc5a
movzwl 0x10(%r14), %eax
cmpl $0x1, %eax
je 0xcb2a
cmpl $0x1c, %eax
jne 0xcc5a
cmpl $0x0, 0x270(%rbx)
je 0xcb87
leaq 0x270(%rbx), %rsi
movq %r14, %rdi
callq 0xcd07
testl %eax, %eax
je 0xcb83
xorl %eax, %eax
callq 0x165f5
pushq $-0x1
popq %rbx
cmpl $0x3, (%rax)
jl 0xccac
leaq 0x144fa(%rip), %rsi     # 0x21009
leaq 0x141c9(%rip), %rdx     # 0x20cdf
leaq 0x145dc(%rip), %r8      # 0x210f9
pushq $0x3
popq %rdi
movl $0x316, %ecx            # imm = 0x316
jmp 0xcc9f
cmpl $0x0, 0x140(%rbx)
je 0xcbf9
leaq 0x140(%rbx), %rsi
movq %r14, %rdi
callq 0xcd07
testl %eax, %eax
je 0xcbf5
xorl %eax, %eax
callq 0x165f5
pushq $-0x1
popq %rbx
cmpl $0x3, (%rax)
jl 0xccac
leaq 0x144a1(%rip), %rsi     # 0x21009
leaq 0x14170(%rip), %rdx     # 0x20cdf
leaq 0x14583(%rip), %r8      # 0x210f9
pushq $0x3
popq %rdi
movl $0x329, %ecx            # imm = 0x329
jmp 0xcc9f
incl 0x74(%r14)
cmpl $0x0, 0x308(%rbx)
je 0xcc5a
cmpl $0x0, 0x74(%r14)
je 0xcba6
cmpq $0x0, 0x20(%rbx)
je 0xcc5a
addq $0x308, %rbx            # imm = 0x308
movq %r14, %rdi
movq %rbx, %rsi
callq 0xcd07
testl %eax, %eax
je 0xcc54
xorl %eax, %eax
callq 0x165f5
pushq $-0x1
popq %rbx
cmpl $0x3, (%rax)
jl 0xccac
leaq 0x1442f(%rip), %rsi     # 0x21009
leaq 0x140fe(%rip), %rdx     # 0x20cdf
leaq 0x14511(%rip), %r8      # 0x210f9
pushq $0x3
popq %rdi
movl $0x31f, %ecx            # imm = 0x31F
jmp 0xcc9f
incl 0x74(%r14)
cmpl $0x0, 0x1d8(%rbx)
je 0xcc5a
cmpl $0x0, 0x74(%r14)
je 0xcc10
cmpq $0x0, 0x20(%rbx)
je 0xcc5a
addq $0x1d8, %rbx            # imm = 0x1D8
movq %r14, %rdi
movq %rbx, %rsi
callq 0xcd07
testl %eax, %eax
je 0xcc54
xorl %eax, %eax
callq 0x165f5
pushq $-0x1
popq %rbx
cmpl $0x3, (%rax)
jl 0xccac
leaq 0x143cd(%rip), %rsi     # 0x21009
leaq 0x1409c(%rip), %rdx     # 0x20cdf
leaq 0x144af(%rip), %r8      # 0x210f9
pushq $0x3
popq %rdi
movl $0x332, %ecx            # imm = 0x332
jmp 0xcc9f
leaq 0x74(%r14), %rax
incl (%rax)
xorl %ebx, %ebx
cmpl $0x0, 0x74(%r14)
jne 0xccac
xorl %ebx, %ebx
movq %r14, %rdi
xorl %esi, %esi
callq 0xcd07
testl %eax, %eax
je 0xcca8
xorl %eax, %eax
callq 0x165f5
pushq $-0x1
popq %rbx
cmpl $0x3, (%rax)
jl 0xccac
leaq 0x14380(%rip), %rsi     # 0x21009
leaq 0x1404f(%rip), %rdx     # 0x20cdf
leaq 0x14462(%rip), %r8      # 0x210f9
pushq $0x3
popq %rdi
movl $0x33d, %ecx            # imm = 0x33D
xorl %eax, %eax
callq 0x1662e
jmp 0xccac
incl 0x74(%r14)
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq