// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/lib/dns.c
// Function: dns_so_submit
int dns_so_submit(struct dns_socket *so, struct dns_packet *Q, struct sockaddr *host) {
	struct dns_rr rr;
	int error = DNS_EUNKNOWN;

	dns_so_reset(so);

	if ((error = dns_rr_parse(&rr, 12, Q)))
		goto error;

	if (!(so->qlen = dns_d_expand(so->qname, sizeof so->qname, rr.dn.p, Q, &error)))
		goto error;
	/*
	 * NOTE: Don't bail if expansion is too long; caller may be
	 * intentionally sending long names. However, we won't be able to
	 * verify it on return.
	 */

	so->qtype	= rr.type;
	so->qclass	= rr.class;

	if ((error = dns_so_newanswer(so, (Q->memo.opt.maxudp)? Q->memo.opt.maxudp : DNS_SO_MINBUF)))
		goto syerr;

	memcpy(&so->remote, host, dns_sa_len(host));

	so->query	= Q;
	so->qout	= 0;

	dns_begin(&so->elapsed);

	if (dns_header(so->query)->qid == 0)
		dns_header(so->query)->qid	= dns_so_mkqid(so);

	so->qid		= dns_header(so->query)->qid;
	so->state	= (so->type == SOCK_STREAM)? DNS_SO_TCP_INIT : DNS_SO_UDP_INIT;

	so->stat.queries++;

	return 0;
syerr:
	error	= dns_syerr();
error:
	dns_so_reset(so);

	return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x9b918cc4, -0x3c(%rbp) # imm = 0x9B918CC4
movq -0x10(%rbp), %rdi
callq 0xf110
movq -0x18(%rbp), %rdx
leaq -0x38(%rbp), %rdi
movl $0xc, %esi
callq 0xf790
movl %eax, -0x3c(%rbp)
cmpl $0x0, %eax
je 0x3d2a3
jmp 0x3d45a
movq -0x10(%rbp), %rdi
addq $0x1b6, %rdi            # imm = 0x1B6
movw -0x34(%rbp), %ax
movq -0x18(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
leaq -0x3c(%rbp), %r8
movzwl %ax, %edx
callq 0xffd0
movq -0x10(%rbp), %rcx
movq %rax, 0x2b8(%rcx)
cmpq $0x0, %rax
jne 0x3d2dd
jmp 0x3d45a
movl -0x30(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x2c0(%rax)
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x2c4(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movzwl 0x32(%rax), %eax
cmpl $0x0, %eax
je 0x3d319
movq -0x18(%rbp), %rax
movzwl 0x32(%rax), %eax
movl %eax, -0x4c(%rbp)
jmp 0x3d323
movl $0x300, %eax            # imm = 0x300
movl %eax, -0x4c(%rbp)
jmp 0x3d323
movq -0x48(%rbp), %rdi
movl -0x4c(%rbp), %eax
movslq %eax, %rsi
callq 0x3d480
movl %eax, -0x3c(%rbp)
cmpl $0x0, %eax
je 0x3d33f
jmp 0x3d450
movq -0x10(%rbp), %rax
addq $0xb8, %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movzwl (%rax), %edi
callq 0x3c6e0
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %rax, %rdx
callq 0xfb40
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x2c8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x2d0(%rax)
movq -0x10(%rbp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
callq 0x3d510
movq -0x10(%rbp), %rax
movq 0x2c8(%rax), %rax
movq 0x5c(%rax), %rax
andq $0xffff, %rax           # imm = 0xFFFF
cmpl $0x0, %eax
jne 0x3d3ed
movq -0x10(%rbp), %rdi
callq 0x104a0
movzwl %ax, %ecx
movq -0x10(%rbp), %rax
movq 0x2c8(%rax), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x5c(%rax), %rcx
andq $0xffff, %rdx           # imm = 0xFFFF
andq $-0x10000, %rcx         # imm = 0xFFFF0000
orq %rdx, %rcx
movq %rcx, 0x5c(%rax)
movq -0x10(%rbp), %rax
movq 0x2c8(%rax), %rax
movq 0x5c(%rax), %rax
andq $0xffff, %rax           # imm = 0xFFFF
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x1b4(%rax)
movq -0x10(%rbp), %rax
movl 0x30(%rax), %edx
movl $0x1, %ecx
movl $0x6, %eax
cmpl $0x1, %edx
cmovel %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1b0(%rax)
movq -0x10(%rbp), %rax
movq 0x168(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x168(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x3d469
callq 0xf0a0
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
callq 0xf110
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)