// File: /workspace/github_c_makefile_star2_O1/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, 0x18(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movl $0x0, 0x40(%rsp)
movq %rsi, %rdi
callq 0x104e0
testl %eax, %eax
je 0x2c45f
cmpb $0x0, 0x20(%rsp)
je 0x2c44b
movq 0x18(%rsp), %rdi
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
leaq 0x50(%rsp), %r12
leaq 0xc(%rsp), %rbx
leaq 0x1a720(%rip), %r15     # 0x46b90
movq %r14, %rdi
callq 0x10900
testl %eax, %eax
jne 0x2c429
movl $0x0, 0xd0(%rsp)
leaq 0xd4(%rsp), %rax
movq %rax, 0x4e0(%rsp)
movq %rax, 0x4d8(%rsp)
leaq 0x9acf(%rip), %rdi      # 0x35f75
movq %r14, %rsi
callq 0x2c816
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2c874
testq %rax, %rax
je 0x2c4e9
movq 0x50(%rsp), %rbp
xorl %ebx, %ebx
movq 0x8(%r15,%rbx,8), %rdi
movq %rbp, %rsi
callq 0xfe40
testl %eax, %eax
je 0x2c4e4
incq %rbx
cmpq $0xa, %rbx
jne 0x2c4c8
jmp 0x2c4e9
testq %rbx, %rbx
je 0x2c512
leaq 0xcb6a(%rip), %rdi      # 0x3905a
movq %r14, %rsi
callq 0x2c816
movq %r14, %rdi
callq 0x104e0
testl %eax, %eax
leaq 0xc(%rsp), %rbx
je 0x2c470
jmp 0x2c429
movl 0xd0(%rsp), %eax
testl %eax, %eax
je 0x2c544
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 0xcaf8(%rip), %rdi      # 0x39043
movq %r14, %rsi
callq 0x2c816
testq %rax, %rax
je 0x2c4e9
movb $0x0, 0x20(%rsp)
movq %r12, %rdi
movq %r14, %rsi
leaq 0xc(%rsp), %rdx
callq 0x2c874
testq %rax, %rax
je 0x2c4e9
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0xcac2(%rip), %rdi      # 0x39049
movq %r14, %rsi
callq 0x2c816
movq %r14, %rdi
callq 0xf360
movl %eax, %ebp
movl %eax, %edi
movq %r14, %rsi
callq 0xf1a0
cmpl $0x5b, %ebp
jne 0x2c66f
leaq 0xca94(%rip), %rdi      # 0x39047
movq %r14, %rsi
callq 0x2c816
movq %r12, %rdi
movq %r14, %rsi
leaq 0xc(%rsp), %rbx
movq %rbx, %rdx
callq 0x2c874
testq %rax, %rax
leaq 0xca71(%rip), %r13      # 0x39049
leaq 0xca6d(%rip), %rbp      # 0x3904c
je 0x2c660
movq %rbp, %rdi
movq %r14, %rsi
callq 0x2c816
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2c874
testq %rax, %rax
je 0x2c61f
movq %r13, %rdi
movq %r14, %rsi
callq 0x2c816
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2c874
testq %rax, %rax
jne 0x2c5e1
jmp 0x2c660
movl 0xd0(%rsp), %eax
testl %eax, %eax
je 0x2c651
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 0xc9f8(%rip), %rdi      # 0x39050
movq %r14, %rsi
callq 0x2c816
leaq 0xc9ef(%rip), %rdi      # 0x39056
movq %r14, %rsi
callq 0x2c816
leaq 0x44(%rsp), %rax
subq 0x10(%rsp), %rax
movl 0xd0(%rsp), %ecx
incl %ecx
cmpq %rcx, %rax
jb 0x2c7c8
movl $0x1, %ebx
movq 0x50(%rsp), %rbp
movq (%r15,%rbx,8), %rdi
movq %rbp, %rsi
callq 0xfe40
testl %eax, %eax
je 0x2c6b0
incq %rbx
cmpq $0xb, %rbx
jne 0x2c695
xorl %ebx, %ebx
leal -0x8(%rbx), %eax
cmpl $0x2, %eax
ja 0x2c7c8
leal -0xb(%rbx), %ecx
movb $0x3f, %al
cmpl $-0x9, %ecx
jb 0x2c6d2
movl %ebx, %eax
leaq 0xc091(%rip), %rcx      # 0x38760
movb (%rax,%rcx), %al
movq 0x10(%rsp), %rcx
movb %al, (%rcx)
incq %rcx
movq %rcx, 0x10(%rsp)
cmpl $0x3, 0xd0(%rsp)
jb 0x2c7c8
movl $0x1, %r12d
movl $0x2, %ebx
movq 0x50(%rsp,%r12,8), %rbp
movl $0x1, %r13d
movq (%r15,%r13,8), %rdi
movq %rbp, %rsi
callq 0xfe40
testl %eax, %eax
je 0x2c721
incq %r13
cmpq $0xb, %r13
jne 0x2c705
xorl %r13d, %r13d
movq 0x50(%rsp,%rbx,8), %rbp
movl $0x1, %ebx
movq (%r15,%rbx,8), %rdi
movq %rbp, %rsi
callq 0xfe40
testl %eax, %eax
je 0x2c746
incq %rbx
cmpq $0xb, %rbx
jne 0x2c72b
xorl %ebx, %ebx
leal -0x2(%r13), %eax
cmpl $0x3, %eax
ja 0x2c7a9
movb $0x3f, %al
movb $0x3f, %cl
cmpl $0x2, %r13d
jb 0x2c766
movl %r13d, %ecx
leaq 0xbffd(%rip), %rdx      # 0x38760
movb (%rcx,%rdx), %cl
movq 0x10(%rsp), %rdx
movb %cl, (%rdx)
movl %ebx, %edx
andl $-0x2, %edx
xorl %ecx, %ecx
cmpl $0x2, %r13d
sete %cl
orl $0x6, %ecx
cmpl $0x6, %edx
cmovel %ebx, %ecx
leal -0xb(%rcx), %edx
cmpl $-0x9, %edx
jb 0x2c798
movl %ecx, %eax
leaq 0xbfcb(%rip), %rcx      # 0x38760
movb (%rax,%rcx), %al
movq 0x10(%rsp), %rcx
movb %al, 0x1(%rcx)
addq $0x2, %rcx
movq %rcx, 0x10(%rsp)
leaq 0x2(%r12), %rax
addq $0x3, %r12
movl 0xd0(%rsp), %ecx
movq %r12, %rbx
cmpq %rcx, %r12
movq %rax, %r12
jb 0x2c6fa
movq 0x10(%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 0xc(%rsp), %rdx
callq 0x2c874
testq %rax, %rax
jne 0x2c580
jmp 0x2c4e9