// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
leaq -0x1d0(%rbp), %rdi
xorl %esi, %esi
movl $0x58, %edx
callq 0xf7d0
movl $0x1, -0x1d0(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x1d0(%rbp), %rdi
callq 0x10750
movq %rax, %rdx
movq -0x18(%rbp), %rcx
leaq -0x48(%rbp), %rdi
movl $0x1, %esi
leaq -0x178(%rbp), %r8
callq 0xfe80
cmpl $0x0, %eax
jne 0x3c9aa
jmp 0x3cc03
leaq -0x150(%rbp), %rdi
movw -0x44(%rbp), %ax
movq -0x18(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
leaq -0x178(%rbp), %r8
movzwl %ax, %edx
callq 0xffd0
movq %rax, -0x158(%rbp)
cmpq $0x0, %rax
jne 0x3c9df
jmp 0x3cc03
cmpq $0x100, -0x158(%rbp) # imm = 0x100
jb 0x3c9f1
jmp 0x3cbf9
jmp 0x3c9f3
leaq -0x430(%rbp), %rdi
xorl %esi, %esi
movl $0x260, %edx            # imm = 0x260
callq 0xf7d0
leaq -0x430(%rbp), %rdi
movl $0x25c, %esi            # imm = 0x25C
callq 0x10c30
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq 0x5c(%rax), %rcx
andq $-0x800001, %rcx        # imm = 0xFF7FFFFF
orq $0x800000, %rcx         # imm = 0x800000
movq %rcx, 0x5c(%rax)
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq -0x48(%rbp), %rsi
callq 0x104d0
movl %eax, -0x178(%rbp)
cmpl $0x0, %eax
je 0x3ca56
jmp 0x3cc03
movq -0x30(%rbp), %rdi
movl $0x4, %esi
leaq 0x10a0d(%rip), %rdx     # 0x4d473
movl $0x1, %ecx
movl $0x2, %r8d
movl $0x1, %r9d
xorl %eax, %eax
leaq 0x10ba9(%rip), %rax     # 0x4d629
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x10880
movl %eax, -0x178(%rbp)
cmpl $0x0, %eax
je 0x3caa1
jmp 0x3cc03
jmp 0x3caa3
leaq -0x150(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x168(%rbp), %rdi
callq 0x3cc30
movq -0x10(%rbp), %r8
leaq -0x170(%rbp), %rdi
leaq -0x174(%rbp), %rsi
movl $0x1, %edx
leaq -0x168(%rbp), %rcx
callq 0x10420
cmpl $0x0, %eax
je 0x3cb91
movq -0x170(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x434(%rbp)
movl -0x434(%rbp), %edx
movl $0x1, %eax
movl $0x1c, %ecx
cmpl $0xa, %edx
cmovel %ecx, %eax
movl %eax, -0x438(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x448(%rbp)
movl -0x438(%rbp), %eax
movl %eax, -0x43c(%rbp)
movl -0x434(%rbp), %edi
movq -0x170(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x3a110
movq -0x448(%rbp), %rdi
movl -0x43c(%rbp), %r8d
movl $0x8, %esi
leaq 0x10ac9(%rip), %rdx     # 0x4d629
movl $0xc, %ecx
movl $0x1, %r9d
xorl %r10d, %r10d
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x10880
movl %eax, -0x178(%rbp)
cmpl $0x0, %eax
je 0x3cb8c
jmp 0x3cc03
jmp 0x3cac1
jmp 0x3cb93
leaq -0x150(%rbp), %rdi
leaq -0x150(%rbp), %rdx
movq -0x158(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
callq 0x10690
movq %rax, -0x158(%rbp)
cmpq $0x0, %rax
jne 0x3caa3
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rdi
leaq -0x178(%rbp), %rsi
callq 0xfb10
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x10300
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x3cbef
jmp 0x3cc03
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x3cc17
movl $0x9b918cc1, -0x178(%rbp) # imm = 0x9B918CC1
movl -0x178(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
nopw %cs:(%rax,%rax)