// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x138(%rax)
je 0x13893
movq -0x10(%rbp), %rax
movzwl 0x10(%rax), %eax
cmpl $0x1c, %eax
jne 0x13771
movq -0x18(%rbp), %rax
cmpl $0x0, 0x270(%rax)
je 0x136da
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x270, %rsi            # imm = 0x270
callq 0x13a50
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x136cd
jmp 0x1368d
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x136bf
movl $0x3, %edi
leaq 0x22f5e(%rip), %rsi     # 0x36603
leaq 0x22c01(%rip), %rdx     # 0x362ad
movl $0x316, %ecx            # imm = 0x316
leaq 0x2303b(%rip), %r8      # 0x366f3
movb $0x0, %al
callq 0x243b0
jmp 0x136c1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13905
movq -0x10(%rbp), %rax
movl 0x74(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x74(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x308(%rax)
je 0x1376c
movq -0x10(%rbp), %rax
cmpl $0x0, 0x74(%rax)
je 0x13700
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x1376c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x308, %rsi            # imm = 0x308
callq 0x13a50
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x1375f
jmp 0x1371f
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x13751
movl $0x3, %edi
leaq 0x22ecc(%rip), %rsi     # 0x36603
leaq 0x22b6f(%rip), %rdx     # 0x362ad
movl $0x31f, %ecx            # imm = 0x31F
leaq 0x22fa9(%rip), %r8      # 0x366f3
movb $0x0, %al
callq 0x243b0
jmp 0x13753
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13905
movq -0x10(%rbp), %rax
movl 0x74(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x74(%rax)
jmp 0x13891
movq -0x10(%rbp), %rax
movzwl 0x10(%rax), %eax
cmpl $0x1, %eax
jne 0x1388f
movq -0x18(%rbp), %rax
cmpl $0x0, 0x140(%rax)
je 0x137fb
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x140, %rsi            # imm = 0x140
callq 0x13a50
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x137ee
jmp 0x137ae
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x137e0
movl $0x3, %edi
leaq 0x22e3d(%rip), %rsi     # 0x36603
leaq 0x22ae0(%rip), %rdx     # 0x362ad
movl $0x329, %ecx            # imm = 0x329
leaq 0x22f1a(%rip), %r8      # 0x366f3
movb $0x0, %al
callq 0x243b0
jmp 0x137e2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13905
movq -0x10(%rbp), %rax
movl 0x74(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x74(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x1d8(%rax)
je 0x1388d
movq -0x10(%rbp), %rax
cmpl $0x0, 0x74(%rax)
je 0x13821
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x1388d
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x1d8, %rsi            # imm = 0x1D8
callq 0x13a50
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x13880
jmp 0x13840
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x13872
movl $0x3, %edi
leaq 0x22dab(%rip), %rsi     # 0x36603
leaq 0x22a4e(%rip), %rdx     # 0x362ad
movl $0x332, %ecx            # imm = 0x332
leaq 0x22e88(%rip), %r8      # 0x366f3
movb $0x0, %al
callq 0x243b0
jmp 0x13874
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13905
movq -0x10(%rbp), %rax
movl 0x74(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x74(%rax)
jmp 0x1388f
jmp 0x13891
jmp 0x13893
movq -0x10(%rbp), %rax
cmpl $0x0, 0x74(%rax)
jne 0x138ff
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x13a50
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x138f2
jmp 0x138b5
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x138e7
movl $0x3, %edi
leaq 0x22d36(%rip), %rsi     # 0x36603
leaq 0x229d9(%rip), %rdx     # 0x362ad
movl $0x33d, %ecx            # imm = 0x33D
leaq 0x22e13(%rip), %r8      # 0x366f3
movb $0x0, %al
callq 0x243b0
jmp 0x138e9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13905
movq -0x10(%rbp), %rax
movl 0x74(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x74(%rax)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop