// File: /workspace/github_c_makefile_star2_O3/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 0xd2a2
movzwl 0x10(%r14), %eax
cmpl $0x1, %eax
je 0xd166
cmpl $0x1c, %eax
jne 0xd2a2
cmpl $0x0, 0x270(%rbx)
je 0xd1c7
leaq 0x270(%rbx), %rsi
movq %r14, %rdi
callq 0xd35e
testl %eax, %eax
je 0xd1c3
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0xd2f8
leaq 0x15ec0(%rip), %rsi     # 0x23009
leaq 0x15b8f(%rip), %rdx     # 0x22cdf
leaq 0x15fa2(%rip), %r8      # 0x230f9
movl $0x3, %edi
movl $0x316, %ecx            # imm = 0x316
jmp 0xd2eb
cmpl $0x0, 0x140(%rbx)
je 0xd23d
leaq 0x140(%rbx), %rsi
movq %r14, %rdi
callq 0xd35e
testl %eax, %eax
je 0xd239
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0xd2f8
leaq 0x15e63(%rip), %rsi     # 0x23009
leaq 0x15b32(%rip), %rdx     # 0x22cdf
leaq 0x15f45(%rip), %r8      # 0x230f9
movl $0x3, %edi
movl $0x329, %ecx            # imm = 0x329
jmp 0xd2eb
incl 0x74(%r14)
cmpl $0x0, 0x308(%rbx)
je 0xd2a2
cmpl $0x0, 0x74(%r14)
je 0xd1e6
cmpq $0x0, 0x20(%rbx)
je 0xd2a2
addq $0x308, %rbx            # imm = 0x308
movq %r14, %rdi
movq %rbx, %rsi
callq 0xd35e
testl %eax, %eax
je 0xd29c
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0xd2f8
leaq 0x15ded(%rip), %rsi     # 0x23009
leaq 0x15abc(%rip), %rdx     # 0x22cdf
leaq 0x15ecf(%rip), %r8      # 0x230f9
movl $0x3, %edi
movl $0x31f, %ecx            # imm = 0x31F
jmp 0xd2eb
incl 0x74(%r14)
cmpl $0x0, 0x1d8(%rbx)
je 0xd2a2
cmpl $0x0, 0x74(%r14)
je 0xd254
cmpq $0x0, 0x20(%rbx)
je 0xd2a2
addq $0x1d8, %rbx            # imm = 0x1D8
movq %r14, %rdi
movq %rbx, %rsi
callq 0xd35e
testl %eax, %eax
je 0xd29c
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0xd2f8
leaq 0x15d87(%rip), %rsi     # 0x23009
leaq 0x15a56(%rip), %rdx     # 0x22cdf
leaq 0x15e69(%rip), %r8      # 0x230f9
movl $0x3, %edi
movl $0x332, %ecx            # imm = 0x332
jmp 0xd2eb
leaq 0x74(%r14), %rax
incl (%rax)
xorl %ebx, %ebx
cmpl $0x0, 0x74(%r14)
jne 0xd2f8
xorl %ebx, %ebx
movq %r14, %rdi
xorl %esi, %esi
callq 0xd35e
testl %eax, %eax
je 0xd2f4
xorl %eax, %eax
callq 0x176e5
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0xd2f8
leaq 0x15d36(%rip), %rsi     # 0x23009
leaq 0x15a05(%rip), %rdx     # 0x22cdf
leaq 0x15e18(%rip), %r8      # 0x230f9
movl $0x3, %edi
movl $0x33d, %ecx            # imm = 0x33D
xorl %eax, %eax
callq 0x1771e
jmp 0xd2f8
incl 0x74(%r14)
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq