// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/channel_chndoh.c
// Function: query_doh_addr
static void query_doh_addr(channel_chndoh_t* c, doh_server_t* doh)
{
	channel_req_t* req;
	ns_msg_t msg;
	ns_flags_t flags;

	doh->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(doh->host) + 2);
	strcpy(msg.qrs->qname, doh->host);
	strcat(msg.qrs->qname, ".");

	req = myreq_new(c, &msg, query_doh_addr_cb, doh);

	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)
movq %rsi, -0x10(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x3330
movq %rax, %rcx
addq $0x3c, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
leaq -0x38(%rbp), %rdi
callq 0x270f0
movw $0x0, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x26e80
movw %ax, -0x3c(%rbp)
movw -0x3c(%rbp), %ax
movw %ax, -0x3a(%rbp)
movw -0x3a(%rbp), %ax
andw $-0x21, %ax
orw $0x20, %ax
movw %ax, -0x3a(%rbp)
movw -0x3a(%rbp), %ax
andw $0xfeff, %ax            # imm = 0xFEFF
orw $0x100, %ax             # imm = 0x100
movw %ax, -0x3a(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x3a(%rbp), %rsi
callq 0x26fd0
movw $0x1, -0x34(%rbp)
movl $0x10, %edi
callq 0x34d0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xfd08
jmp 0xfea0
movq -0x28(%rbp), %rax
movw $0x1, 0xa(%rax)
movq -0x28(%rbp), %rax
movw $0x1, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x460(%rax), %rdi
callq 0x3180
movq %rax, %rdi
addq $0x2, %rdi
callq 0x34d0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x460(%rax), %rsi
callq 0x3350
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq 0x2992d(%rip), %rsi     # 0x39694
callq 0x35e0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rcx
leaq -0x38(%rbp), %rsi
leaq 0x271(%rip), %rdx       # 0xfff0
callq 0xfeb0
movq %rax, -0x18(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x27870
cmpq $0x0, -0x18(%rbp)
jne 0xfd9d
jmp 0xfea0
jmp 0xfd9f
movq -0x8(%rbp), %rcx
addq $0x58, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x18(%rbp), %rcx
addq $0x28, %rcx
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rcx
addq $0x28, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x8(%rbp), %rdi
addq $0x68, %rdi
movq -0x18(%rbp), %rsi
addq $0x38, %rsi
callq 0x3790
movq -0x8(%rbp), %rax
movl 0x78(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x78(%rax)
movq -0x18(%rbp), %rdi
callq 0x102a0
cmpl $0x0, %eax
je 0xfea0
jmp 0xfe18
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0xfe4a
movl $0x3, %edi
leaq 0x2614e(%rip), %rsi     # 0x35f7e
leaq 0x2641a(%rip), %rdx     # 0x36251
movl $0x139, %ecx            # imm = 0x139
leaq 0x2641d(%rip), %r8      # 0x36260
movb $0x0, %al
callq 0x243b0
jmp 0xfe4c
jmp 0xfe4e
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rdi
addq $0x68, %rdi
movq -0x18(%rbp), %rsi
addq $0x38, %rsi
callq 0x3b90
movq -0x8(%rbp), %rax
movl 0x78(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x78(%rax)
movq -0x18(%rbp), %rdi
callq 0x10410
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)