// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/ns_msg.c
// Function: ns_rr_clone
ns_rr_t* ns_rr_clone(const ns_rr_t* array, int num)
{
	ns_rr_t* copy, * dst;
	const ns_rr_t* src;
	int i;
	if (!array)
		return NULL;
	copy = (ns_rr_t*)malloc(sizeof(ns_rr_t) * num);
	if (!copy) {
		loge("alloc \n");
		return NULL;
	}
	memset(copy, 0, sizeof(ns_rr_t) * num);
	for (i = 0; i < num; i++) {
		src = array + i;
		dst = copy + i;

		dst->name = src->name ? strdup(src->name) : NULL;
		dst->type = src->type;
		dst->cls = src->cls;
		dst->ttl = src->ttl;
		dst->rdlength = src->rdlength;
		dst->rdata = NULL;

		if (src->rdata) {
			dst->rdata = ns_msg_clone_rdata(src);
			if (!dst->rdata) {
				loge("alloc \n");
				for (; i >= 0; i--) {
					dst = copy + i;
					ns_msg_free_rdata(dst);
					free(dst->name);
				}
				free(copy);
				return NULL;
			}
		}
	}
	return copy;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
testq %rdi, %rdi
je 0x1991b
movl %esi, %ebp
movq %rdi, %r12
movslq %esi, %rsi
shlq $0x5, %rsi
movl $0x1, %edi
callq 0x3240
testq %rax, %rax
je 0x1984a
movq %rax, %r15
testl %ebp, %ebp
jle 0x1991e
movl %ebp, %eax
movq %rax, 0x38(%rsp)
xorl %ebp, %ebp
xorl %ebx, %ebx
movq %r12, 0x40(%rsp)
movq %rbx, %r14
shlq $0x5, %r14
movq (%r12,%r14), %rdi
testq %rdi, %rdi
je 0x19600
callq 0x3610
jmp 0x19602
xorl %eax, %eax
leaq (%r12,%r14), %rcx
addq %r15, %r14
movq %rax, (%r14)
movq 0x8(%rcx), %rax
movl %eax, 0x8(%r14)
movl 0xc(%rcx), %edx
movl %edx, 0xc(%r14)
movzwl 0x10(%rcx), %r13d
movw %r13w, 0x10(%r14)
movq $0x0, 0x18(%r14)
movq 0x18(%rcx), %r12
testq %r12, %r12
je 0x1982e
movq %rax, %xmm0
pextrw $0x0, %xmm0, %eax
leal -0x2(%rax), %ecx
cmpl $0xd, %ecx
ja 0x19691
leaq 0xb38d(%rip), %rdx      # 0x249e0
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq %r12, %rdi
callq 0x3610
movq %rax, 0x18(%r14)
testq %rax, %rax
jne 0x1982e
jmp 0x198c5
movl $0x10, %edi
callq 0x34b0
testq %rax, %rax
je 0x198bd
movq %rax, %rcx
jmp 0x197f2
cmpl $0x29, %eax
jne 0x19775
movl $0x10, %edi
callq 0x34b0
testq %rax, %rax
je 0x198bd
movslq 0x8(%r12), %r13
movq %r13, %rdi
shlq $0x4, %rdi
movq %rax, 0x8(%rsp)
callq 0x34b0
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x19930
movl %r13d, 0x8(%rcx)
testl %r13d, %r13d
jle 0x1982a
movq %rbx, 0x20(%rsp)
movq %r15, 0x18(%rsp)
movq (%r12), %rbx
negq %r13
movq %r13, 0x30(%rsp)
movl $0x1, %r13d
movl $0x8, %r15d
movq %rbx, 0x28(%rsp)
movl -0x8(%rbx,%r15), %r12d
movq 0x10(%rsp), %rbx
movl %r12d, -0x8(%rbx,%r15)
shrl $0x10, %r12d
movq %r12, %rdi
callq 0x34b0
movq %rax, (%rbx,%r15)
testq %rax, %rax
je 0x1988b
movq 0x28(%rsp), %rbx
movq (%rbx,%r15), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0x32b0
addq $0x10, %r15
movq 0x30(%rsp), %rax
addq %r13, %rax
incq %rax
incq %r13
cmpq $0x1, %rax
jne 0x1970d
movq 0x18(%rsp), %r15
movq 0x8(%rsp), %rax
movq 0x20(%rsp), %rbx
jmp 0x19664
movq %r13, %rdi
callq 0x34b0
testq %rax, %rax
je 0x198bd
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rax, %r12
callq 0x32b0
movq %r12, %rcx
jmp 0x1982a
movl $0x10, %edi
callq 0x34b0
testq %rax, %rax
je 0x198bd
movq %rax, %rcx
movzwl (%r12), %eax
movw %ax, (%rcx)
jmp 0x1980d
movl $0x28, %edi
callq 0x34b0
testq %rax, %rax
je 0x198bd
movq %rax, %rcx
movq 0x20(%r12), %rax
movq %rax, 0x20(%rcx)
movdqu (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups %xmm1, 0x10(%rcx)
movdqu %xmm0, (%rcx)
movq (%r12), %rdi
testq %rdi, %rdi
je 0x19808
movq %rcx, %r13
callq 0x3610
movq %r13, %rcx
jmp 0x1980a
xorl %eax, %eax
movq %rax, (%rcx)
movq 0x8(%r12), %rdi
testq %rdi, %rdi
je 0x19824
movq %rcx, %r12
callq 0x3610
movq %r12, %rcx
jmp 0x19826
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x18(%r14)
incq %rbx
addq $0x20, %rbp
cmpq 0x38(%rsp), %rbx
movq 0x40(%rsp), %r12
jne 0x195e9
jmp 0x1991e
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x1991e
leaq 0xb380(%rip), %rsi      # 0x24be4
leaq 0xb392(%rip), %rdx      # 0x24bfd
leaq 0x8d64(%rip), %r8       # 0x225d6
xorl %r15d, %r15d
movl $0x3, %edi
movl $0xfa, %ecx
xorl %eax, %eax
callq 0x1771e
jmp 0x1991e
movq 0x10(%rsp), %rbx
addq %r15, %rbx
movq (%rbx), %rdi
callq 0x3450
addq $-0x10, %rbx
decq %r13
jg 0x19893
movq 0x10(%rsp), %rdi
callq 0x3450
movq 0x8(%rsp), %rdi
callq 0x3450
movq 0x18(%rsp), %r15
movq $0x0, 0x18(%r14)
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x198f7
leaq 0xb30c(%rip), %rsi      # 0x24be4
leaq 0xb31e(%rip), %rdx      # 0x24bfd
leaq 0x8cf0(%rip), %r8       # 0x225d6
movl $0x3, %edi
movl $0x10c, %ecx            # imm = 0x10C
xorl %eax, %eax
callq 0x1771e
leaq (%r15,%rbp), %rdi
callq 0x1993a
movq (%r15,%rbp), %rdi
callq 0x3450
addq $-0x20, %rbp
cmpq $-0x20, %rbp
jne 0x198f7
movq %r15, %rdi
callq 0x3450
xorl %r15d, %r15d
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, %rdi
callq 0x3450
jmp 0x198bd