// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/lib/dns.c
// Function: dns_ai_nextaf
static int dns_ai_nextaf(struct dns_addrinfo *ai) {
	int i, pc;

	dns_static_assert(AF_UNSPEC == 0, "AF_UNSPEC constant not 0");
	dns_static_assert(AF_INET <= DNS_AI_AFMAX, "AF_INET constant too large");
	dns_static_assert(AF_INET6 <= DNS_AI_AFMAX, "AF_INET6 constant too large");

	DNS_SM_ENTER;

	if (ai->res) {
		/*
		 * NB: On OpenBSD, at least, the types of entries resolved
		 * is the intersection of the /etc/resolv.conf families and
		 * the families permitted by the .ai_type hint. So if
		 * /etc/resolv.conf has "family inet4" and .ai_type
		 * is AF_INET6, then the address ::1 will return 0 entries
		 * even if AI_NUMERICHOST is specified in .ai_flags.
		 */
		while (i < (int)lengthof(ai->res->resconf->family)) {
			int af = ai->res->resconf->family[i++];

			if (af == AF_UNSPEC) {
				DNS_SM_EXIT;
			} else if (af < 0 || af > DNS_AI_AFMAX) {
				continue;
			} else if (!(DNS_AI_AF2INDEX(af) & ai->af.todo)) {
				continue;
			} else if (af == AF_INET) {
				DNS_SM_YIELD(dns_ai_setaf(ai, AF_INET, DNS_T_A));
			} else if (af == AF_INET6) {
				DNS_SM_YIELD(dns_ai_setaf(ai, AF_INET6, DNS_T_AAAA));
			}
		}
	} else {
		/*
		 * NB: If we get here than AI_NUMERICFLAGS should be set and
		 * order shouldn't matter.
		 */
		if (DNS_AI_AF2INDEX(AF_INET) & ai->af.todo)
			DNS_SM_YIELD(dns_ai_setaf(ai, AF_INET, DNS_T_A));
		if (DNS_AI_AF2INDEX(AF_INET6) & ai->af.todo)
			DNS_SM_YIELD(dns_ai_setaf(ai, AF_INET6, DNS_T_AAAA));
	}

	DNS_SM_LEAVE;

	return dns_ai_setaf(ai, AF_UNSPEC, 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
jmp 0x41f4e
movq -0x10(%rbp), %rax
movl 0x148(%rax), %eax
sarl $0x0, %eax
andl $0xff, %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x148(%rax), %eax
sarl $0x8, %eax
andl $0xff, %eax
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
movq %rax, -0x28(%rbp)
subq $0x25, %rax
ja 0x421c8
movq -0x28(%rbp), %rax
leaq 0x8144(%rip), %rcx      # 0x4a0d8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x420d3
jmp 0x41fae
cmpl $0x3, -0x14(%rbp)
jge 0x420ce
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x300(%rax), %rax
movl -0x14(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x14(%rbp)
movslq %ecx, %rcx
movl 0x5a4(%rax,%rcx,4), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x41fec
jmp 0x41fe7
jmp 0x42196
cmpl $0x0, -0x1c(%rbp)
jl 0x41ff8
cmpl $0x20, -0x1c(%rbp)
jle 0x41ffa
jmp 0x41fae
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq -0x10(%rbp), %rcx
andq 0x140(%rcx), %rax
cmpq $0x0, %rax
jne 0x4201f
jmp 0x41fae
cmpl $0x2, -0x1c(%rbp)
jne 0x42070
jmp 0x42027
movl $0x15, -0x18(%rbp)
movl -0x18(%rbp), %ecx
andl $0xff, %ecx
shll $0x0, %ecx
movl -0x14(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
orl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x148(%rax)
movq -0x10(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x45630
movl %eax, -0x4(%rbp)
jmp 0x421da
jmp 0x4206e
jmp 0x420c3
cmpl $0xa, -0x1c(%rbp)
jne 0x420c1
jmp 0x42078
movl $0x17, -0x18(%rbp)
movl -0x18(%rbp), %ecx
andl $0xff, %ecx
shll $0x0, %ecx
movl -0x14(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
orl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x148(%rax)
movq -0x10(%rbp), %rdi
movl $0xa, %esi
movl $0x1c, %edx
callq 0x45630
movl %eax, -0x4(%rbp)
jmp 0x421da
jmp 0x420bf
jmp 0x420c1
jmp 0x420c3
jmp 0x420c5
jmp 0x420c7
jmp 0x420c9
jmp 0x41fae
jmp 0x42194
movq -0x10(%rbp), %rax
movq 0x140(%rax), %rax
andq $0x2, %rax
cmpq $0x0, %rax
je 0x42133
jmp 0x420ea
movl $0x20, -0x18(%rbp)
movl -0x18(%rbp), %ecx
andl $0xff, %ecx
shll $0x0, %ecx
movl -0x14(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
orl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x148(%rax)
movq -0x10(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x45630
movl %eax, -0x4(%rbp)
jmp 0x421da
jmp 0x42131
jmp 0x42133
movq -0x10(%rbp), %rax
movq 0x140(%rax), %rax
andq $0x200, %rax            # imm = 0x200
cmpq $0x0, %rax
je 0x42192
jmp 0x4214c
movl $0x22, -0x18(%rbp)
movl -0x18(%rbp), %ecx
andl $0xff, %ecx
shll $0x0, %ecx
movl -0x14(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
orl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x148(%rax)
movq -0x10(%rbp), %rdi
movl $0xa, %esi
movl $0x1c, %edx
callq 0x45630
movl %eax, -0x4(%rbp)
jmp 0x421da
jmp 0x42190
jmp 0x42192
jmp 0x42194
jmp 0x42196
jmp 0x42198
movl $0x25, -0x18(%rbp)
movl -0x18(%rbp), %ecx
andl $0xff, %ecx
shll $0x0, %ecx
movl -0x14(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
orl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x148(%rax)
jmp 0x421c6
jmp 0x421c6
jmp 0x421c8
jmp 0x421ca
movq -0x10(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x45630
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)