// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/channel_doh.c
// Function: doh_build_post_request
static http_request_t* doh_build_post_request(channel_req_t* rq, subnet_t* subnet)
{
	channel_doh_t* c = rq->ctx;
	http_request_t* req = NULL;
	ns_msg_t msg;
	int r, len;
	stream_t s = STREAM_INIT();

	init_ns_msg(&msg);

	r = build_request_nsmsg(&msg, rq);
	if (r) {
		loge("build_request_nsmsg() error\n");
		return NULL;
	}

	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");
				ns_msg_free(&msg);
				return NULL;
			}
		}

		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");
			ns_msg_free(&msg);
			return NULL;
		}
	}

	if ((len = ns_serialize(&s, &msg, 0)) <= 0) {
		loge("ns_serialize() error\n");
		stream_free(&s);
		ns_msg_free(&msg);
		return NULL;
	}

	ns_msg_free(&msg);

	req = http_request_create("POST", c->path, c->host, c->keep_alive);
	if (!req) {
		loge("http_request_create() error\n");
		stream_free(&s);
		return NULL;
	}

	r = http_request_set_header(req, "Content-Type", "application/dns-message");
	if (r) {
		loge("http_request_set_header() error\n");
		stream_free(&s);
		http_request_destroy(req);
		return NULL;
	}

	r = http_request_set_header(req, "Pragma", "no-cache");
	if (r) {
		loge("http_request_set_header() error\n");
		stream_free(&s);
		http_request_destroy(req);
		return NULL;
	}

	r = http_request_set_header(req, "Cache-Control", "no-cache");
	if (r) {
		loge("http_request_set_header() error\n");
		stream_free(&s);
		http_request_destroy(req);
		return NULL;
	}

	r = http_request_set_header(req, "Accept", "*/*");
	if (r) {
		loge("http_request_set_header() error\n");
		stream_free(&s);
		http_request_destroy(req);
		return NULL;
	}

	http_request_set_data(req, s.array, s.size);

	http_request_set_tag(req, rq->qr.qname);

	return req;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x3200
leaq -0x48(%rbp), %rdi
callq 0x270f0
movq -0x10(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x14950
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x13cb6
jmp 0x13c75
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x13ca7
movl $0x3, %edi
leaq 0x22976(%rip), %rsi     # 0x36603
leaq 0x22821(%rip), %rdx     # 0x364b5
movl $0x238, %ecx            # imm = 0x238
leaq 0x2264d(%rip), %r8      # 0x362ed
movb $0x0, %al
callq 0x243b0
jmp 0x13ca9
movq $0x0, -0x8(%rbp)
jmp 0x140a8
cmpq $0x0, -0x18(%rbp)
je 0x13db6
leaq -0x48(%rbp), %rdi
movl $0x29, %esi
callq 0x29010
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x13d3c
leaq -0x48(%rbp), %rdi
callq 0x29220
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x13d3a
jmp 0x13cf0
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x13d22
movl $0x3, %edi
leaq 0x228fb(%rip), %rsi     # 0x36603
leaq 0x227a6(%rip), %rdx     # 0x364b5
movl $0x242, %ecx            # imm = 0x242
leaq 0x22711(%rip), %r8      # 0x3642c
movb $0x0, %al
callq 0x243b0
jmp 0x13d24
leaq -0x48(%rbp), %rdi
callq 0x27870
movq $0x0, -0x8(%rbp)
jmp 0x140a8
jmp 0x13d3c
movq -0x70(%rbp), %rax
movw $0x400, 0xa(%rax)       # imm = 0x400
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x10, %rsi
movq -0x18(%rbp), %rax
movl 0x90(%rax), %edx
xorl %ecx, %ecx
callq 0x29e00
cmpl $0x0, %eax
je 0x13db4
jmp 0x13d6a
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x13d9c
movl $0x3, %edi
leaq 0x22881(%rip), %rsi     # 0x36603
leaq 0x2272c(%rip), %rdx     # 0x364b5
movl $0x24b, %ecx            # imm = 0x24B
leaq 0x226bc(%rip), %r8      # 0x36451
movb $0x0, %al
callq 0x243b0
jmp 0x13d9e
leaq -0x48(%rbp), %rdi
callq 0x27870
movq $0x0, -0x8(%rbp)
jmp 0x140a8
jmp 0x13db6
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rsi
xorl %edx, %edx
callq 0x29ec0
movl %eax, -0x50(%rbp)
cmpl $0x0, %eax
jg 0x13e22
jmp 0x13dcf
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x13e01
movl $0x3, %edi
leaq 0x2281c(%rip), %rsi     # 0x36603
leaq 0x226c7(%rip), %rdx     # 0x364b5
movl $0x252, %ecx            # imm = 0x252
leaq 0x21f68(%rip), %r8      # 0x35d62
movb $0x0, %al
callq 0x243b0
jmp 0x13e03
leaq -0x68(%rbp), %rdi
callq 0x2d640
leaq -0x48(%rbp), %rdi
callq 0x27870
movq $0x0, -0x8(%rbp)
jmp 0x140a8
leaq -0x48(%rbp), %rdi
callq 0x27870
movq -0x20(%rbp), %rax
movq 0x128(%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x120(%rax), %rdx
movq -0x20(%rbp), %rax
movl 0x130(%rax), %ecx
leaq 0x215b9(%rip), %rdi     # 0x3540b
callq 0x1e3d0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x13eae
jmp 0x13e64
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x13e96
movl $0x3, %edi
leaq 0x22787(%rip), %rsi     # 0x36603
leaq 0x22632(%rip), %rdx     # 0x364b5
movl $0x25c, %ecx            # imm = 0x25C
leaq 0x2263d(%rip), %r8      # 0x364cc
movb $0x0, %al
callq 0x243b0
jmp 0x13e98
leaq -0x68(%rbp), %rdi
callq 0x2d640
movq $0x0, -0x8(%rbp)
jmp 0x140a8
movq -0x28(%rbp), %rdi
leaq 0x22630(%rip), %rsi     # 0x364e9
leaq 0x22636(%rip), %rdx     # 0x364f6
callq 0x1e6c0
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x13f23
jmp 0x13ed0
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x13f02
movl $0x3, %edi
leaq 0x2271b(%rip), %rsi     # 0x36603
leaq 0x225c6(%rip), %rdx     # 0x364b5
movl $0x263, %ecx            # imm = 0x263
leaq 0x22613(%rip), %r8      # 0x3650e
movb $0x0, %al
callq 0x243b0
jmp 0x13f04
leaq -0x68(%rbp), %rdi
callq 0x2d640
movq -0x28(%rbp), %rdi
callq 0x1e4b0
movq $0x0, -0x8(%rbp)
jmp 0x140a8
movq -0x28(%rbp), %rdi
leaq 0x2280c(%rip), %rsi     # 0x3673a
leaq 0x2280c(%rip), %rdx     # 0x36741
callq 0x1e6c0
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x13f98
jmp 0x13f45
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x13f77
movl $0x3, %edi
leaq 0x226a6(%rip), %rsi     # 0x36603
leaq 0x22551(%rip), %rdx     # 0x364b5
movl $0x26b, %ecx            # imm = 0x26B
leaq 0x2259e(%rip), %r8      # 0x3650e
movb $0x0, %al
callq 0x243b0
jmp 0x13f79
leaq -0x68(%rbp), %rdi
callq 0x2d640
movq -0x28(%rbp), %rdi
callq 0x1e4b0
movq $0x0, -0x8(%rbp)
jmp 0x140a8
movq -0x28(%rbp), %rdi
leaq 0x227a7(%rip), %rsi     # 0x3674a
leaq 0x22797(%rip), %rdx     # 0x36741
callq 0x1e6c0
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x1400d
jmp 0x13fba
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x13fec
movl $0x3, %edi
leaq 0x22631(%rip), %rsi     # 0x36603
leaq 0x224dc(%rip), %rdx     # 0x364b5
movl $0x273, %ecx            # imm = 0x273
leaq 0x22529(%rip), %r8      # 0x3650e
movb $0x0, %al
callq 0x243b0
jmp 0x13fee
leaq -0x68(%rbp), %rdi
callq 0x2d640
movq -0x28(%rbp), %rdi
callq 0x1e4b0
movq $0x0, -0x8(%rbp)
jmp 0x140a8
movq -0x28(%rbp), %rdi
leaq 0x22517(%rip), %rsi     # 0x3652f
leaq 0x22517(%rip), %rdx     # 0x36536
callq 0x1e6c0
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x1407f
jmp 0x1402f
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x14061
movl $0x3, %edi
leaq 0x225bc(%rip), %rsi     # 0x36603
leaq 0x22467(%rip), %rdx     # 0x364b5
movl $0x27b, %ecx            # imm = 0x27B
leaq 0x224b4(%rip), %r8      # 0x3650e
movb $0x0, %al
callq 0x243b0
jmp 0x14063
leaq -0x68(%rbp), %rdi
callq 0x2d640
movq -0x28(%rbp), %rdi
callq 0x1e4b0
movq $0x0, -0x8(%rbp)
jmp 0x140a8
movq -0x28(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0x60(%rbp), %edx
callq 0x1ea40
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x1e950
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)