// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x32035
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x2b0(%rbp)
jmp 0x32040
xorl %eax, %eax
movq %rax, -0x2b0(%rbp)
jmp 0x32040
movq -0x2b0(%rbp), %rax
movq %rax, -0x2b8(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x32066
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x2c0(%rbp)
jmp 0x32071
xorl %eax, %eax
movq %rax, -0x2c0(%rbp)
jmp 0x32071
movq -0x2b8(%rbp), %rcx
movq -0x2c0(%rbp), %rax
addq %rax, %rcx
movl $0xffff, %eax           # imm = 0xFFFF
cmpq %rcx, %rax
jae 0x3209a
movl $0xffff, %eax           # imm = 0xFFFF
movq %rax, -0x2c8(%rbp)
jmp 0x32106
cmpq $0x0, -0x10(%rbp)
je 0x320b2
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x2d0(%rbp)
jmp 0x320bd
xorl %eax, %eax
movq %rax, -0x2d0(%rbp)
jmp 0x320bd
movq -0x2d0(%rbp), %rax
movq %rax, -0x2d8(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x320e3
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x2e0(%rbp)
jmp 0x320ee
xorl %eax, %eax
movq %rax, -0x2e0(%rbp)
jmp 0x320ee
movq -0x2d8(%rbp), %rax
movq -0x2e0(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x2c8(%rbp)
movq -0x2c8(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x32135
cmpq $0x0, -0x20(%rbp)
je 0x32135
movq -0x20(%rbp), %rax
movq %rax, -0x10(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
jmp 0x32137
movq -0x38(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0xfb10
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x32153
jmp 0x32383
movl $0x1, -0x44(%rbp)
movl -0x44(%rbp), %eax
andl $0xf, %eax
cmpl $0x0, %eax
je 0x32379
cmpq $0x0, -0x10(%rbp)
je 0x32214
movl -0x44(%rbp), %eax
andl -0x14(%rbp), %eax
cmpl $0x0, %eax
je 0x32214
leaq -0x130(%rbp), %rdi
xorl %esi, %esi
movl $0x58, %edx
callq 0xf7d0
movl -0x44(%rbp), %eax
movl %eax, -0x130(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x130(%rbp), %rdi
callq 0x10750
movq %rax, %rsi
leaq -0xd8(%rbp), %rdi
movl $0x58, %edx
callq 0xfb40
movq -0x10(%rbp), %rcx
movl $0x0, -0x134(%rbp)
leaq -0x5c(%rbp), %rdi
movl $0x1, %esi
leaq -0xd8(%rbp), %rdx
leaq -0x134(%rbp), %r8
callq 0xfe80
cmpl $0x0, %eax
je 0x32212
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq -0x5c(%rbp), %rsi
callq 0x104d0
movl %eax, -0x78(%rbp)
cmpl $0x0, %eax
je 0x32210
jmp 0x32383
jmp 0x321c3
jmp 0x32214
cmpq $0x0, -0x20(%rbp)
je 0x3236a
movl -0x44(%rbp), %eax
andl -0x24(%rbp), %eax
cmpl $0x0, %eax
je 0x3236a
leaq -0x1e8(%rbp), %rdi
xorl %esi, %esi
movl $0x58, %edx
callq 0xf7d0
movl -0x44(%rbp), %eax
movl %eax, -0x1e8(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x1e8(%rbp), %rdi
callq 0x10750
movq %rax, %rsi
leaq -0x190(%rbp), %rdi
movl $0x58, %edx
callq 0xfb40
movq -0x20(%rbp), %rcx
movl $0x0, -0x1ec(%rbp)
leaq -0x5c(%rbp), %rdi
movl $0x1, %esi
leaq -0x190(%rbp), %rdx
leaq -0x1ec(%rbp), %r8
callq 0xfe80
cmpl $0x0, %eax
je 0x32368
movl $0x1, -0x7c(%rbp)
leaq -0x2a0(%rbp), %rdi
xorl %esi, %esi
movl $0x58, %edx
callq 0xf7d0
movl $0xf, -0x2a0(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x290(%rbp)
movq -0x40(%rbp), %rsi
leaq -0x2a0(%rbp), %rdi
callq 0x10750
movq %rax, %rsi
leaq -0x248(%rbp), %rdi
movl $0x58, %edx
callq 0xfb40
movq -0x40(%rbp), %rcx
movl $0x0, -0x2a4(%rbp)
leaq -0x74(%rbp), %rdi
movl $0x1, %esi
leaq -0x248(%rbp), %rdx
leaq -0x2a4(%rbp), %r8
callq 0xfe80
cmpl $0x0, %eax
je 0x32342
movq -0x20(%rbp), %rsi
movq -0x40(%rbp), %rcx
leaq -0x5c(%rbp), %rdi
leaq -0x74(%rbp), %rdx
callq 0x10be0
movl %eax, -0x7c(%rbp)
cmpl $0x0, %eax
jne 0x32340
jmp 0x32342
jmp 0x322f2
cmpl $0x0, -0x7c(%rbp)
je 0x32363
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq -0x5c(%rbp), %rsi
callq 0x104d0
movl %eax, -0x78(%rbp)
cmpl $0x0, %eax
je 0x32363
jmp 0x32383
jmp 0x3226e
jmp 0x3236a
jmp 0x3236c
movl -0x44(%rbp), %eax
shll %eax
movl %eax, -0x44(%rbp)
jmp 0x3215a
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x323f1
leaq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x328c0
cmpl $0x9b918cc0, -0x78(%rbp) # imm = 0x9B918CC0
jne 0x323e0
cmpq $0xffff, -0x38(%rbp)    # imm = 0xFFFF
jae 0x323e0
movq -0x38(%rbp), %rcx
shlq %rcx
movl $0xffff, %eax           # imm = 0xFFFF
cmpq %rcx, %rax
jae 0x323c2
movl $0xffff, %eax           # imm = 0xFFFF
movq %rax, -0x2e8(%rbp)
jmp 0x323d0
movq -0x38(%rbp), %rax
shlq %rax
movq %rax, -0x2e8(%rbp)
movq -0x2e8(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x32137
movl -0x78(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
nop