// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/channel_doh.c
// Function: query_http_addr
static void query_http_addr(channel_doh_t* c)
{
	channel_req_t* req;
	ns_msg_t msg;
	ns_flags_t flags;

	c->http_addr_expire = time(NULL) + 60;

	init_ns_msg(&msg);

	msg.id = 0;

	flags = ns_get_flags(&msg);
	flags.aa = 1;
	flags.ra = 1;
	ns_set_flags(&msg, &flags);

	msg.qdcount = 1;
	msg.qrs = (ns_qr_t*)malloc(sizeof(ns_qr_t));
	if (!msg.qrs) {
		return;
	}

	msg.qrs->qclass = NS_QCLASS_IN;
	msg.qrs->qtype = NS_QTYPE_A;
	msg.qrs->qname = (char*)malloc(strlen(c->host) + 2);
	strcpy(msg.qrs->qname, c->host);
	strcat(msg.qrs->qname, ".");

	req = myreq_new(c, &msg, http_addr_query_cb, c);

	ns_msg_free(&msg);

	if (!req) {
		return;
	}

	dllist_add(&c->reqs, &req->entry);
	rbtree_insert(&c->reqdic, &req->rbn);
	c->req_count++;

	if (doh_query(req)) {
		loge("doh_query() error\n");
		dllist_remove(&req->entry);
		rbtree_remove(&c->reqdic, &req->rbn);
		c->req_count--;
		myreq_destroy(req);
		return;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x3330
movq %rax, %rcx
addq $0x3c, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x118(%rax)
leaq -0x30(%rbp), %rdi
callq 0x270f0
movw $0x0, -0x30(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x26e80
movw %ax, -0x34(%rbp)
movw -0x34(%rbp), %ax
movw %ax, -0x32(%rbp)
movw -0x32(%rbp), %ax
andw $-0x21, %ax
orw $0x20, %ax
movw %ax, -0x32(%rbp)
movw -0x32(%rbp), %ax
andw $0xfeff, %ax            # imm = 0xFEFF
orw $0x100, %ax             # imm = 0x100
movw %ax, -0x32(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x32(%rbp), %rsi
callq 0x26fd0
movw $0x1, -0x2c(%rbp)
movl $0x10, %edi
callq 0x34d0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x13088
jmp 0x13220
movq -0x20(%rbp), %rax
movw $0x1, 0xa(%rax)
movq -0x20(%rbp), %rax
movw $0x1, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x120(%rax), %rdi
callq 0x3180
movq %rax, %rdi
addq $0x2, %rdi
callq 0x34d0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x120(%rax), %rsi
callq 0x3350
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x265ad(%rip), %rsi     # 0x39694
callq 0x35e0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rcx
leaq -0x30(%rbp), %rsi
leaq 0x261(%rip), %rdx       # 0x13360
callq 0x13230
movq %rax, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x27870
cmpq $0x0, -0x10(%rbp)
jne 0x1311d
jmp 0x13220
jmp 0x1311f
movq -0x8(%rbp), %rcx
addq $0x58, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rcx
addq $0x28, %rcx
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rcx
addq $0x28, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x8(%rbp), %rdi
addq $0x68, %rdi
movq -0x10(%rbp), %rsi
addq $0x38, %rsi
callq 0x3790
movq -0x8(%rbp), %rax
movl 0x78(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x78(%rax)
movq -0x10(%rbp), %rdi
callq 0x13620
cmpl $0x0, %eax
je 0x13220
jmp 0x13198
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x131ca
movl $0x3, %edi
leaq 0x23453(%rip), %rsi     # 0x36603
leaq 0x23519(%rip), %rdx     # 0x366d0
movl $0xfe, %ecx
leaq 0x2309d(%rip), %r8      # 0x36260
movb $0x0, %al
callq 0x243b0
jmp 0x131cc
jmp 0x131ce
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rdi
addq $0x68, %rdi
movq -0x10(%rbp), %rsi
addq $0x38, %rsi
callq 0x3b90
movq -0x8(%rbp), %rax
movl 0x78(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x78(%rax)
movq -0x10(%rbp), %rdi
callq 0x13910
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)