// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/channel_chndoh.c
// Function: http_cb
static void http_cb(
	int status,
	http_request_t* request,
	http_response_t* response,
	void* state)
{
	channel_req_t* rq = (channel_req_t*)state;
	channel_chndoh_t* c = rq->ctx;
	doh_server_t* doh = NULL;
	ns_msg_t* result = NULL;
	char* data;
	int datalen;
	int http_status = 0;
	const char* status_text = NULL;

	doh = (doh_server_t*)http_request_get_state(request);

	if (status == HTTP_OK &&
		(http_status = http_response_get_status_code(response, &status_text)) == 200) {
		result = (ns_msg_t*)malloc(sizeof(ns_msg_t));
		if (!result) {
			loge("alloc\n");
			goto exit;
		}
		
		if (init_ns_msg(result)) {
			loge("init_ns_msg() error\n");
			free(result);
			result = NULL;
			goto exit;
		}

		data = http_response_get_data(response, &datalen);
		if (ns_parse(result, (const uint8_t*)data, datalen)) {
			loge("ns_parse() error\n");
			ns_msg_free(result);
			free(result);
			result = NULL;
			goto exit;
		}

		result->id = doh == &c->chndoh ? 0 : 1;

		logd("%d. query %s success: %s - %s (%lu ms)\n",
			2 - rq->wait_num,
			rq->qr.qname,
			msg_answers(result),
			doh->name ? doh->name : (doh->host ? doh->host : doh->addrstr),
			OS_GetTickCount() - rq->start_time);
	}
	else {
		loge("%d. query %s failed: HTTP %d %s - %s (%lu ms)\n",
			2 - rq->wait_num,
			rq->qr.qname,
			http_status,
			status_text,
			doh->name ? doh->name : (doh->host ? doh->host : doh->addrstr),
			OS_GetTickCount() - rq->start_time);
	}

exit:
	free(http_request_get_data(request, &datalen));
	http_request_destroy(request);
	http_response_destroy(response);

	query_cb(NULL, result ? 0 : -1, result, FALSE, !!result, rq);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0xf0, %rsp
movl %edi, -0x14(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movl $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x20(%rbp), %rdi
callq 0x1e8f0
movq %rax, -0x48(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x11fcc
movq -0x28(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x1f440
movl %eax, -0x60(%rbp)
cmpl $0xc8, %eax
jne 0x11fcc
movl $0x20, %edi
callq 0x34d0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x11dc2
jmp 0x11d89
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x11dbb
movl $0x3, %edi
leaq 0x241dd(%rip), %rsi     # 0x35f7e
leaq 0x247db(%rip), %rdx     # 0x36583
movl $0x2db, %ecx            # imm = 0x2DB
leaq 0x250e3(%rip), %r8      # 0x36e97
movb $0x0, %al
callq 0x243b0
jmp 0x11dbd
jmp 0x120fc
movq -0x50(%rbp), %rdi
callq 0x270f0
cmpl $0x0, %eax
je 0x11e1c
jmp 0x11dd2
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x11e04
movl $0x3, %edi
leaq 0x24194(%rip), %rsi     # 0x35f7e
leaq 0x24792(%rip), %rdx     # 0x36583
movl $0x2e0, %ecx            # imm = 0x2E0
leaq 0x23da5(%rip), %r8      # 0x35ba2
movb $0x0, %al
callq 0x243b0
jmp 0x11e06
movq -0x50(%rbp), %rdi
callq 0x3460
movq $0x0, -0x50(%rbp)
jmp 0x120fc
movq -0x28(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0x1f500
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
movl -0x5c(%rbp), %edx
callq 0x284b0
cmpl $0x0, %eax
je 0x11e97
jmp 0x11e44
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x11e76
movl $0x3, %edi
leaq 0x24122(%rip), %rsi     # 0x35f7e
leaq 0x24720(%rip), %rdx     # 0x36583
movl $0x2e8, %ecx            # imm = 0x2E8
leaq 0x2471c(%rip), %r8      # 0x3658b
movb $0x0, %al
callq 0x243b0
jmp 0x11e78
movq -0x50(%rbp), %rdi
callq 0x27870
movq -0x50(%rbp), %rdi
callq 0x3460
movq $0x0, -0x50(%rbp)
jmp 0x120fc
movq -0x48(%rbp), %rdx
movq -0x40(%rbp), %rsi
addq $0x80, %rsi
movl $0x1, %eax
xorl %ecx, %ecx
cmpq %rsi, %rdx
cmovel %ecx, %eax
movw %ax, %cx
movq -0x50(%rbp), %rax
movw %cx, (%rax)
movb $0x0, %al
callq 0x242d0
cmpl $0x7, (%rax)
jl 0x11fc5
movq -0x38(%rbp), %rcx
movl $0x2, %eax
subl 0x74(%rcx), %eax
movl %eax, -0x7c(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x50(%rbp), %rdi
callq 0x27de0
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x450(%rax)
je 0x11f17
movq -0x48(%rbp), %rax
movq 0x450(%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0x11f59
movq -0x48(%rbp), %rax
cmpq $0x0, 0x460(%rax)
je 0x11f39
movq -0x48(%rbp), %rax
movq 0x460(%rax), %rax
movq %rax, -0x90(%rbp)
jmp 0x11f4b
movq -0x48(%rbp), %rax
movq 0x458(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x78(%rbp), %rbx
movq -0x88(%rbp), %rax
movq %rax, -0x98(%rbp)
movb $0x0, %al
callq 0x26e40
movl -0x7c(%rbp), %r9d
movq -0x70(%rbp), %r11
movq -0x98(%rbp), %r10
movq -0x38(%rbp), %rcx
subq 0x80(%rcx), %rax
movl $0x7, %edi
leaq 0x23fe6(%rip), %rsi     # 0x35f7e
leaq 0x245e4(%rip), %rdx     # 0x36583
movl $0x2f6, %ecx            # imm = 0x2F6
leaq 0x2435f(%rip), %r8      # 0x3630a
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x11fc7
jmp 0x120fa
jmp 0x11fce
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x120f6
movq -0x38(%rbp), %rcx
movl $0x2, %eax
subl 0x74(%rcx), %eax
movl %eax, -0xb4(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xb0(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0xa4(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x450(%rax)
je 0x12035
movq -0x48(%rbp), %rax
movq 0x450(%rax), %rax
movq %rax, -0xc0(%rbp)
jmp 0x12077
movq -0x48(%rbp), %rax
cmpq $0x0, 0x460(%rax)
je 0x12057
movq -0x48(%rbp), %rax
movq 0x460(%rax), %rax
movq %rax, -0xc8(%rbp)
jmp 0x12069
movq -0x48(%rbp), %rax
movq 0x458(%rax), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl -0xa4(%rbp), %ebx
movq -0xb0(%rbp), %r14
movq -0xc0(%rbp), %rax
movq %rax, -0xd0(%rbp)
movb $0x0, %al
callq 0x26e40
movl -0xb4(%rbp), %r9d
movq -0xa0(%rbp), %r11
movq -0xd0(%rbp), %r10
movq -0x38(%rbp), %rcx
subq 0x80(%rcx), %rax
movl $0x3, %edi
leaq 0x23eb9(%rip), %rsi     # 0x35f7e
leaq 0x244b7(%rip), %rdx     # 0x36583
movl $0x2ff, %ecx            # imm = 0x2FF
leaq 0x244c5(%rip), %r8      # 0x3659d
movq %r14, (%rsp)
movl %ebx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x120f8
jmp 0x120fa
jmp 0x120fc
movq -0x20(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0x1ea10
movq %rax, %rdi
callq 0x3460
movq -0x20(%rbp), %rdi
callq 0x1e4b0
movq -0x28(%rbp), %rdi
callq 0x1f090
movq -0x50(%rbp), %rcx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
cmpq $0x0, %rcx
cmovnel %eax, %esi
movq -0x50(%rbp), %rdx
cmpq $0x0, -0x50(%rbp)
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %r8d
movq -0x38(%rbp), %r9
xorl %eax, %eax
movl %eax, %edi
xorl %ecx, %ecx
callq 0x10730
addq $0xf0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopw %cs:(%rax,%rax)