// File: /workspace/github_c_makefile_star2_O3/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 $0x1f8, %rsp            # imm = 0x1F8
movq %r8, 0x30(%rsp)
movl %ecx, 0x14(%rsp)
movq %rdx, %rbx
movl %esi, 0x8(%rsp)
testq %rdi, %rdi
je 0x2640c
movq 0x50(%rdi), %rax
jmp 0x2640e
xorl %eax, %eax
testq %rbx, %rbx
je 0x26419
movq 0x50(%rbx), %rcx
jmp 0x2641b
xorl %ecx, %ecx
addq %rax, %rcx
movl $0xffff, %edx           # imm = 0xFFFF
cmpq $0xffff, %rcx           # imm = 0xFFFF
ja 0x26449
testq %rdi, %rdi
je 0x26437
movq 0x50(%rdi), %rax
jmp 0x26439
xorl %eax, %eax
testq %rbx, %rbx
je 0x26444
movq 0x50(%rbx), %rdx
jmp 0x26446
xorl %edx, %edx
addq %rax, %rdx
testq %rbx, %rbx
setne %al
testq %rdi, %rdi
movq %rbx, %r13
cmoveq %rdi, %r13
sete %cl
testb %al, %cl
movl 0x8(%rsp), %eax
cmovnel 0x14(%rsp), %eax
movl %eax, 0x8(%rsp)
cmoveq %rdi, %rbx
leaq 0x170(%rsp), %r15
leaq 0x1e0(%rsp), %r12
leaq 0xc(%rsp), %rbp
movq %rbx, 0x28(%rsp)
movq %rdx, 0x38(%rsp)
movq %rdx, %rdi
leaq 0x10(%rsp), %rsi
callq 0xfa30
movq %rax, %r14
testq %rax, %rax
je 0x266e9
movl $0x1, %edx
testq %rbx, %rbx
movq %rdx, 0x20(%rsp)
je 0x26552
movl %edx, %eax
andl 0x8(%rsp), %eax
je 0x26552
xorps %xmm0, %xmm0
movaps %xmm0, 0x120(%rsp)
movaps %xmm0, 0x130(%rsp)
movaps %xmm0, 0x140(%rsp)
movl $0x0, 0x150(%rsp)
leaq 0x154(%rsp), %rax
movups %xmm0, (%rax)
leaq 0x7c(%rsp), %rdi
movups %xmm0, 0x44(%rdi)
movl %edx, 0x78(%rsp)
movl $0x11, %ecx
leaq 0x120(%rsp), %rsi
rep  movsl (%rsi), %es:(%rdi)
movq %r15, %rdi
movl $0x1, %esi
leaq 0x78(%rsp), %rdx
movq %rbx, %rcx
leaq 0x1c(%rsp), %r8
callq 0xfd70
testl %eax, %eax
je 0x26548
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x10370
testl %eax, %eax
je 0x26513
jmp 0x266e1
leaq 0xc(%rsp), %rbp
movq 0x20(%rsp), %rdx
testq %r13, %r13
sete %al
testl %edx, 0x14(%rsp)
sete %cl
orb %al, %cl
jne 0x266d1
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xe0(%rsp)
movaps %xmm0, 0xf0(%rsp)
movl $0x0, 0x100(%rsp)
leaq 0x104(%rsp), %rax
movups %xmm0, (%rax)
leaq 0x7c(%rsp), %rax
movups %xmm0, 0x44(%rax)
movl %edx, 0x78(%rsp)
movl $0x11, %ecx
leaq 0x7c(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
rep  movsl (%rsi), %es:(%rdi)
movq %r15, %rdi
movl $0x1, %esi
leaq 0x78(%rsp), %rdx
movq %r13, %rcx
leaq 0x18(%rsp), %r8
callq 0xfd70
testl %eax, %eax
je 0x266cc
leaq 0x18c(%rsp), %rdx
xorl %eax, %eax
movl %eax, 0x8(%rdx)
movq $0x0, (%rdx)
movl %eax, 0x60(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movl 0x178(%rsp), %eax
leaq 0x64(%rsp), %rcx
movups %xmm0, (%rcx)
movups %xmm0, 0x44(%rdx)
movl $0xf, 0x188(%rsp)
movl %eax, 0x198(%rsp)
movl 0x70(%rsp), %eax
movl %eax, 0x40(%rdx)
movaps 0x40(%rsp), %xmm0
movaps 0x50(%rsp), %xmm1
movl 0x60(%rsp), %eax
movl %eax, 0x30(%rdx)
movq 0x64(%rsp), %rax
movq %rax, 0x34(%rdx)
movl 0x6c(%rsp), %eax
movl %eax, 0x3c(%rdx)
movups %xmm1, 0x20(%rdx)
movups %xmm0, 0x10(%rdx)
leaq 0x188(%rsp), %rbx
movq %r12, %rdi
movl $0x1, %esi
movq %rbx, %rdx
movq %r14, %rcx
movq %rbp, %r8
callq 0xfd70
testl %eax, %eax
je 0x2668e
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x109e0
testl %eax, %eax
jne 0x2665d
jmp 0x266a0
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x10370
testl %eax, %eax
jne 0x266e1
movq %r15, %rdi
movl $0x1, %esi
leaq 0x78(%rsp), %rdx
movq %r13, %rcx
leaq 0x18(%rsp), %r8
callq 0xfd70
testl %eax, %eax
movq 0x28(%rsp), %rbx
leaq 0xc(%rsp), %rbp
jne 0x265db
movq 0x20(%rsp), %rdx
leal (%rdx,%rdx), %eax
testb $0x7, %dl
movl %eax, %edx
jne 0x264ac
jmp 0x26733
movl %eax, %ebp
movl %eax, 0x10(%rsp)
jmp 0x266ed
movl 0x10(%rsp), %ebp
movq %r14, %rdi
callq 0xff30
movq 0x38(%rsp), %rdx
cmpq $0xfffe, %rdx           # imm = 0xFFFE
ja 0x26729
cmpl $0x9b918cc0, %ebp       # imm = 0x9B918CC0
jne 0x26729
addq %rdx, %rdx
movl $0xffff, %eax           # imm = 0xFFFF
cmpq %rax, %rdx
cmovaeq %rax, %rdx
movq 0x28(%rsp), %rbx
leaq 0xc(%rsp), %rbp
jmp 0x26489
movq 0x30(%rsp), %rax
movl %ebp, (%rax)
xorl %r14d, %r14d
movq %r14, %rax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq