// File: /workspace/github_c_makefile_star2_O2/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 0x18722
movl %esi, %r14d
movq %rdi, %r13
movslq %esi, %rsi
shlq $0x5, %rsi
pushq $0x1
popq %rdi
callq 0x3250
testq %rax, %rax
je 0x18643
movq %rax, %rbp
xorl %eax, %eax
testl %r14d, %r14d
cmovlel %eax, %r14d
xorl %ebx, %ebx
movq %r14, 0x38(%rsp)
movq %r13, 0x30(%rsp)
cmpq %r14, %rbx
je 0x18724
movq %rbx, %r15
shlq $0x5, %r15
movq (%r13,%r15), %rdi
testq %rdi, %rdi
je 0x183fe
callq 0x3620
jmp 0x18400
xorl %eax, %eax
leaq (%r15,%r13), %rcx
addq %rbp, %r15
movq %rax, (%r15)
movq 0x8(%rcx), %rax
movl %eax, 0x8(%r15)
movl 0xc(%rcx), %edx
movl %edx, 0xc(%r15)
movzwl 0x10(%rcx), %r12d
movw %r12w, 0x10(%r15)
andq $0x0, 0x18(%r15)
movq 0x18(%rcx), %rdi
testq %rdi, %rdi
je 0x18618
movq %rax, %xmm0
pextrw $0x0, %xmm0, %eax
leal -0x2(%rax), %ecx
cmpl $0xd, %ecx
ja 0x1848a
leaq 0xa5b2(%rip), %rdx      # 0x22a00
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
callq 0x3620
movq %rax, 0x18(%r15)
testq %rax, %rax
jne 0x18618
jmp 0x186c8
movq %rdi, %r14
pushq $0x10
popq %rdi
callq 0x34c0
testq %rax, %rax
je 0x186c3
movq %rax, %r13
jmp 0x185d9
cmpl $0x29, %eax
jne 0x18555
movq %rdi, 0x40(%rsp)
pushq $0x10
popq %rdi
callq 0x34c0
testq %rax, %rax
je 0x186c3
movq %rax, 0x8(%rsp)
movq 0x40(%rsp), %rax
movslq 0x8(%rax), %r14
movq %r14, %rdi
shlq $0x4, %rdi
callq 0x34c0
movq 0x8(%rsp), %rdi
movq %rax, (%rdi)
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x186be
movq %r15, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
movq %rbp, 0x28(%rsp)
movl %r14d, 0x8(%rdi)
testl %r14d, %r14d
movl $0x0, %eax
cmovlel %eax, %r14d
pushq $0x8
popq %rbp
xorl %r13d, %r13d
cmpq %r13, %r14
movq 0x40(%rsp), %rax
je 0x18620
movq %r14, %r15
movq (%rax), %r12
movl -0x8(%r12,%rbp), %r14d
movq 0x10(%rsp), %rbx
movl %r14d, -0x8(%rbx,%rbp)
shrl $0x10, %r14d
movq %r14, %rdi
callq 0x34c0
movq %rax, (%rbx,%rbp)
testq %rax, %rax
je 0x18680
movq (%r12,%rbp), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x32c0
incq %r13
addq $0x10, %rbp
movq %r15, %r14
jmp 0x184fe
movq %rdi, %r14
movq %r12, %rdi
callq 0x34c0
testq %rax, %rax
je 0x186c3
movq %rax, %r13
movq %rax, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x32c0
jmp 0x1860a
movq %rdi, %r14
pushq $0x10
popq %rdi
callq 0x34c0
testq %rax, %rax
je 0x186c3
movq %rax, %r13
movzwl (%r14), %eax
movw %ax, (%r13)
movq 0x8(%r14), %rdi
jmp 0x185f8
movq %rdi, %r14
pushq $0x28
popq %rdi
callq 0x34c0
testq %rax, %rax
je 0x186c3
movq %rax, %r13
movq 0x20(%r14), %rax
movq %rax, 0x20(%r13)
movdqu (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x10(%r13)
movdqu %xmm0, (%r13)
movq (%r14), %rdi
testq %rdi, %rdi
je 0x185eb
callq 0x3620
movq %r14, %rcx
jmp 0x185f0
movq %r14, %rcx
xorl %eax, %eax
movq %rax, (%r13)
movq 0x8(%rcx), %rdi
testq %rdi, %rdi
je 0x18604
callq 0x3620
jmp 0x18606
xorl %eax, %eax
movq %rax, 0x8(%r13)
movq %r13, 0x18(%r15)
movq 0x38(%rsp), %r14
movq 0x30(%rsp), %r13
incq %rbx
jmp 0x183dd
movq 0x28(%rsp), %rbp
movq 0x38(%rsp), %r14
movq 0x30(%rsp), %r13
movq 0x8(%rsp), %rax
movq 0x20(%rsp), %rbx
movq 0x18(%rsp), %r15
jmp 0x1845c
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0x18724
leaq 0xa5a8(%rip), %rsi      # 0x22c04
leaq 0xa5ba(%rip), %rdx      # 0x22c1d
leaq 0x7f6c(%rip), %r8       # 0x205d6
xorl %ebp, %ebp
pushq $0x3
popq %rdi
movl $0xfa, %ecx
xorl %eax, %eax
callq 0x1662e
jmp 0x18724
movq 0x28(%rsp), %rbp
movq 0x20(%rsp), %rbx
movq 0x18(%rsp), %r15
testl %r13d, %r13d
js 0x186af
movl %r13d, %eax
shlq $0x4, %rax
movq 0x10(%rsp), %rcx
movq 0x8(%rcx,%rax), %rdi
callq 0x3460
decl %r13d
jmp 0x1868f
movq 0x10(%rsp), %rdi
callq 0x3460
movq 0x8(%rsp), %rdi
callq 0x3460
andq $0x0, 0x18(%r15)
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0x18716
leaq 0xa529(%rip), %rsi      # 0x22c04
leaq 0xa53b(%rip), %rdx      # 0x22c1d
leaq 0x7eed(%rip), %r8       # 0x205d6
pushq $0x3
popq %rdi
movl $0x10c, %ecx            # imm = 0x10C
xorl %eax, %eax
callq 0x1662e
jmp 0x18716
movl %ebx, %r14d
shlq $0x5, %r14
leaq (%r14,%rbp), %rdi
callq 0x18736
movq (%rbp,%r14), %rdi
callq 0x3460
decl %ebx
testl %ebx, %ebx
jns 0x186fa
movq %rbp, %rdi
callq 0x3460
xorl %ebp, %ebp
movq %rbp, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq