// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/channel_chndoh.c
// Function: doh_build_get_request
static http_request_t* doh_build_get_request(channel_req_t* rq, doh_server_t* doh, ns_msg_t* msg)
{
	channel_chndoh_t* c = rq->ctx;
	http_request_t* req = NULL;
	int r, len;
	stream_t s = STREAM_INIT();
	char* dns;
	int dns_len;

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

	dns = base64url_encode(s.array, s.size, &dns_len, FALSE, TRUE);
	if (!dns) {
		loge("base64_encode() error\n");
		stream_free(&s);
		return NULL;
	}

	stream_reset(&s);

	if (stream_appendf(&s,
		"%s?dns=%s",
		doh->path,
		dns) == -1) {
		loge("stream_appendf()\n");
		stream_free(&s);
		return NULL;
	}

	free(dns);

	req = http_request_create("GET", s.array, doh->host, doh->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, "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_state(req, doh);

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

	return req;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x3200
movq -0x20(%rbp), %rsi
leaq -0x50(%rbp), %rdi
xorl %edx, %edx
callq 0x29ec0
movl %eax, -0x38(%rbp)
cmpl $0x0, %eax
jg 0x11a4b
jmp 0x11a01
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x11a33
movl $0x3, %edi
leaq 0x24565(%rip), %rsi     # 0x35f7e
leaq 0x24b1a(%rip), %rdx     # 0x3653a
movl $0x341, %ecx            # imm = 0x341
leaq 0x24336(%rip), %r8      # 0x35d62
movb $0x0, %al
callq 0x243b0
jmp 0x11a35
leaq -0x50(%rbp), %rdi
callq 0x2d640
movq $0x0, -0x8(%rbp)
jmp 0x11cdc
movq -0x50(%rbp), %rdi
movl -0x48(%rbp), %esi
leaq -0x5c(%rbp), %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0xb860
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x11aba
jmp 0x11a70
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x11aa2
movl $0x3, %edi
leaq 0x244f6(%rip), %rsi     # 0x35f7e
leaq 0x24aab(%rip), %rdx     # 0x3653a
movl $0x348, %ecx            # imm = 0x348
leaq 0x24ab5(%rip), %r8      # 0x36550
movb $0x0, %al
callq 0x243b0
jmp 0x11aa4
leaq -0x50(%rbp), %rdi
callq 0x2d640
movq $0x0, -0x8(%rbp)
jmp 0x11cdc
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq 0x468(%rax), %rdx
movq -0x58(%rbp), %rcx
leaq -0x50(%rbp), %rdi
leaq 0x24a85(%rip), %rsi     # 0x36567
movb $0x0, %al
callq 0x2e2a0
cmpl $-0x1, %eax
jne 0x11b3a
jmp 0x11af0
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x11b22
movl $0x3, %edi
leaq 0x24476(%rip), %rsi     # 0x35f7e
leaq 0x24a2b(%rip), %rdx     # 0x3653a
movl $0x353, %ecx            # imm = 0x353
leaq 0x24a56(%rip), %r8      # 0x36571
movb $0x0, %al
callq 0x243b0
jmp 0x11b24
leaq -0x50(%rbp), %rdi
callq 0x2d640
movq $0x0, -0x8(%rbp)
jmp 0x11cdc
movq -0x58(%rbp), %rdi
callq 0x3460
movq -0x50(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x460(%rax), %rdx
movq -0x18(%rbp), %rax
movl 0x470(%rax), %ecx
leaq 0x2389f(%rip), %rdi     # 0x35402
callq 0x1e3d0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x11bbf
jmp 0x11b75
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x11ba7
movl $0x3, %edi
leaq 0x243f1(%rip), %rsi     # 0x35f7e
leaq 0x249a6(%rip), %rdx     # 0x3653a
movl $0x35c, %ecx            # imm = 0x35C
leaq 0x2492c(%rip), %r8      # 0x364cc
movb $0x0, %al
callq 0x243b0
jmp 0x11ba9
leaq -0x50(%rbp), %rdi
callq 0x2d640
movq $0x0, -0x8(%rbp)
jmp 0x11cdc
movq -0x30(%rbp), %rdi
leaq 0x2491f(%rip), %rsi     # 0x364e9
leaq 0x24925(%rip), %rdx     # 0x364f6
callq 0x1e6c0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x11c34
jmp 0x11be1
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x11c13
movl $0x3, %edi
leaq 0x24385(%rip), %rsi     # 0x35f7e
leaq 0x2493a(%rip), %rdx     # 0x3653a
movl $0x363, %ecx            # imm = 0x363
leaq 0x24902(%rip), %r8      # 0x3650e
movb $0x0, %al
callq 0x243b0
jmp 0x11c15
leaq -0x50(%rbp), %rdi
callq 0x2d640
movq -0x30(%rbp), %rdi
callq 0x1e4b0
movq $0x0, -0x8(%rbp)
jmp 0x11cdc
movq -0x30(%rbp), %rdi
leaq 0x248f0(%rip), %rsi     # 0x3652f
leaq 0x248f0(%rip), %rdx     # 0x36536
callq 0x1e6c0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x11ca6
jmp 0x11c56
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x11c88
movl $0x3, %edi
leaq 0x24310(%rip), %rsi     # 0x35f7e
leaq 0x248c5(%rip), %rdx     # 0x3653a
movl $0x36b, %ecx            # imm = 0x36B
leaq 0x2488d(%rip), %r8      # 0x3650e
movb $0x0, %al
callq 0x243b0
jmp 0x11c8a
leaq -0x50(%rbp), %rdi
callq 0x2d640
movq -0x30(%rbp), %rdi
callq 0x1e4b0
movq $0x0, -0x8(%rbp)
jmp 0x11cdc
movq -0x30(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl -0x48(%rbp), %edx
callq 0x1ea40
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1e910
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x1e950
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)