// File: /workspace/github_c_makefile_star2_O3/wahern[P]cqueues/src/lib/dns.c
// Function: dns_resconf_loadfile
int dns_resconf_loadfile(struct dns_resolv_conf *resconf, FILE *fp) {
	unsigned sa_count	= 0;
	char words[6][DNS_D_MAXNAME + 1];
	unsigned wp, wc, i, j, n;
	int ch, error;

	rewind(fp);

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

		while (EOF != (ch = getc(fp)) && ch != '\n') {
			if (dns_resconf_issep(ch)) {
				if (wp > 0) {
					wp	= 0;

					if (++wc >= lengthof(words))
						goto skip;
				}
			} else if (dns_resconf_iscom(ch)) {
skip:
				do {
					ch	= getc(fp);
				} while (ch != EOF && ch != '\n');

				break;
			} else if (wp < sizeof words[wc] - 1) {
				words[wc][wp++] = ch;
			} else {
				wp = 0; /* drop word */
				goto skip;
			}
		}

		if (wp > 0)
			wc++;

		if (wc < 2)
			continue;

		switch (dns_resconf_keyword(words[0])) {
		case DNS_RESCONF_NAMESERVER:
			if (sa_count >= lengthof(resconf->nameserver))
				continue;

			if ((error = dns_resconf_pton(&resconf->nameserver[sa_count], words[1])))
				continue;

			sa_count++;

			break;
		case DNS_RESCONF_DOMAIN:
		case DNS_RESCONF_SEARCH:
			memset(resconf->search, '\0', sizeof resconf->search);

			for (i = 1, j = 0; i < wc && j < lengthof(resconf->search); i++, j++)
				dns_d_anchor(resconf->search[j], sizeof resconf->search[j], words[i], strlen(words[i]));

			break;
		case DNS_RESCONF_LOOKUP:
			for (i = 1, j = 0; i < wc && j < lengthof(resconf->lookup); i++) {
				switch (dns_resconf_keyword(words[i])) {
				case DNS_RESCONF_FILE:
					resconf->lookup[j++]	= 'f';

					break;
				case DNS_RESCONF_BIND:
					resconf->lookup[j++]	= 'b';

					break;
				case DNS_RESCONF_CACHE:
					resconf->lookup[j++]	= 'c';

					break;
				default:
					break;
				} /* switch() */
			} /* for() */

			break;
		case DNS_RESCONF_FAMILY:
			for (i = 1, j = 0; i < wc && j < lengthof(resconf->family); i++) {
				switch (dns_resconf_keyword(words[i])) {
				case DNS_RESCONF_INET4:
					resconf->family[j++]	= AF_INET;

					break;
				case DNS_RESCONF_INET6:
					resconf->family[j++]	= AF_INET6;

					break;
				default:
					break;
				}
			}

			break;
		case DNS_RESCONF_OPTIONS:
			for (i = 1; i < wc; i++) {
				switch (dns_resconf_keyword(words[i])) {
				case DNS_RESCONF_EDNS0:
					resconf->options.edns0	= 1;

					break;
				case DNS_RESCONF_NDOTS:
					for (j = sizeof "ndots:" - 1, n = 0; dns_isdigit(words[i][j]); j++) {
						n	*= 10;
						n	+= words[i][j] - '0';
					} /* for() */

					resconf->options.ndots	= n;

					break;
				case DNS_RESCONF_TIMEOUT:
					for (j = sizeof "timeout:" - 1, n = 0; dns_isdigit(words[i][j]); j++) {
						n	*= 10;
						n	+= words[i][j] - '0';
					} /* for() */

					resconf->options.timeout	= n;

					break;
				case DNS_RESCONF_ATTEMPTS:
					for (j = sizeof "attempts:" - 1, n = 0; dns_isdigit(words[i][j]); j++) {
						n	*= 10;
						n	+= words[i][j] - '0';
					} /* for() */

					resconf->options.attempts	= n;

					break;
				case DNS_RESCONF_ROTATE:
					resconf->options.rotate		= 1;

					break;
				case DNS_RESCONF_RECURSE:
					resconf->options.recurse	= 1;

					break;
				case DNS_RESCONF_SMART:
					resconf->options.smart		= 1;

					break;
				case DNS_RESCONF_TCP:
					resconf->options.tcp		= DNS_RESCONF_TCP_ONLY;

					break;
				case DNS_RESCONF_TCPx:
					switch (dns_resconf_keyword(&words[i][sizeof "tcp:" - 1])) {
					case DNS_RESCONF_ENABLE:
						resconf->options.tcp	= DNS_RESCONF_TCP_ENABLE;

						break;
					case DNS_RESCONF_ONE:
					case DNS_RESCONF_ONLY:
						resconf->options.tcp	= DNS_RESCONF_TCP_ONLY;

						break;
					case DNS_RESCONF_ZERO:
					case DNS_RESCONF_DISABLE:
						resconf->options.tcp	= DNS_RESCONF_TCP_DISABLE;

						break;
					default:
						break;
					} /* switch() */

					break;
				default:
					break;
				} /* switch() */
			} /* for() */

			break;
		case DNS_RESCONF_INTERFACE:
			for (i = 0, n = 0; dns_isdigit(words[2][i]); i++) {
				n	*= 10;
				n	+= words[2][i] - '0';
			}

			dns_resconf_setiface(resconf, words[1], n);

			break;
		default:
			break;
		} /* switch() */
	} while (ch != EOF);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x628, %rsp            # imm = 0x628
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0xf150
movq %rbx, (%rsp)
leaq 0x180(%rbx), %rax
movq %rax, 0x18(%rsp)
xorl %ebx, %ebx
movq %r14, 0x10(%rsp)
movq %rbx, 0x8(%rsp)
movl $0x600, %edx            # imm = 0x600
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0xf750
xorl %r12d, %r12d
movl %r12d, %eax
xorl %r15d, %r15d
shlq $0x8, %rax
leaq (%rsp,%rax), %rbx
addq $0x20, %rbx
movq %r14, %rdi
callq 0xf360
movl %eax, %ebp
cmpl $-0x1, %eax
je 0x2ba76
cmpl $0xa, %ebp
je 0x2ba76
callq 0xfe30
cmpl $0x2c, %ebp
je 0x2ba58
movq (%rax), %rax
movzbl %bpl, %ecx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
jne 0x2ba58
cmpl $0x3b, %ebp
je 0x2ba7e
cmpl $0x23, %ebp
je 0x2ba7e
cmpl $0xfe, %r15d
ja 0x2ba7b
movl %r15d, %eax
incl %r15d
movb %bpl, (%rax,%rbx)
jmp 0x2ba09
testl %r15d, %r15d
movl $0x0, %r15d
je 0x2ba09
leal 0x1(%r12), %r13d
cmpl $0x4, %r12d
movl %r13d, %r12d
jbe 0x2b9f7
xorl %r15d, %r15d
jmp 0x2ba81
movl %r12d, %r13d
jmp 0x2ba95
xorl %r15d, %r15d
movl %r12d, %r13d
movq %r14, %rdi
callq 0xf360
movl %eax, %ebp
cmpl $-0x1, %eax
je 0x2ba95
cmpl $0xa, %ebp
jne 0x2ba81
cmpl $0x1, %r15d
sbbl $-0x1, %r13d
cmpl $0x2, %r13d
jb 0x2be63
leaq 0x20(%rsp), %rdi
callq 0x2bec5
cmpl $0xa, %eax
ja 0x2bb94
movl %eax, %eax
leaq 0xb03d(%rip), %rcx      # 0x36b00
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x400, %edx            # imm = 0x400
movq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0xf750
movl %r13d, %r13d
movl $0x2, %r14d
xorl %ebx, %ebx
leaq (%rsp,%rbx), %r12
addq $0x120, %r12            # imm = 0x120
movq %r12, %rdi
callq 0xf560
testq %rax, %rax
je 0x2bb6e
movq %rax, %r15
movq (%rsp), %rax
leaq (%rax,%rbx), %rdi
addq $0x180, %rdi            # imm = 0x180
movl $0x100, %eax            # imm = 0x100
cmpq %rax, %r15
movl $0x100, %edx            # imm = 0x100
cmovbq %r15, %rdx
movq %r12, %rsi
callq 0xfa60
leaq 0x20(%rsp), %rax
addq %r15, %rax
cmpb $0x2e, 0xff(%rbx,%rax)
je 0x2bb55
cmpq $0xff, %r15
ja 0x2bb52
movq 0x18(%rsp), %rax
addq %r15, %rax
movb $0x2e, (%rbx,%rax)
incq %r15
movl $0xff, %eax
cmpq %rax, %r15
cmovaeq %rax, %r15
addq (%rsp), %r15
movb $0x0, 0x180(%rbx,%r15)
cmpq %r13, %r14
jae 0x2be5e
leaq -0x2(%r14), %rax
addq $0x100, %rbx            # imm = 0x100
incq %r14
cmpq $0x3, %rax
jb 0x2bae8
jmp 0x2be5e
cmpl $0x14, %eax
jne 0x2be63
callq 0xfe30
movq (%rax), %rax
movzbl 0x220(%rsp), %esi
testb $0x8, 0x1(%rax,%rsi,2)
movq 0x8(%rsp), %rbx
jne 0x2be73
xorl %ecx, %ecx
jmp 0x2be9b
movl %r13d, %r12d
movl $0x1, %r13d
movq %r13, %rbx
shlq $0x8, %rbx
leaq (%rsp,%rbx), %r15
addq $0x20, %r15
movq %r15, %rdi
callq 0x2bec5
addl $-0xb, %eax
cmpl $0x8, %eax
ja 0x2bd51
leaq 0xaf35(%rip), %rcx      # 0x36b2c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rsp), %rax
movb $0x1, 0x5b0(%rax)
jmp 0x2bd51
movq (%rsp), %rax
movb $0x1, 0x5c0(%rax)
jmp 0x2bd51
callq 0xfe30
movq (%rax), %rax
movzbl 0x28(%rsp,%rbx), %edx
xorl %ecx, %ecx
testb $0x8, 0x1(%rax,%rdx,2)
je 0x2bc59
xorl %ecx, %ecx
movl $0x9, %esi
leal (%rcx,%rcx,4), %ecx
movsbl %dl, %edx
leal (%rdx,%rcx,2), %ecx
addl $-0x30, %ecx
movl %esi, %edx
movzbl (%rdx,%r15), %edx
incl %esi
testb $0x8, 0x1(%rax,%rdx,2)
jne 0x2bc3d
movq (%rsp), %rax
movl %ecx, 0x5b8(%rax)
jmp 0x2bd51
callq 0xfe30
movq (%rax), %rax
movzbl 0x29(%rsp,%rbx), %edx
xorl %ecx, %ecx
testb $0x8, 0x1(%rax,%rdx,2)
je 0x2bca1
xorl %ecx, %ecx
movl $0xa, %esi
leal (%rcx,%rcx,4), %ecx
movsbl %dl, %edx
leal (%rdx,%rcx,2), %ecx
addl $-0x30, %ecx
movl %esi, %edx
movzbl (%rdx,%r15), %edx
incl %esi
testb $0x8, 0x1(%rax,%rdx,2)
jne 0x2bc85
movq (%rsp), %rax
movl %ecx, 0x5bc(%rax)
jmp 0x2bd51
callq 0xfe30
movq (%rax), %rax
movzbl 0x26(%rsp,%rbx), %edx
xorl %ecx, %ecx
testb $0x8, 0x1(%rax,%rdx,2)
je 0x2bce9
xorl %ecx, %ecx
movl $0x7, %esi
leal (%rcx,%rcx,4), %ecx
movsbl %dl, %edx
leal (%rdx,%rcx,2), %ecx
addl $-0x30, %ecx
movl %esi, %edx
movzbl (%rdx,%r15), %edx
incl %esi
testb $0x8, 0x1(%rax,%rdx,2)
jne 0x2bccd
movq (%rsp), %rax
movl %ecx, 0x5b4(%rax)
jmp 0x2bd51
movq (%rsp), %rax
movb $0x1, 0x5c1(%rax)
jmp 0x2bd51
movq (%rsp), %rax
movb $0x1, 0x5c2(%rax)
jmp 0x2bd51
addq $0x4, %r15
movq %r15, %rdi
callq 0x2bec5
addl $-0x15, %eax
cmpl $0x4, %eax
ja 0x2bd51
leaq 0xae26(%rip), %rcx      # 0x36b50
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rsp), %rax
movl $0x2, 0x5c4(%rax)
jmp 0x2bd51
movq (%rsp), %rax
movl $0x1, 0x5c4(%rax)
incq %r13
cmpq %r12, %r13
jne 0x2bbcd
jmp 0x2be63
movq (%rsp), %rax
movl $0x0, 0x5c4(%rax)
jmp 0x2bd51
movl %r13d, %ebx
xorl %r13d, %r13d
movl $0x2, %r14d
leaq 0x120(%rsp), %r15
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x2bec5
addl $-0x4, %eax
cmpl $0x2, %eax
ja 0x2bdb4
shll $0x3, %eax
movl $0x636266, %edx         # imm = 0x636266
movl %eax, %ecx
shrl %cl, %edx
incl %r12d
movq (%rsp), %rax
movb %dl, 0x580(%rax,%r13)
cmpq %rbx, %r14
jae 0x2be5e
addq $0x100, %r15            # imm = 0x100
incq %r14
movl %r12d, %r13d
cmpl $0x24, %r12d
jb 0x2bd89
jmp 0x2be5e
movq 0x8(%rsp), %rbx
cmpl $0x2, %ebx
ja 0x2be68
movl %ebx, %edi
shlq $0x7, %rdi
addq (%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x10950
cmpl $0x1, %eax
adcl $0x0, %ebx
jmp 0x2be68
movl %r13d, %ebx
xorl %r13d, %r13d
movl $0x2, %r14d
leaq 0x120(%rsp), %r15
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x2bec5
cmpl $0x8, %eax
je 0x2be32
cmpl $0x9, %eax
jne 0x2be46
movl $0xa, %eax
jmp 0x2be37
movl $0x2, %eax
incl %r12d
movq (%rsp), %rcx
movl %eax, 0x5a4(%rcx,%r13,4)
cmpq %rbx, %r14
jae 0x2be5e
addq $0x100, %r15            # imm = 0x100
incq %r14
movl %r12d, %r13d
cmpl $0x3, %r12d
jb 0x2be19
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %rbx
cmpl $-0x1, %ebp
jne 0x2b9de
jmp 0x2beb1
movl $0x1, %edx
xorl %ecx, %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
movsbl %sil, %esi
addl %esi, %ecx
addl $-0x30, %ecx
movl %edx, %esi
movzbl 0x220(%rsp,%rsi), %esi
incl %edx
testb $0x8, 0x1(%rax,%rsi,2)
jne 0x2be7a
movzwl %cx, %edx
movq (%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0xfe80
jmp 0x2be68
xorl %eax, %eax
addq $0x628, %rsp            # imm = 0x628
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq