// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/channel_chndoh.c
// Function: doh_channel_query
static int doh_channel_query(channel_req_t* rq, doh_server_t* doh,
	ns_msg_t *msg, int use_proxy, subnet_t* subnet)
{
	channel_chndoh_t* c = rq->ctx;
	http_request_t* req;
	int r;

	if (subnet) {
		ns_rr_t* rr;
		rr = ns_find_opt_rr(msg);
		if (rr == NULL) {
			rr = ns_add_optrr(msg);
			if (rr == NULL) {
				loge("Can't add option record to ns_msg_t\n");
				return -1;
			}
		}

		rr->cls = NS_PAYLOAD_SIZE; /* reset edns payload size */

		if (ns_optrr_set_ecs(rr, (struct sockaddr*)&subnet->addr, subnet->mask, 0) != 0) {
			loge("Can't add ecs option\n");
			return -1;
		}
	}

	req = doh->post
		? doh_build_post_request(rq, doh, msg)
		: doh_build_get_request(rq, doh, msg);

	if (!req) {
		loge("%s error\n",
			doh->post
			? "doh_build_post_request()"
			: "doh_build_get_request()");
		return -1;
	}

	r = http_send(doh->http, doh->addr, use_proxy, req, doh->timeout, http_cb, rq);
	if (r) {
		loge("http_send() error\n");
		free(http_request_get_data(req, NULL));
		http_request_destroy(req);
		return -1;
	}

	return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x10d23
movq -0x20(%rbp), %rdi
movl $0x29, %esi
callq 0x29010
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x10cb3
movq -0x20(%rbp), %rdi
callq 0x29220
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x10cb1
jmp 0x10c71
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x10ca3
movl $0x3, %edi
leaq 0x252f5(%rip), %rsi     # 0x35f7e
leaq 0x2578a(%rip), %rdx     # 0x3641a
movl $0x387, %ecx            # imm = 0x387
leaq 0x25790(%rip), %r8      # 0x3642c
movb $0x0, %al
callq 0x243b0
jmp 0x10ca5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x10e71
jmp 0x10cb3
movq -0x50(%rbp), %rax
movw $0x400, 0xa(%rax)       # imm = 0x400
movq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x10, %rsi
movq -0x30(%rbp), %rax
movl 0x90(%rax), %edx
xorl %ecx, %ecx
callq 0x29e00
cmpl $0x0, %eax
je 0x10d21
jmp 0x10ce1
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x10d13
movl $0x3, %edi
leaq 0x25285(%rip), %rsi     # 0x35f7e
leaq 0x2571a(%rip), %rdx     # 0x3641a
movl $0x38f, %ecx            # imm = 0x38F
leaq 0x25745(%rip), %r8      # 0x36451
movb $0x0, %al
callq 0x243b0
jmp 0x10d15
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x10e71
jmp 0x10d23
movq -0x18(%rbp), %rax
cmpl $0x0, 0x44c(%rax)
je 0x10d47
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x11760
movq %rax, -0x58(%rbp)
jmp 0x10d5c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x119b0
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x10dcc
jmp 0x10d6d
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x10dbe
movq -0x18(%rbp), %rax
movl 0x44c(%rax), %ecx
leaq 0x25700(%rip), %r9      # 0x3648a
leaq 0x256e0(%rip), %rax     # 0x36471
cmpl $0x0, %ecx
cmovneq %rax, %r9
movl $0x3, %edi
leaq 0x251da(%rip), %rsi     # 0x35f7e
leaq 0x2566f(%rip), %rdx     # 0x3641a
movl $0x39c, %ecx            # imm = 0x39C
leaq 0x256b0(%rip), %r8      # 0x36467
movb $0x0, %al
callq 0x243b0
jmp 0x10dc0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x10e71
movq -0x18(%rbp), %rax
movq 0x5b8(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x8, %rsi
movl -0x24(%rbp), %edx
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movl 0x47c(%rax), %r8d
movq -0x10(%rbp), %rax
leaq 0xef4(%rip), %r9        # 0x11cf0
movq %rax, (%rsp)
callq 0x20000
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x10e6b
jmp 0x10e10
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x10e42
movl $0x3, %edi
leaq 0x25156(%rip), %rsi     # 0x35f7e
leaq 0x255eb(%rip), %rdx     # 0x3641a
movl $0x3a2, %ecx            # imm = 0x3A2
leaq 0x25667(%rip), %r8      # 0x364a2
movb $0x0, %al
callq 0x243b0
jmp 0x10e44
movq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1ea10
movq %rax, %rdi
callq 0x3460
movq -0x40(%rbp), %rdi
callq 0x1e4b0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x10e71
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)