// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/lib/dns.c
// Function: dns_l_expand
static size_t dns_l_expand(unsigned char *dst, size_t lim, unsigned short src, unsigned short *nxt, const unsigned char *data, size_t end) {
	unsigned short len;
	unsigned nptrs	= 0;

retry:
	if (src >= end)
		goto invalid;

	switch (0x03 & (data[src] >> 6)) {
	case 0x00:
		len	= (0x3f & (data[src++]));

		if (end - src < len)
			goto invalid;

		if (lim > 0) {
			memcpy(dst, &data[src], DNS_PP_MIN(lim, len));

			dst[DNS_PP_MIN(lim - 1, len)]	= '\0';
		}

		*nxt	= src + len;

		return len;
	case 0x01:
		goto invalid;
	case 0x02:
		goto invalid;
	case 0x03:
		if (++nptrs > DNS_D_MAXPTRS)
			goto invalid;

		if (end - src < 2)
			goto invalid;

		src	= ((0x3f & data[src + 0]) << 8)
			| ((0xff & data[src + 1]) << 0);

		goto retry;
	} /* switch() */

	/* NOT REACHED */
invalid:
	*nxt	= end;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movw %dx, %ax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movw %ax, -0x1a(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movl $0x0, -0x40(%rbp)
movzwl -0x1a(%rbp), %eax
cmpq -0x38(%rbp), %rax
jb 0x341b9
jmp 0x34337
movq -0x30(%rbp), %rax
movzwl -0x1a(%rbp), %ecx
movzbl (%rax,%rcx), %eax
shrl $0x6, %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0x3, %eax
ja 0x34335
movq -0x48(%rbp), %rax
leaq 0x15cbe(%rip), %rcx     # 0x49ea0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x30(%rbp), %rax
movw -0x1a(%rbp), %cx
movw %cx, %dx
addw $0x1, %dx
movw %dx, -0x1a(%rbp)
movzwl %cx, %ecx
movzbl (%rax,%rcx), %eax
andl $0x3f, %eax
movw %ax, -0x3a(%rbp)
movq -0x38(%rbp), %rax
movzwl -0x1a(%rbp), %ecx
subq %rcx, %rax
movzwl -0x3a(%rbp), %ecx
cmpq %rcx, %rax
jae 0x34225
jmp 0x34337
cmpq $0x0, -0x18(%rbp)
jbe 0x342b2
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
movzwl -0x1a(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movzwl -0x3a(%rbp), %ecx
cmpq %rcx, %rax
jae 0x3425e
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x34266
movzwl -0x3a(%rbp), %eax
movq %rax, -0x60(%rbp)
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rdx
callq 0xfb40
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rax
subq $0x1, %rax
movzwl -0x3a(%rbp), %ecx
cmpq %rcx, %rax
jae 0x3429e
movq -0x18(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x342a6
movzwl -0x3a(%rbp), %eax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
movq -0x70(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movzwl -0x1a(%rbp), %eax
movzwl -0x3a(%rbp), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, (%rax)
movzwl -0x3a(%rbp), %eax
movq %rax, -0x8(%rbp)
jmp 0x3434d
jmp 0x34337
jmp 0x34337
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
cmpl $0x7f, %eax
jbe 0x342e4
jmp 0x34337
movq -0x38(%rbp), %rax
movzwl -0x1a(%rbp), %ecx
subq %rcx, %rax
cmpq $0x2, %rax
jae 0x342f7
jmp 0x34337
movq -0x30(%rbp), %rax
movzwl -0x1a(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
andl $0x3f, %eax
shll $0x8, %eax
movq -0x30(%rbp), %rcx
movzwl -0x1a(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
andl $0xff, %ecx
shll $0x0, %ecx
orl %ecx, %eax
movw %ax, -0x1a(%rbp)
jmp 0x341aa
jmp 0x34337
movq -0x38(%rbp), %rax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, (%rax)
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)