// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/lib/dns.c
// Function: dns_d_comp
size_t dns_d_comp(void *dst_, size_t lim, const void *src_, size_t len, struct dns_packet *P, int *error) {
	struct { unsigned char *b; size_t p, x; } dst, src;
	unsigned char ch	= '.';

	dst.b	= dst_;
	dst.p	= 0;
	dst.x	= 1;

	src.b	= (unsigned char *)src_;
	src.p	= 0;
	src.x	= 0;

	while (src.x < len) {
		ch	= src.b[src.x];

		if (ch == '.') {
			if (dst.p < lim)
				dst.b[dst.p]	= (0x3f & (src.x - src.p));

			dst.p	= dst.x++;
			src.p	= ++src.x;
		} else {
			if (dst.x < lim)
				dst.b[dst.x]	= ch;

			dst.x++;
			src.x++;
		}
	} /* while() */

	if (src.x > src.p) {
		if (dst.p < lim)
			dst.b[dst.p]	= (0x3f & (src.x - src.p));

		dst.p	= dst.x;
	}

	if (dst.p > 1) {
		if (dst.p < lim)
			dst.b[dst.p]	= 0x00;

		dst.p++;
	}

#if 1
	if (dst.p < lim) {
		struct { unsigned char label[DNS_D_MAXLABEL + 1]; size_t len; unsigned short p, x, y; } a, b;
		unsigned i;

		a.p	= 0;

		while ((a.len = dns_l_expand(a.label, sizeof a.label, a.p, &a.x, dst.b, lim))) {
			for (i = 0; i < lengthof(P->dict) && P->dict[i]; i++) {
				b.p	= P->dict[i];

				while ((b.len = dns_l_expand(b.label, sizeof b.label, b.p, &b.x, P->data, P->end))) {
					a.y	= a.x;
					b.y	= b.x;

					while (a.len && b.len && 0 == strcasecmp((char *)a.label, (char *)b.label)) {
						a.len = dns_l_expand(a.label, sizeof a.label, a.y, &a.y, dst.b, lim);
						b.len = dns_l_expand(b.label, sizeof b.label, b.y, &b.y, P->data, P->end);
					}

					if (a.len == 0 && b.len == 0 && b.p <= 0x3fff) {
						dst.b[a.p++]	= 0xc0
								| (0x3f & (b.p >> 8));
						dst.b[a.p++]	= (0xff & (b.p >> 0));

						/* silence static analyzers */
						dns_assume(a.p > 0);

						return a.p;
					}

					b.p	= b.x;
				} /* while() */
			} /* for() */

			a.p	= a.x;
		} /* while() */
	} /* if () */
#endif

	if (!dst.p)
		*error = DNS_EILLEGAL;

	return dst.p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movb $0x2e, -0x69(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x1, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x33e69
movq -0x68(%rbp), %rax
movq -0x58(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x69(%rbp)
movzbl -0x69(%rbp), %eax
cmpl $0x2e, %eax
jne 0x33e34
movq -0x48(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x33e0f
movq -0x58(%rbp), %rax
subq -0x60(%rbp), %rax
andq $0x3f, %rax
movb %al, %dl
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
movq %rax, -0x48(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movq %rax, -0x60(%rbp)
jmp 0x33e64
movq -0x40(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x33e4c
movb -0x69(%rbp), %dl
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x33dc7
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
jbe 0x33e9e
movq -0x48(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x33e96
movq -0x58(%rbp), %rax
subq -0x60(%rbp), %rax
andq $0x3f, %rax
movb %al, %dl
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x1, -0x48(%rbp)
jbe 0x33ec7
movq -0x48(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x33ebb
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x34156
movw $0x0, -0x78(%rbp)
leaq -0xc0(%rbp), %rdi
movw -0x78(%rbp), %ax
leaq -0xc0(%rbp), %rcx
addq $0x4a, %rcx
movq -0x50(%rbp), %r8
movq -0x18(%rbp), %r9
movl $0x40, %esi
movzwl %ax, %edx
callq 0x34180
movq %rax, -0x80(%rbp)
cmpq $0x0, %rax
je 0x34154
movl $0x0, -0x114(%rbp)
movl -0x114(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
cmpq $0x10, %rcx
movb %al, -0x115(%rbp)
jae 0x33f4e
movq -0x30(%rbp), %rax
movl -0x114(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x115(%rbp)
movb -0x115(%rbp), %al
testb $0x1, %al
jne 0x33f5d
jmp 0x34147
movq -0x30(%rbp), %rax
movl -0x114(%rbp), %ecx
movw (%rax,%rcx,2), %ax
movw %ax, -0xc8(%rbp)
leaq -0x110(%rbp), %rdi
movw -0xc8(%rbp), %ax
leaq -0x110(%rbp), %rcx
addq $0x4a, %rcx
movq -0x30(%rbp), %r8
addq $0x5c, %r8
movq -0x30(%rbp), %rdx
movq 0x50(%rdx), %r9
movl $0x40, %esi
movzwl %ax, %edx
callq 0x34180
movq %rax, -0xd0(%rbp)
cmpq $0x0, %rax
je 0x34131
movw -0x76(%rbp), %ax
movw %ax, -0x74(%rbp)
movw -0xc6(%rbp), %ax
movw %ax, -0xc4(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x80(%rbp)
movb %al, -0x116(%rbp)
je 0x34012
xorl %eax, %eax
cmpq $0x0, -0xd0(%rbp)
movb %al, -0x116(%rbp)
je 0x34012
leaq -0xc0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0xff50
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
sete %al
movb %al, -0x116(%rbp)
movb -0x116(%rbp), %al
testb $0x1, %al
jne 0x3401e
jmp 0x3408f
leaq -0xc0(%rbp), %rdi
movw -0x74(%rbp), %ax
leaq -0xc0(%rbp), %rcx
addq $0x4c, %rcx
movq -0x50(%rbp), %r8
movq -0x18(%rbp), %r9
movl $0x40, %esi
movzwl %ax, %edx
callq 0x34180
movq %rax, -0x80(%rbp)
leaq -0x110(%rbp), %rdi
movw -0xc4(%rbp), %ax
leaq -0x110(%rbp), %rcx
addq $0x4c, %rcx
movq -0x30(%rbp), %r8
addq $0x5c, %r8
movq -0x30(%rbp), %rdx
movq 0x50(%rdx), %r9
movl $0x40, %esi
movzwl %ax, %edx
callq 0x34180
movq %rax, -0xd0(%rbp)
jmp 0x33fcf
cmpq $0x0, -0x80(%rbp)
jne 0x3411e
cmpq $0x0, -0xd0(%rbp)
jne 0x3411e
movzwl -0xc8(%rbp), %eax
cmpl $0x3fff, %eax           # imm = 0x3FFF
jg 0x3411e
movzwl -0xc8(%rbp), %eax
sarl $0x8, %eax
andl $0x3f, %eax
orl $0xc0, %eax
movb %al, %dl
movq -0x50(%rbp), %rax
movw -0x78(%rbp), %cx
movw %cx, %si
addw $0x1, %si
movw %si, -0x78(%rbp)
movzwl %cx, %ecx
movb %dl, (%rax,%rcx)
movzwl -0xc8(%rbp), %eax
sarl $0x0, %eax
andl $0xff, %eax
movb %al, %dl
movq -0x50(%rbp), %rax
movw -0x78(%rbp), %cx
movw %cx, %si
addw $0x1, %si
movw %si, -0x78(%rbp)
movzwl %cx, %ecx
movb %dl, (%rax,%rcx)
movzwl -0x78(%rbp), %eax
cmpl $0x0, %eax
jg 0x34112
jmp 0x34114
movzwl -0x78(%rbp), %eax
movq %rax, -0x8(%rbp)
jmp 0x3416f
movw -0xc6(%rbp), %ax
movw %ax, -0xc8(%rbp)
jmp 0x33f72
jmp 0x34133
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x33f1e
movw -0x76(%rbp), %ax
movw %ax, -0x78(%rbp)
jmp 0x33edb
jmp 0x34156
cmpq $0x0, -0x48(%rbp)
jne 0x34167
movq -0x38(%rbp), %rax
movl $0x9b918cc1, (%rax)     # imm = 0x9B918CC1
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopl (%rax)