// File: /workspace/github_c_makefile_star2_O3/wahern[P]cqueues/src/lib/dns.c
// Function: dns_resconf_search
size_t dns_resconf_search(void *dst, size_t lim, const void *qname, size_t qlen, struct dns_resolv_conf *resconf, dns_resconf_i_t *state) {
	unsigned pc, srchi, ndots, len;

	DNS_SM_ENTER;

	/* if FQDN then return as-is and finish */
	if (dns_d_isanchored(qname, qlen)) {
		len = dns_d_anchor(dst, lim, qname, qlen);
		DNS_SM_YIELD(len);
		DNS_SM_EXIT;
	}

	ndots = dns_d_ndots(qname, qlen);

	if (ndots >= resconf->options.ndots) {
		len = dns_d_anchor(dst, lim, qname, qlen);
		DNS_SM_YIELD(len);
	}

	while (srchi < lengthof(resconf->search) && resconf->search[srchi][0]) {
		struct dns_buf buf = DNS_B_INTO(dst, lim);
		const char *dn = resconf->search[srchi++];

		dns_b_put(&buf, qname, qlen);
		dns_b_putc(&buf, '.');
		dns_b_puts(&buf, dn);
		if (!dns_d_isanchored(dn, strlen(dn)))
			dns_b_putc(&buf, '.');
		len = dns_b_strllen(&buf);
		DNS_SM_YIELD(len);
	}

	if (ndots < resconf->options.ndots) {
		len = dns_d_anchor(dst, lim, qname, qlen);
		DNS_SM_YIELD(len);
	}

	DNS_SM_LEAVE;

	return dns_strlcpy(dst, "", lim);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %r14
movq %r8, %rbp
movq %rdx, %r8
movq %rsi, %r12
movl (%r9), %r13d
movl %r13d, %r15d
shrl $0x8, %r15d
movl $0xff, %eax
andl %eax, %r15d
movl %r13d, %ebx
shrl $0x10, %ebx
andl %eax, %ebx
andl %r13d, %eax
cmpl $0xc, %eax
jle 0x2c8a2
cmpl $0xd, %eax
je 0x2c967
cmpl $0x1a, %eax
je 0x2c967
cmpl $0x1f, %eax
je 0x2ca21
jmp 0x2ca34
testl %eax, %eax
je 0x2c8b4
cmpl $0x5, %eax
je 0x2ca21
jmp 0x2ca34
testq %rcx, %rcx
movq %rdi, 0x8(%rsp)
je 0x2c8f7
cmpb $0x2e, -0x1(%r8,%rcx)
jne 0x2c8f7
cmpq %rcx, %r12
movq %rcx, %rdx
cmovbq %r12, %rdx
movq %r8, %rsi
movq %rcx, %rbp
movq %r8, %r13
callq 0x105f0
movq %rbp, %rcx
cmpb $0x2e, -0x1(%r13,%rbp)
jne 0x2cbb5
movq 0x8(%rsp), %rax
jmp 0x2cbc6
movq %r14, 0x18(%rsp)
movq %r8, %rdi
movl $0x2e, %esi
movq %rcx, %rdx
movq %rcx, %rbx
movq %r8, %r14
callq 0xfe90
testq %rax, %rax
movq %rbx, 0x10(%rsp)
movq %r14, 0x30(%rsp)
je 0x2c945
addq %rbx, %r14
xorl %ebx, %ebx
incl %ebx
incq %rax
movq %r14, %rdx
subq %rax, %rdx
movq %rax, %rdi
movl $0x2e, %esi
callq 0xfe90
testq %rax, %rax
jne 0x2c926
jmp 0x2c947
xorl %ebx, %ebx
cmpl %ebx, 0x5b4(%rbp)
jbe 0x2cad2
movq 0x18(%rsp), %r14
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rcx
movq 0x30(%rsp), %r8
cmpl $0x3, %r15d
ja 0x2c9da
movl %r15d, %eax
shll $0x8, %eax
cmpb $0x0, 0x180(%rbp,%rax)
je 0x2c9da
addq %rbp, %rax
addq $0x180, %rax            # imm = 0x180
movq %rax, 0x28(%rsp)
leaq (%rdi,%r12), %rax
movq %rax, 0x20(%rsp)
cmpq %rcx, %r12
movq %rcx, %r15
cmovbq %r12, %r15
movq %rdi, 0x8(%rsp)
movq 0x8(%rsp), %rdi
movq %r8, %rsi
movq %r15, %rdx
movq %rcx, %rbp
callq 0xfa60
movq 0x8(%rsp), %rax
leaq (%rax,%r15), %rcx
xorl %eax, %eax
subq %r12, %rbp
cmovaeq %rbp, %rax
cmpq %r12, %r15
movq %r14, 0x18(%rsp)
jge 0x2ca43
movb $0x2e, (%rcx)
incq %rcx
jmp 0x2ca46
cmpl 0x5b4(%rbp), %ebx
jae 0x2ca21
testq %rcx, %rcx
je 0x2cb1d
cmpq %rcx, %r12
movq %rcx, %rdx
cmovbq %r12, %rdx
movq %rdi, 0x8(%rsp)
movq %r8, %rsi
movq %rcx, %rbp
movq %r8, %r13
callq 0x105f0
movq %rbp, %rcx
cmpb $0x2e, -0x1(%r13,%rbp)
jne 0x2cb21
movq 0x8(%rsp), %rax
jmp 0x2cb32
shll $0x8, %r15d
movzbl %bl, %eax
shll $0x10, %eax
addl %r15d, %eax
addl $0x22, %eax
movq %rax, (%r14)
testq %r12, %r12
jle 0x2ca3c
movb $0x0, (%rdi)
xorl %eax, %eax
jmp 0x2cc28
incq %rax
movq %rax, 0x10(%rsp)
movq %rcx, %rbp
movq 0x28(%rsp), %rdi
callq 0xf560
movq %rax, %r14
movq 0x20(%rsp), %r12
subq %rbp, %r12
cmpq %rax, %r12
movq %rax, %r15
cmovbq %r12, %r15
movq %rbp, %rdi
movq 0x28(%rsp), %rsi
movq %r15, %rdx
callq 0xfa60
addq %rbp, %r15
subq %r12, %r14
movl $0x0, %r12d
cmovaeq %r14, %r12
movq 0x28(%rsp), %r14
addq 0x10(%rsp), %r12
movq %r14, %rdi
callq 0xf560
testq %rax, %rax
je 0x2cab6
cmpb $0x2e, -0x1(%r14,%rax)
jne 0x2cab6
movq 0x18(%rsp), %rdx
jmp 0x2cb5e
cmpq 0x20(%rsp), %r15
movq 0x18(%rsp), %rdx
jae 0x2cb5b
movb $0x2e, (%r15)
incq %r15
jmp 0x2cb5e
movq 0x10(%rsp), %rax
testq %rax, %rax
movq 0x18(%rsp), %r14
movq 0x8(%rsp), %rdi
je 0x2cbea
cmpq %rax, %r12
movq %rax, %rdx
cmovbq %r12, %rdx
movq 0x30(%rsp), %rbp
movq %rbp, %rsi
movq %rax, %r13
callq 0x105f0
movq %r13, %rcx
cmpb $0x2e, -0x1(%rbp,%r13)
jne 0x2cbee
movq 0x8(%rsp), %rax
jmp 0x2cbff
xorl %ecx, %ecx
jmp 0x2cb46
cmpq %r12, %rcx
movq 0x8(%rsp), %rax
jae 0x2cb2f
movb $0x2e, (%rax,%rcx)
incq %rcx
testq %r12, %r12
je 0x2cb46
decq %r12
cmpq %rcx, %r12
cmovaeq %rcx, %r12
movb $0x0, (%rax,%r12)
shll $0x8, %r15d
movzbl %bl, %eax
shll $0x10, %eax
addl %r15d, %eax
addl $0x1f, %eax
jmp 0x2cc23
incq %r12
movq 0x8(%rsp), %rcx
cmpq 0x20(%rsp), %r15
jae 0x2cb76
movb $0x0, (%r15)
subq %rcx, %r15
movq %r15, %rax
jmp 0x2cb93
cmpq %rcx, %r15
jbe 0x2cb91
leaq -0x1(%r15), %rax
cmpb $0x0, -0x1(%r15)
je 0x2cb8c
incq %r12
movb $0x0, (%rax)
subq %rcx, %rax
jmp 0x2cb93
xorl %eax, %eax
addl %r12d, %eax
addl $0x100, %r13d           # imm = 0x100
andl $0xff00, %r13d          # imm = 0xFF00
movzbl %bl, %ecx
shll $0x10, %ecx
addl %r13d, %ecx
addl $0x1a, %ecx
movq %rcx, (%rdx)
jmp 0x2cc28
cmpq %r12, %rcx
movq 0x8(%rsp), %rax
jae 0x2cbc3
movb $0x2e, (%rax,%rcx)
incq %rcx
testq %r12, %r12
je 0x2cbda
decq %r12
cmpq %rcx, %r12
cmovaeq %rcx, %r12
movb $0x0, (%rax,%r12)
shll $0x8, %r15d
shll $0x10, %ebx
leal (%r15,%rbx), %eax
addl $0x5, %eax
jmp 0x2cc23
xorl %ecx, %ecx
jmp 0x2cc13
cmpq %r12, %rcx
movq 0x8(%rsp), %rax
jae 0x2cbfc
movb $0x2e, (%rax,%rcx)
incq %rcx
testq %r12, %r12
je 0x2cc13
decq %r12
cmpq %rcx, %r12
cmovaeq %rcx, %r12
movb $0x0, (%rax,%r12)
shll $0x8, %r15d
movzbl %bl, %eax
shll $0x10, %eax
addl %r15d, %eax
addl $0xd, %eax
movq %rax, (%r14)
movl %ecx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq