// File: /workspace/github_c_makefile_star2_O1/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 0xd6dd
movzwl 0x10(%r14), %eax
cmpl $0x1, %eax
je 0xd5a1
cmpl $0x1c, %eax
jne 0xd6dd
cmpl $0x0, 0x270(%rbx)
je 0xd602
leaq 0x270(%rbx), %rsi
movq %r14, %rdi
callq 0xd796
testl %eax, %eax
je 0xd5fe
xorl %eax, %eax
callq 0x17d59
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0xd733
leaq 0x15a7d(%rip), %rsi     # 0x23001
leaq 0x1574c(%rip), %rdx     # 0x22cd7
leaq 0x15b5f(%rip), %r8      # 0x230f1
movl $0x3, %edi
movl $0x316, %ecx            # imm = 0x316
jmp 0xd726
cmpl $0x0, 0x140(%rbx)
je 0xd678
leaq 0x140(%rbx), %rsi
movq %r14, %rdi
callq 0xd796
testl %eax, %eax
je 0xd674
xorl %eax, %eax
callq 0x17d59
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0xd733
leaq 0x15a20(%rip), %rsi     # 0x23001
leaq 0x156ef(%rip), %rdx     # 0x22cd7
leaq 0x15b02(%rip), %r8      # 0x230f1
movl $0x3, %edi
movl $0x329, %ecx            # imm = 0x329
jmp 0xd726
incl 0x74(%r14)
cmpl $0x0, 0x308(%rbx)
je 0xd6dd
cmpl $0x0, 0x74(%r14)
je 0xd621
cmpq $0x0, 0x20(%rbx)
je 0xd6dd
addq $0x308, %rbx            # imm = 0x308
movq %r14, %rdi
movq %rbx, %rsi
callq 0xd796
testl %eax, %eax
je 0xd6d7
xorl %eax, %eax
callq 0x17d59
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0xd733
leaq 0x159aa(%rip), %rsi     # 0x23001
leaq 0x15679(%rip), %rdx     # 0x22cd7
leaq 0x15a8c(%rip), %r8      # 0x230f1
movl $0x3, %edi
movl $0x31f, %ecx            # imm = 0x31F
jmp 0xd726
incl 0x74(%r14)
cmpl $0x0, 0x1d8(%rbx)
je 0xd6dd
cmpl $0x0, 0x74(%r14)
je 0xd68f
cmpq $0x0, 0x20(%rbx)
je 0xd6dd
addq $0x1d8, %rbx            # imm = 0x1D8
movq %r14, %rdi
movq %rbx, %rsi
callq 0xd796
testl %eax, %eax
je 0xd6d7
xorl %eax, %eax
callq 0x17d59
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0xd733
leaq 0x15944(%rip), %rsi     # 0x23001
leaq 0x15613(%rip), %rdx     # 0x22cd7
leaq 0x15a26(%rip), %r8      # 0x230f1
movl $0x3, %edi
movl $0x332, %ecx            # imm = 0x332
jmp 0xd726
leaq 0x74(%r14), %rax
incl (%rax)
xorl %ebx, %ebx
cmpl $0x0, 0x74(%r14)
jne 0xd733
xorl %ebx, %ebx
movq %r14, %rdi
xorl %esi, %esi
callq 0xd796
testl %eax, %eax
je 0xd72f
xorl %eax, %eax
callq 0x17d59
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, (%rax)
jl 0xd733
leaq 0x158f3(%rip), %rsi     # 0x23001
leaq 0x155c2(%rip), %rdx     # 0x22cd7
leaq 0x159d5(%rip), %r8      # 0x230f1
movl $0x3, %edi
movl $0x33d, %ecx            # imm = 0x33D
xorl %eax, %eax
callq 0x17d92
jmp 0xd733
incl 0x74(%r14)
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq