// File: /workspace/github_c_makefile_star2_O3/wahern[P]cqueues/src/lib/dns.c
// Function: dns_nssconf_loadfile
DNS_PRAGMA_POP


int dns_nssconf_loadfile(struct dns_resolv_conf *resconf, FILE *fp) {
	enum dns_nssconf_keyword source, status, action;
	char lookup[sizeof resconf->lookup] = "", *lp;
	struct dns_anyconf cf;
	size_t i;
	int error;

	while (!feof(fp) && !ferror(fp)) {
		dns_anyconf_reset(&cf);

		dns_anyconf_skip("%s", fp);

		if (!dns_anyconf_scan(&cf, "%w_", fp, &error))
			goto nextent;

		if (DNS_NSSCONF_HOSTS != dns_nssconf_keyword(cf.token[0]))
			goto nextent;

		dns_anyconf_pop(&cf);

		if (!dns_anyconf_skip(": \t", fp))
			goto nextent;

		*(lp = lookup) = '\0';

		while (dns_anyconf_scan(&cf, "%w_", fp, &error)) {
			dns_anyconf_skip(" \t", fp);

			if ('[' == dns_anyconf_peek(fp)) {
				dns_anyconf_skip("[! \t", fp);

				while (dns_anyconf_scan(&cf, "%w_", fp, &error)) {
					dns_anyconf_skip("= \t", fp);
					if (!dns_anyconf_scan(&cf, "%w_", fp, &error)) {
						dns_anyconf_pop(&cf); /* discard status */
						dns_anyconf_skip("^#;]\n", fp); /* skip to end of criteria */
						break;
					}
					dns_anyconf_skip(" \t", fp);
				}

				dns_anyconf_skip("] \t", fp);
			}

			if ((size_t)(endof(lookup) - lp) < cf.count + 1) /* +1 for '\0' */
				goto nextsrc;

			source = dns_nssconf_keyword(cf.token[0]);

			switch (source) {
			case DNS_NSSCONF_DNS:
			case DNS_NSSCONF_MDNS:
			case DNS_NSSCONF_FILES:
				*lp++ = dns_nssconf_k2c(source);
				break;
			default:
				goto nextsrc;
			}

			for (i = 1; i + 1 < cf.count; i += 2) {
				status = dns_nssconf_keyword(cf.token[i]);
				action = dns_nssconf_keyword(cf.token[i + 1]);

				switch (status) {
				case DNS_NSSCONF_SUCCESS:
				case DNS_NSSCONF_NOTFOUND:
				case DNS_NSSCONF_UNAVAIL:
				case DNS_NSSCONF_TRYAGAIN:
					*lp++ = dns_nssconf_k2c(status);
					break;
				default:
					continue;
				}

				switch (action) {
				case DNS_NSSCONF_CONTINUE:
				case DNS_NSSCONF_RETURN:
					break;
				default:
					action = (status == DNS_NSSCONF_SUCCESS)
					       ? DNS_NSSCONF_RETURN
					       : DNS_NSSCONF_CONTINUE;
					break;
				}

				*lp++ = dns_nssconf_k2c(action);
			}
nextsrc:
			*lp = '\0';
			dns_anyconf_reset(&cf);
		}
nextent:
		dns_anyconf_skip("^\n", fp);
	}

	if (*lookup)
		strncpy(resconf->lookup, lookup, sizeof resconf->lookup);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4e8, %rsp            # imm = 0x4E8
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movl $0x0, 0x40(%rsp)
movq %rsi, %rdi
callq 0x104e0
testl %eax, %eax
jne 0x2c406
movq %rbx, 0x18(%rsp)
leaq 0x50(%rsp), %r12
leaq 0x14(%rsp), %r13
leaq 0x1ab45(%rip), %r15     # 0x46b90
movq %r14, %rdi
callq 0x10900
testl %eax, %eax
jne 0x2c3e4
movl $0x0, 0xd0(%rsp)
leaq 0xd4(%rsp), %rax
movq %rax, 0x4e0(%rsp)
movq %rax, 0x4d8(%rsp)
leaq 0x9ec8(%rip), %rdi      # 0x35f4d
movq %r14, %rsi
callq 0x2c41a
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x2c478
testq %rax, %rax
je 0x2c0c8
movq 0x50(%rsp), %rbp
xorl %ebx, %ebx
movq 0x8(%r15,%rbx,8), %rdi
movq %rbp, %rsi
callq 0xfe40
testl %eax, %eax
je 0x2c0c3
incq %rbx
cmpq $0xa, %rbx
jne 0x2c0a7
jmp 0x2c0c8
testq %rbx, %rbx
je 0x2c0ec
leaq 0xcf4b(%rip), %rdi      # 0x3901a
movq %r14, %rsi
callq 0x2c41a
movq %r14, %rdi
callq 0x104e0
testl %eax, %eax
je 0x2c04b
jmp 0x2c3e4
movl 0xd0(%rsp), %eax
testl %eax, %eax
je 0x2c11e
decl %eax
movl %eax, 0xd0(%rsp)
movq 0x50(%rsp,%rax,8), %rcx
movq %rcx, 0x4e0(%rsp)
movq %rcx, 0x4d8(%rsp)
movq $0x0, 0x50(%rsp,%rax,8)
leaq 0xcede(%rip), %rdi      # 0x39003
movq %r14, %rsi
callq 0x2c41a
testq %rax, %rax
je 0x2c0c8
movb $0x0, 0x20(%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x2c478
testq %rax, %rax
je 0x2c0c8
leaq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0xceaa(%rip), %rbx      # 0x39009
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2c41a
movq %r14, %rdi
callq 0xf360
movl %eax, %ebp
movl %eax, %edi
movq %r14, %rsi
callq 0xf1a0
cmpl $0x5b, %ebp
jne 0x2c23e
leaq 0xce79(%rip), %rdi      # 0x39007
movq %r14, %rsi
callq 0x2c41a
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x2c478
testq %rax, %rax
leaq 0xce5e(%rip), %rbp      # 0x3900c
je 0x2c22f
movq %rbp, %rdi
movq %r14, %rsi
callq 0x2c41a
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x2c478
testq %rax, %rax
je 0x2c1ee
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2c41a
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x2c478
testq %rax, %rax
jne 0x2c1b0
jmp 0x2c22f
movl 0xd0(%rsp), %eax
testl %eax, %eax
je 0x2c220
decl %eax
movl %eax, 0xd0(%rsp)
movq 0x50(%rsp,%rax,8), %rcx
movq %rcx, 0x4e0(%rsp)
movq %rcx, 0x4d8(%rsp)
movq $0x0, 0x50(%rsp,%rax,8)
leaq 0xcde9(%rip), %rdi      # 0x39010
movq %r14, %rsi
callq 0x2c41a
leaq 0xcde0(%rip), %rdi      # 0x39016
movq %r14, %rsi
callq 0x2c41a
leaq 0x44(%rsp), %rax
subq 0x8(%rsp), %rax
movl 0xd0(%rsp), %ecx
incl %ecx
cmpq %rcx, %rax
jb 0x2c393
movq 0x50(%rsp), %rbp
xorl %ebx, %ebx
movq 0x8(%r15,%rbx,8), %rdi
movq %rbp, %rsi
callq 0xfe40
testl %eax, %eax
je 0x2c280
incq %rbx
cmpq $0xa, %rbx
jne 0x2c261
jmp 0x2c393
leal -0x7(%rbx), %eax
cmpl $0x2, %eax
ja 0x2c393
leaq 0xc47d(%rip), %rax      # 0x38710
movb 0x1(%rbx,%rax), %al
movq 0x8(%rsp), %rcx
movb %al, (%rcx)
incq %rcx
movq %rcx, 0x8(%rsp)
movl 0xd0(%rsp), %edx
cmpl $0x3, %edx
jb 0x2c393
movl $0x1, %r12d
movl $0x2, %r13d
movl %edx, 0x10(%rsp)
movq 0x50(%rsp,%r12,8), %rbp
movl $0x1, %ebx
movq (%r15,%rbx,8), %rdi
movq %rbp, %rsi
callq 0xfe40
testl %eax, %eax
je 0x2c2eb
incq %rbx
cmpq $0xb, %rbx
jne 0x2c2d0
xorl %ebx, %ebx
movq 0x50(%rsp,%r13,8), %rbp
movl $0x1, %r13d
movq (%r15,%r13,8), %rdi
movq %rbp, %rsi
callq 0xfe40
testl %eax, %eax
je 0x2c312
incq %r13
cmpq $0xb, %r13
jne 0x2c2f6
xorl %r13d, %r13d
leal -0x2(%rbx), %eax
cmpl $0x3, %eax
ja 0x2c375
movl %r13d, %ecx
andl $-0x2, %ecx
xorl %eax, %eax
cmpl $0x2, %ebx
movl %ebx, %edx
leaq 0xc3e2(%rip), %rsi      # 0x38710
movb (%rdx,%rsi), %dl
sete %al
orl $0x6, %eax
cmpl $0x6, %ecx
cmovel %r13d, %eax
movq 0x8(%rsp), %rcx
movb %dl, (%rcx)
leal -0xb(%rax), %edx
movb $0x3f, %cl
cmpl $-0x9, %edx
jb 0x2c35b
movl %eax, %eax
leaq 0xc3b8(%rip), %rcx      # 0x38710
movb (%rax,%rcx), %cl
movq 0x8(%rsp), %rax
movb %cl, 0x1(%rax)
addq $0x2, %rax
movq %rax, 0x8(%rsp)
movl 0xd0(%rsp), %edx
jmp 0x2c379
movl 0x10(%rsp), %edx
leaq 0x2(%r12), %rax
addq $0x3, %r12
movl %edx, %ecx
movq %r12, %r13
cmpq %rcx, %r12
movq %rax, %r12
jb 0x2c2c2
movq 0x8(%rsp), %rax
movb $0x0, (%rax)
movl $0x0, 0xd0(%rsp)
leaq 0xd4(%rsp), %rax
movq %rax, 0x4e0(%rsp)
movq %rax, 0x4d8(%rsp)
leaq 0x50(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
leaq 0x14(%rsp), %r13
movq %r13, %rdx
callq 0x2c478
testq %rax, %rax
jne 0x2c158
jmp 0x2c0c8
cmpb $0x0, 0x20(%rsp)
movq 0x18(%rsp), %rdi
je 0x2c406
addq $0x580, %rdi            # imm = 0x580
leaq 0x20(%rsp), %rsi
movl $0x24, %edx
callq 0xf680
xorl %eax, %eax
addq $0x4e8, %rsp            # imm = 0x4E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq