// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/lib/dns.c
// Function: dns_rr_parse
int dns_rr_parse(struct dns_rr *rr, unsigned short src, struct dns_packet *P) {
	unsigned short p	= src;

	if (src >= P->end)
		goto invalid;

	rr->dn.p   = p;
	rr->dn.len = (p = dns_d_skip(p, P)) - rr->dn.p;

	if (P->end - p < 4)
		goto invalid;

	rr->type = ((0xff & P->data[p + 0]) << 8)
	         | ((0xff & P->data[p + 1]) << 0);

	rr->class = ((0xff & P->data[p + 2]) << 8)
	          | ((0xff & P->data[p + 3]) << 0);

	p += 4;

	if (src < dns_p_qend(P)) {
		rr->section = DNS_S_QUESTION;

		rr->ttl    = 0;
		rr->rd.p   = 0;
		rr->rd.len = 0;

		return 0;
	}

	if (P->end - p < 4)
		goto invalid;

	rr->ttl = ((0xff & P->data[p + 0]) << 24)
	        | ((0xff & P->data[p + 1]) << 16)
	        | ((0xff & P->data[p + 2]) << 8)
	        | ((0xff & P->data[p + 3]) << 0);
	if (rr->type != DNS_T_OPT)
		rr->ttl = DNS_PP_MIN(rr->ttl, 0x7fffffffU);

	p += 4;

	if (P->end - p < 2)
		goto invalid;

	rr->rd.len = ((0xff & P->data[p + 0]) << 8)
	           | ((0xff & P->data[p + 1]) << 0);
	rr->rd.p = p + 2;

	p += 2;

	if (P->end - p < rr->rd.len)
		goto invalid;

	return 0;
invalid:
	return DNS_EILLEGAL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movw %si, %ax
movq %rdi, -0x10(%rbp)
movw %ax, -0x12(%rbp)
movq %rdx, -0x20(%rbp)
movw -0x12(%rbp), %ax
movw %ax, -0x22(%rbp)
movzwl -0x12(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jb 0x34a42
jmp 0x34ce9
movw -0x22(%rbp), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x4(%rax)
movw -0x22(%rbp), %ax
movq -0x20(%rbp), %rsi
movzwl %ax, %edi
callq 0x10400
movw %ax, -0x22(%rbp)
movzwl %ax, %eax
movq -0x10(%rbp), %rcx
movzwl 0x4(%rcx), %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x6(%rax)
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rax
movzwl -0x22(%rbp), %ecx
subq %rcx, %rax
cmpq $0x4, %rax
jae 0x34a94
jmp 0x34ce9
movq -0x20(%rbp), %rax
movzwl -0x22(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzbl 0x5c(%rax,%rcx), %ecx
andl $0xff, %ecx
shll $0x8, %ecx
movq -0x20(%rbp), %rax
movzwl -0x22(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movzbl 0x5c(%rax,%rdx), %eax
andl $0xff, %eax
shll $0x0, %eax
orl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x20(%rbp), %rax
movzwl -0x22(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movzbl 0x5c(%rax,%rcx), %ecx
andl $0xff, %ecx
shll $0x8, %ecx
movq -0x20(%rbp), %rax
movzwl -0x22(%rbp), %edx
addl $0x3, %edx
movslq %edx, %rdx
movzbl 0x5c(%rax,%rdx), %eax
andl $0xff, %eax
shll $0x0, %eax
orl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movzwl -0x22(%rbp), %eax
addl $0x4, %eax
movw %ax, -0x22(%rbp)
movzwl -0x12(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x34d00
movw %ax, %cx
movl -0x28(%rbp), %eax
movzwl %cx, %ecx
cmpl %ecx, %eax
jge 0x34b71
movq -0x10(%rbp), %rax
movl $0x1, (%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x14(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x16(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x34cf0
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rax
movzwl -0x22(%rbp), %ecx
subq %rcx, %rax
cmpq $0x4, %rax
jae 0x34b8b
jmp 0x34ce9
movq -0x20(%rbp), %rax
movzwl -0x22(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzbl 0x5c(%rax,%rcx), %ecx
andl $0xff, %ecx
shll $0x18, %ecx
movq -0x20(%rbp), %rax
movzwl -0x22(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movzbl 0x5c(%rax,%rdx), %eax
andl $0xff, %eax
shll $0x10, %eax
orl %eax, %ecx
movq -0x20(%rbp), %rax
movzwl -0x22(%rbp), %edx
addl $0x2, %edx
movslq %edx, %rdx
movzbl 0x5c(%rax,%rdx), %eax
andl $0xff, %eax
shll $0x8, %eax
orl %eax, %ecx
movq -0x20(%rbp), %rax
movzwl -0x22(%rbp), %edx
addl $0x3, %edx
movslq %edx, %rdx
movzbl 0x5c(%rax,%rdx), %eax
andl $0xff, %eax
shll $0x0, %eax
orl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
cmpl $0x29, 0x8(%rax)
je 0x34c3c
movq -0x10(%rbp), %rax
cmpl $0x7fffffff, 0x10(%rax) # imm = 0x7FFFFFFF
jae 0x34c28
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x34c32
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x2c(%rbp)
jmp 0x34c32
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movzwl -0x22(%rbp), %eax
addl $0x4, %eax
movw %ax, -0x22(%rbp)
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rax
movzwl -0x22(%rbp), %ecx
subq %rcx, %rax
cmpq $0x2, %rax
jae 0x34c61
jmp 0x34ce9
movq -0x20(%rbp), %rax
movzwl -0x22(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movzbl 0x5c(%rax,%rcx), %eax
andl $0xff, %eax
shll $0x8, %eax
movq -0x20(%rbp), %rcx
movzwl -0x22(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movzbl 0x5c(%rcx,%rdx), %ecx
andl $0xff, %ecx
shll $0x0, %ecx
orl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x16(%rax)
movzwl -0x22(%rbp), %eax
addl $0x2, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x14(%rax)
movzwl -0x22(%rbp), %eax
addl $0x2, %eax
movw %ax, -0x22(%rbp)
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rax
movzwl -0x22(%rbp), %ecx
subq %rcx, %rax
movq -0x10(%rbp), %rcx
movzwl 0x16(%rcx), %ecx
cmpq %rcx, %rax
jae 0x34ce0
jmp 0x34ce9
movl $0x0, -0x4(%rbp)
jmp 0x34cf0
movl $0x9b918cc1, -0x4(%rbp) # imm = 0x9B918CC1
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)