// File: /workspace/github_c_makefile_star2_O3/wahern[P]cqueues/src/lib/dns.c
// Function: dns_hosts_loadfile
int dns_hosts_loadfile(struct dns_hosts *hosts, FILE *fp) {
	struct dns_hosts_entry ent;
	char word[DNS_PP_MAX(INET6_ADDRSTRLEN, DNS_D_MAXNAME) + 1];
	unsigned wp, wc, skip;
	int ch, error;

	rewind(fp);

	do {
		memset(&ent, '\0', sizeof ent);
		wc	= 0;
		skip	= 0;

		do {
			memset(word, '\0', sizeof word);
			wp	= 0;

			while (EOF != (ch = fgetc(fp)) && ch != '\n') {
				skip	|= !!dns_hosts_iscom(ch);

				if (skip)
					continue;

				if (dns_hosts_issep(ch))
					break;

				if (wp < sizeof word - 1)
					word[wp]	= ch;
				wp++;
			}

			if (!wp)
				continue;

			wc++;

			switch (wc) {
			case 0:
				break;
			case 1:
				ent.af	= (strchr(word, ':'))? AF_INET6 : AF_INET;
				skip	= (1 != dns_inet_pton(ent.af, word, &ent.addr));

				break;
			default:
				if (!wp)
					break;

				dns_d_anchor(ent.host, sizeof ent.host, word, wp);

				if ((error = dns_hosts_insert(hosts, ent.af, &ent.addr, ent.host, (wc > 2))))
					return error;

				break;
			} /* switch() */
		} while (ch != EOF && ch != '\n');
	} while (ch != EOF);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rsi, %rbx
movq %rdi, 0x8(%rsp)
movq %rsi, %rdi
callq 0xf150
leaq 0x160(%rsp), %r13
xorl %r15d, %r15d
movl $0x170, %edx            # imm = 0x170
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0xf750
xorl %r14d, %r14d
movl $0x100, %edx            # imm = 0x100
leaq 0x180(%rsp), %rdi
xorl %esi, %esi
callq 0xf750
xorl %r12d, %r12d
movq %rbx, %rdi
callq 0x10540
movl %eax, %ebp
cmpl $-0x1, %eax
je 0x2afa4
cmpl $0xa, %ebp
je 0x2afa4
cmpl $0x23, %ebp
sete %al
cmpl $0x3b, %ebp
sete %cl
orb %al, %cl
movzbl %cl, %eax
orl %eax, %r14d
movl $0x1, %r14d
jne 0x2af42
callq 0xfe30
movq (%rax), %rax
movzbl %bpl, %ecx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x2afa1
cmpl $0xfe, %r12d
ja 0x2af99
movl %r12d, %eax
movb %bpl, 0x180(%rsp,%rax)
incl %r12d
xorl %r14d, %r14d
jmp 0x2af42
xorl %r14d, %r14d
testl %r12d, %r12d
je 0x2b093
cmpl $-0x1, %r15d
je 0x2b003
testl %r15d, %r15d
jne 0x2b00b
leaq 0x180(%rsp), %r14
movq %r14, %rdi
movl $0x3a, %esi
callq 0xf4e0
xorl %ecx, %ecx
testq %rax, %rax
setne %cl
leal 0x2(,%rcx,8), %edi
movl %edi, 0x15c(%rsp)
movq %r14, %rsi
movq %r13, %rdx
callq 0x10960
xorl %r14d, %r14d
cmpl $0x1, %eax
setne %r14b
movl $0x1, %r15d
jmp 0x2b093
xorl %r15d, %r15d
jmp 0x2b093
movl %r12d, %r13d
movl $0x100, %eax            # imm = 0x100
cmpq %rax, %r13
movl $0x100, %edx            # imm = 0x100
cmovbq %r13, %rdx
leaq 0x10(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0xfa60
cmpb $0x2e, 0x17f(%rsp,%r13)
je 0x2b04e
cmpl $0xff, %r12d
ja 0x2b04b
movb $0x2e, 0x10(%rsp,%r13)
incq %r13
incl %r15d
movl $0xff, %eax
cmpq %rax, %r13
cmovaeq %rax, %r13
movb $0x0, 0x10(%rsp,%r13)
movl 0x15c(%rsp), %esi
xorl %r8d, %r8d
cmpl $0x3, %r15d
setae %r8b
movq 0x8(%rsp), %rdi
leaq 0x160(%rsp), %r13
movq %r13, %rdx
leaq 0x10(%rsp), %rcx
callq 0xf720
testl %eax, %eax
jne 0x2b0a7
xorl %eax, %eax
cmpl $0xa, %ebp
je 0x2af14
cmpl $-0x1, %ebp
jne 0x2af2b
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq