// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/lib/dns.c
// Function: dns_res_merge
static struct dns_packet *dns_res_merge(struct dns_packet *P0, struct dns_packet *P1, int *error_) {
	size_t bufsiz	= P0->end + P1->end;
	struct dns_packet *P[3]	= { P0, P1, 0 };
	struct dns_rr rr[3];
	int error, copy, i;
	enum dns_section section;

retry:
	if (!(P[2] = dns_p_make(bufsiz, &error)))
		goto error;

	dns_rr_foreach(&rr[0], P[0], .section = DNS_S_QD) {
		if ((error = dns_rr_copy(P[2], &rr[0], P[0])))
			goto error;
	}

	for (section = DNS_S_AN; (DNS_S_ALL & section); section <<= 1) {
		for (i = 0; i < 2; i++) {
			dns_rr_foreach(&rr[i], P[i], .section = section) {
				copy	= 1;

				dns_rr_foreach(&rr[2], P[2], .type = rr[i].type, .section = (DNS_S_ALL & ~DNS_S_QD)) {
					if (0 == dns_rr_cmp(&rr[i], P[i], &rr[2], P[2])) {
						copy	= 0;

						break;
					}
				}

				if (copy && (error = dns_rr_copy(P[2], &rr[i], P[i]))) {
					if (error == DNS_ENOBUFS && bufsiz < 65535) {
						dns_p_setptr(&P[2], NULL);

						bufsiz	= DNS_PP_MAX(65535, bufsiz * 2);

						goto retry;
					}

					goto error;
				}
			} /* foreach(rr) */
		} /* foreach(packet) */
	} /* foreach(section) */

	return P[2];
error:
	*error_	= error;

	dns_p_free(P[2]);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x18(%rbp), %rcx
addq 0x50(%rcx), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x28(%rbp), %rdi
leaq -0x94(%rbp), %rsi
callq 0xfb10
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x451a2
jmp 0x454d4
leaq -0x150(%rbp), %rdi
xorl %esi, %esi
movl $0x58, %edx
callq 0xf7d0
movl $0x1, -0x150(%rbp)
movq -0x40(%rbp), %rsi
leaq -0x150(%rbp), %rdi
callq 0x10750
movq %rax, %rsi
leaq -0xf8(%rbp), %rdi
movl $0x58, %edx
callq 0xfb40
leaq -0x90(%rbp), %rdi
movq -0x40(%rbp), %rcx
movl $0x0, -0x154(%rbp)
movl $0x1, %esi
leaq -0xf8(%rbp), %rdx
leaq -0x154(%rbp), %r8
callq 0xfe80
cmpl $0x0, %eax
je 0x4523b
movq -0x30(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x104d0
movl %eax, -0x94(%rbp)
cmpl $0x0, %eax
je 0x45239
jmp 0x454d4
jmp 0x451e3
movl $0x2, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
andl $0xf, %eax
cmpl $0x0, %eax
je 0x454ca
movl $0x0, -0x9c(%rbp)
cmpl $0x2, -0x9c(%rbp)
jge 0x454b5
leaq -0x208(%rbp), %rdi
xorl %esi, %esi
movl $0x58, %edx
callq 0xf7d0
movl -0xa0(%rbp), %eax
movl %eax, -0x208(%rbp)
movslq -0x9c(%rbp), %rax
movq -0x40(%rbp,%rax,8), %rsi
leaq -0x208(%rbp), %rdi
callq 0x10750
movq %rax, %rsi
leaq -0x1b0(%rbp), %rdi
movl $0x58, %edx
callq 0xfb40
movslq -0x9c(%rbp), %rax
leaq -0x90(%rbp), %rdi
imulq $0x18, %rax, %rax
addq %rax, %rdi
movslq -0x9c(%rbp), %rax
movq -0x40(%rbp,%rax,8), %rcx
movl $0x0, -0x20c(%rbp)
movl $0x1, %esi
leaq -0x1b0(%rbp), %rdx
leaq -0x20c(%rbp), %r8
callq 0xfe80
cmpl $0x0, %eax
je 0x4549f
movl $0x1, -0x98(%rbp)
leaq -0x2c0(%rbp), %rdi
xorl %esi, %esi
movl $0x58, %edx
callq 0xf7d0
movl $0xe, -0x2c0(%rbp)
movslq -0x9c(%rbp), %rcx
leaq -0x90(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x2b0(%rbp)
movq -0x30(%rbp), %rsi
leaq -0x2c0(%rbp), %rdi
callq 0x10750
movq %rax, %rsi
leaq -0x268(%rbp), %rdi
movl $0x58, %edx
callq 0xfb40
leaq -0x90(%rbp), %rdi
addq $0x30, %rdi
movq -0x30(%rbp), %rcx
movl $0x0, -0x2c4(%rbp)
movl $0x1, %esi
leaq -0x268(%rbp), %rdx
leaq -0x2c4(%rbp), %r8
callq 0xfe80
cmpl $0x0, %eax
je 0x453f2
movslq -0x9c(%rbp), %rax
leaq -0x90(%rbp), %rdi
imulq $0x18, %rax, %rax
addq %rax, %rdi
movslq -0x9c(%rbp), %rax
movq -0x40(%rbp,%rax,8), %rsi
leaq -0x90(%rbp), %rdx
addq $0x30, %rdx
movq -0x30(%rbp), %rcx
callq 0x10be0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x453ed
movl $0x0, -0x98(%rbp)
jmp 0x453f2
jmp 0x4536e
cmpl $0x0, -0x98(%rbp)
je 0x4549a
movq -0x30(%rbp), %rdi
movslq -0x9c(%rbp), %rax
leaq -0x90(%rbp), %rsi
imulq $0x18, %rax, %rax
addq %rax, %rsi
movslq -0x9c(%rbp), %rax
movq -0x40(%rbp,%rax,8), %rdx
callq 0x104d0
movl %eax, -0x94(%rbp)
cmpl $0x0, %eax
je 0x4549a
cmpl $0x9b918cc0, -0x94(%rbp) # imm = 0x9B918CC0
jne 0x45498
cmpq $0xffff, -0x28(%rbp)    # imm = 0xFFFF
jae 0x45498
leaq -0x40(%rbp), %rdi
addq $0x10, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x328c0
movq -0x28(%rbp), %rcx
shlq %rcx
movl $0xffff, %eax           # imm = 0xFFFF
cmpq %rcx, %rax
jbe 0x4547a
movl $0xffff, %eax           # imm = 0xFFFF
movq %rax, -0x2d0(%rbp)
jmp 0x45488
movq -0x28(%rbp), %rax
shlq %rax
movq %rax, -0x2d0(%rbp)
movq -0x2d0(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x45183
jmp 0x454d4
jmp 0x452b9
jmp 0x454a1
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x45261
jmp 0x454b7
movl -0xa0(%rbp), %eax
shll %eax
movl %eax, -0xa0(%rbp)
jmp 0x45245
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x454f1
movl -0x94(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rdi
callq 0x39a50
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
nop