// File: /workspace/github_c_makefile_star2_O1/wahern[P]cqueues/src/lib/dns.c
// Function: dns_p_merge
struct dns_packet *dns_p_merge(struct dns_packet *A, enum dns_section Amask, struct dns_packet *B, enum dns_section Bmask, int *error_) {
	size_t bufsiz = DNS_PP_MIN(65535, ((A)? A->end : 0) + ((B)? B->end : 0));
	struct dns_packet *M;
	enum dns_section section;
	struct dns_rr rr, mr;
	int error, copy;

	if (!A && B) {
		A = B;
		Amask = Bmask;
		B = 0;
	}

merge:
	if (!(M = dns_p_make(bufsiz, &error)))
		goto error;

	for (section = DNS_S_QD; (DNS_S_ALL & section); section <<= 1) {
		if (A && (section & Amask)) {
			dns_rr_foreach(&rr, A, .section = section) {
				if ((error = dns_rr_copy(M, &rr, A)))
					goto error;
			}
		}

		if (B && (section & Bmask)) {
			dns_rr_foreach(&rr, B, .section = section) {
				copy = 1;

				dns_rr_foreach(&mr, M, .type = rr.type, .section = DNS_S_ALL) {
					if (!(copy = dns_rr_cmp(&rr, B, &mr, M)))
						break;
				}

				if (copy && (error = dns_rr_copy(M, &rr, B)))
					goto error;
			}
		}
	}

	return M;
error:
	dns_p_setptr(&M, NULL);

	if (error == DNS_ENOBUFS && bufsiz < 65535) {
		bufsiz = DNS_PP_MIN(65535, bufsiz * 2);

		goto merge;
	}

	*error_	= error;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %r8, 0x40(%rsp)
movl %ecx, 0x2c(%rsp)
movl %esi, 0x20(%rsp)
testq %rdi, %rdi
je 0x265dc
movq 0x50(%rdi), %rax
jmp 0x265de
xorl %eax, %eax
testq %rdx, %rdx
je 0x265e9
movq 0x50(%rdx), %rcx
jmp 0x265eb
xorl %ecx, %ecx
addq %rax, %rcx
movl $0xffff, %r8d           # imm = 0xFFFF
cmpq $0xffff, %rcx           # imm = 0xFFFF
ja 0x2661b
testq %rdi, %rdi
je 0x26608
movq 0x50(%rdi), %rax
jmp 0x2660a
xorl %eax, %eax
testq %rdx, %rdx
je 0x26615
movq 0x50(%rdx), %r8
jmp 0x26618
xorl %r8d, %r8d
addq %rax, %r8
testq %rdx, %rdx
setne %al
testq %rdi, %rdi
movq %rdx, %r13
cmoveq %rdi, %r13
sete %cl
testb %al, %cl
movl 0x20(%rsp), %eax
cmovnel 0x2c(%rsp), %eax
movl %eax, 0x20(%rsp)
cmoveq %rdi, %rdx
movq %rdx, 0x18(%rsp)
leaq 0x14(%rsp), %rsi
leaq 0x180(%rsp), %r12
leaq 0x1f0(%rsp), %rbp
leaq 0x198(%rsp), %rbx
leaq 0x3c(%rsp), %r14
movq %r8, 0x48(%rsp)
movq %r8, %rdi
callq 0xfa30
movq %rax, %r15
testq %rax, %rax
je 0x26959
movl $0x1, %esi
movl 0x14(%rsp), %eax
movl %eax, 0x10(%rsp)
movq 0x18(%rsp), %r8
testq %r8, %r8
movq %rsi, 0x30(%rsp)
je 0x26789
movl %esi, %eax
andl 0x20(%rsp), %eax
je 0x26789
xorps %xmm0, %xmm0
movaps %xmm0, 0xe0(%rsp)
movaps %xmm0, 0xf0(%rsp)
movaps %xmm0, 0x100(%rsp)
movaps %xmm0, 0x110(%rsp)
xorl %edx, %edx
movl %edx, 0x120(%rsp)
leaq 0x114(%rsp), %rax
movups %xmm0, (%rax)
leaq 0x12c(%rsp), %rdi
movups %xmm0, 0x44(%rdi)
movl %esi, 0x128(%rsp)
movl $0x11, %ecx
leaq 0xe0(%rsp), %rsi
rep  movsl (%rsi), %es:(%rdi)
movl %edx, 0x28(%rsp)
movq %r12, %rdi
movl $0x1, %esi
leaq 0x128(%rsp), %rdx
movq %r8, %rcx
leaq 0x28(%rsp), %r8
callq 0xfd70
testl %eax, %eax
sete %al
je 0x2677f
movb %al, 0xf(%rsp)
movq %r15, %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
callq 0x10370
movl %eax, 0x10(%rsp)
testl %eax, %eax
jne 0x26769
movl $0x0, 0x28(%rsp)
movq %r12, %rdi
movl $0x1, %esi
leaq 0x128(%rsp), %rdx
movq 0x18(%rsp), %rcx
jmp 0x2671d
cmpb $0x0, 0xf(%rsp)
movq 0x18(%rsp), %r8
movq 0x30(%rsp), %rsi
jne 0x26789
jmp 0x26951
movq 0x18(%rsp), %r8
movq 0x30(%rsp), %rsi
testq %r13, %r13
sete %al
testl %esi, 0x2c(%rsp)
sete %cl
orb %al, %cl
jne 0x2693b
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xc0(%rsp)
xorl %edx, %edx
movl %edx, 0xd0(%rsp)
leaq 0xc4(%rsp), %rax
movups %xmm0, (%rax)
leaq 0x12c(%rsp), %rax
movups %xmm0, 0x44(%rax)
movl %esi, 0x128(%rsp)
movl $0x11, %ecx
leaq 0x12c(%rsp), %rdi
leaq 0x90(%rsp), %rsi
rep  movsl (%rsi), %es:(%rdi)
movl %edx, 0x24(%rsp)
movq %r12, %rdi
movl $0x1, %esi
leaq 0x128(%rsp), %rdx
movq %r13, %rcx
leaq 0x24(%rsp), %r8
callq 0xfd70
movl $0x9, %ecx
testl %eax, %eax
je 0x2692c
leaq 0x19c(%rsp), %rdx
xorl %eax, %eax
movl %eax, 0x8(%rdx)
movq $0x0, (%rdx)
movl %eax, 0x80(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movl 0x188(%rsp), %eax
leaq 0x74(%rsp), %rcx
movups %xmm0, (%rcx)
movups %xmm0, 0x44(%rdx)
movl $0xf, 0x198(%rsp)
movl %eax, 0x1a8(%rsp)
movl 0x80(%rsp), %eax
movl %eax, 0x40(%rdx)
movaps 0x50(%rsp), %xmm0
movaps 0x60(%rsp), %xmm1
movaps 0x70(%rsp), %xmm2
movups %xmm2, 0x30(%rdx)
movups %xmm1, 0x20(%rdx)
movups %xmm0, 0x10(%rdx)
movl $0x0, 0x3c(%rsp)
movq %rbp, %rdi
movl $0x1, %esi
movq %rbx, %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0xfd70
testl %eax, %eax
je 0x268dd
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x109e0
testl %eax, %eax
jne 0x268a4
jmp 0x268f3
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x10370
movl %eax, 0x10(%rsp)
testl %eax, %eax
jne 0x26927
movl $0x0, 0x24(%rsp)
movq %r12, %rdi
movl $0x1, %esi
leaq 0x128(%rsp), %rdx
movq %r13, %rcx
leaq 0x24(%rsp), %r8
callq 0xfd70
testl %eax, %eax
jne 0x2682d
movl $0x9, %ecx
jmp 0x2692c
movl $0x3, %ecx
cmpl $0x9, %ecx
movq 0x18(%rsp), %r8
movq 0x30(%rsp), %rsi
jne 0x2694c
leal (%rsi,%rsi), %eax
testb $0x7, %sil
movl %eax, %esi
jne 0x26693
jmp 0x26993
cmpl $0x3, %ecx
jne 0x26993
movl 0x10(%rsp), %eax
movl %eax, 0x14(%rsp)
movq %r15, %rdi
callq 0xff30
movl 0x14(%rsp), %eax
movq 0x48(%rsp), %r8
cmpq $0xfffe, %r8            # imm = 0xFFFE
ja 0x269b0
cmpl $0x9b918cc0, %eax       # imm = 0x9B918CC0
jne 0x269b0
addq %r8, %r8
movl $0xffff, %eax           # imm = 0xFFFF
cmpq %rax, %r8
cmovaeq %rax, %r8
leaq 0x14(%rsp), %rsi
jmp 0x26668
movl 0x10(%rsp), %eax
movl %eax, 0x14(%rsp)
movq %r15, %rax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x40(%rsp), %rcx
movl %eax, (%rcx)
xorl %r15d, %r15d
jmp 0x2699b