// File: /workspace/github_c_makefile_star2_O1/wahern[P]cqueues/src/lib/dns.c
// Function: dns_hints_query
struct dns_packet *dns_hints_query(struct dns_hints *hints, struct dns_packet *Q, int *error_) {
	struct dns_packet *A, *P;
	struct dns_rr rr;
	char zone[DNS_D_MAXNAME + 1];
	size_t zlen;
	struct dns_hints_i i;
	struct sockaddr *sa;
	socklen_t slen;
	int error;

	if (!dns_rr_grep(&rr, 1, dns_rr_i_new(Q, .section = DNS_S_QUESTION), Q, &error))
		goto error;

	if (!(zlen = dns_d_expand(zone, sizeof zone, rr.dn.p, Q, &error)))
		goto error;
	else if (zlen >= sizeof zone)
		goto toolong;

	P			= dns_p_new(512);
	dns_header(P)->qr	= 1;

	if ((error = dns_rr_copy(P, &rr, Q)))
		goto error;

	if ((error = dns_p_push(P, DNS_S_AUTHORITY, ".", strlen("."), DNS_T_NS, DNS_C_IN, 0, "hints.local.")))
		goto error;

	do {
		i.zone	= zone;

		dns_hints_i_init(&i, hints);

		while (dns_hints_grep(&sa, &slen, 1, &i, hints)) {
			int af		= sa->sa_family;
			int rtype	= (af == AF_INET6)? DNS_T_AAAA : DNS_T_A;

			if ((error = dns_p_push(P, DNS_S_ADDITIONAL, "hints.local.", strlen("hints.local."), rtype, DNS_C_IN, 0, dns_sa_addr(af, sa, NULL))))
				goto error;
		}
	} while ((zlen = dns_d_cleave(zone, sizeof zone, zone, zlen)));

	if (!(A = dns_p_copy(dns_p_make(P->end, &error), P)))
		goto error;

	return A;
toolong:
	error = DNS_EILLEGAL;
error:
	*error_	= error;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %r14
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x30(%rdx)
movaps %xmm0, 0x40(%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, 0x20(%rdx)
movq $0x0, 0x50(%rdx)
movl $0x1, (%rdx)
movups %xmm0, 0x38(%rdx)
movups %xmm0, 0x48(%rdx)
leaq 0x38(%rsp), %rdi
leaq 0x4(%rsp), %r8
movl $0x1, %esi
movq %r15, %rcx
callq 0xfd70
testl %eax, %eax
je 0x2dc4f
movzwl 0x3c(%rsp), %edx
leaq 0x310(%rsp), %rbp
leaq 0x4(%rsp), %r8
movl $0x100, %esi            # imm = 0x100
movq %rbp, %rdi
movq %r15, %rcx
callq 0xfec0
testq %rax, %rax
je 0x2dc4f
movq %rax, %r12
cmpq $0xff, %rax
jbe 0x2da11
movl $0x9b918cc1, 0x4(%rsp)  # imm = 0x9B918CC1
jmp 0x2dc4f
leaq 0xb0(%rsp), %rbx
movl $0x260, %edx            # imm = 0x260
movq %rbx, %rdi
xorl %esi, %esi
callq 0xf750
movq $0x200, 0x48(%rbx)      # imm = 0x200
movq $0xc, 0x50(%rbx)
movl $0x0, 0x64(%rbx)
movq $0x800000, 0x5c(%rbx)   # imm = 0x800000
leaq 0x38(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x10370
movl %eax, 0x4(%rsp)
testl %eax, %eax
jne 0x2dc4f
leaq 0xb69f(%rip), %rax      # 0x39109
leaq 0xb4e2(%rip), %rdx      # 0x38f53
leaq 0xb0(%rsp), %rdi
movl $0x1, %ecx
movl $0x4, %esi
movl $0x2, %r8d
movl $0x1, %r9d
pushq %rax
pushq $0x0
callq 0x106d0
addq $0x10, %rsp
movl %eax, 0x4(%rsp)
testl %eax, %eax
jne 0x2dc4f
movq %r13, 0x8(%rsp)
movl 0x4(%rsp), %r13d
leaq 0x20(%rsp), %rbx
movq %r14, 0x28(%rsp)
movq %rbp, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
callq *0x1a801(%rip)          # 0x482d0
testl %eax, %eax
je 0x2dac9
movl %eax, 0x1c(%rsp)
movq 0x8(%r14), %r15
testq %r15, %r15
je 0x2daf8
movq %rbp, %rdi
movq %r15, %rsi
callq 0xfe40
testl %eax, %eax
je 0x2dafb
movq 0x988(%r15), %r15
jmp 0x2dadb
xorl %r15d, %r15d
testq %r15, %r15
je 0x2db4e
movl 0x980(%r15), %r14d
xorl %ecx, %ecx
cmpl $0x2, %r14d
jb 0x2db38
xorl %ebx, %ebx
movl $0x1, %ebp
movl %ebp, %edi
movl %ebx, %esi
leaq 0x10(%rsp), %rdx
movq %r15, %rcx
callq 0x337e7
movl %ebp, %ecx
testl %eax, %eax
js 0x2db2f
movl %ebx, %ecx
incl %ebp
movl %ecx, %ebx
cmpl %ebp, %r14d
jne 0x2db16
movl %ecx, 0x18(%rsp)
movq 0x28(%rsp), %r14
leaq 0x310(%rsp), %rbp
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
leaq 0x34(%rsp), %r15
movq %r15, %rsi
movl $0x1, %edx
leaq 0x10(%rsp), %rcx
movq %r14, %r8
callq 0x102c0
testl %eax, %eax
je 0x2dbda
movq 0x20(%rsp), %rax
movzwl (%rax), %ecx
movl $0x1c, %r8d
cmpl $0xa, %ecx
je 0x2db88
movl $0x1, %r8d
cmpl $0x2, %ecx
je 0x2db98
cmpl $0xa, %ecx
jne 0x2db9e
addq $0x8, %rax
jmp 0x2dba0
addq $0x4, %rax
jmp 0x2dba0
xorl %eax, %eax
movl $0xc, %ecx
leaq 0xb0(%rsp), %rdi
movl $0x8, %esi
leaq 0xb550(%rip), %rdx      # 0x39109
movl $0x1, %r9d
pushq %rax
pushq $0x0
callq 0x106d0
addq $0x10, %rsp
movl %eax, %r13d
testl %eax, %eax
jne 0x2dc45
movq %rbx, %rdi
jmp 0x2db56
movl %r13d, 0x4(%rsp)
movl $0x100, %esi            # imm = 0x100
movq %rbp, %rdi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x104f0
movq %rax, %r12
testq %rax, %rax
jne 0x2dabb
movq 0x100(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0xfa30
testq %rax, %rax
je 0x2dc6f
movq %rax, %r14
movq 0x48(%rax), %rax
movq 0x100(%rsp), %rdx
cmpq %rdx, %rax
cmovbq %rax, %rdx
movq %rdx, 0x50(%r14)
movq %r14, %rdi
addq $0x5c, %rdi
leaq 0x10c(%rsp), %rsi
callq 0xfa60
jmp 0x2dc72
movl %r13d, 0x4(%rsp)
movq 0x8(%rsp), %r13
movl 0x4(%rsp), %eax
movl %eax, (%r13)
xorl %r14d, %r14d
movq %r14, %rax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
movq 0x8(%rsp), %r13
testq %r14, %r14
jne 0x2dc5a
jmp 0x2dc4f