// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
testq %rdi, %rdi
je 0x19fff
movl %esi, %ebp
movq %rdi, %r13
movslq %esi, %r14
shlq $0x5, %r14
movq %r14, %rdi
callq 0x34b0
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x19f60
movq 0x10(%rsp), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x31e0
testl %ebp, %ebp
jle 0x1a008
movl %ebp, %eax
movq %rax, 0x48(%rsp)
movl $0x1, %ebx
xorl %r15d, %r15d
movq 0x10(%rsp), %r14
movq %r15, 0x50(%rsp)
shlq $0x5, %r15
movq (%r13,%r15), %rdi
testq %rdi, %rdi
je 0x19cab
callq 0x3610
jmp 0x19cad
xorl %eax, %eax
leaq (%r15,%r13), %rcx
addq 0x10(%rsp), %r15
movq %rax, (%r15)
movzwl 0x8(%rcx), %eax
movw %ax, 0x8(%r15)
movzwl 0xa(%rcx), %edx
movw %dx, 0xa(%r15)
movl 0xc(%rcx), %edx
movl %edx, 0xc(%r15)
movzwl 0x10(%rcx), %ebp
movw %bp, 0x10(%r15)
movq $0x0, 0x18(%r15)
movq 0x18(%rcx), %rdi
testq %rdi, %rdi
je 0x19f08
leal -0x2(%rax), %ecx
cmpl $0xd, %ecx
ja 0x19d3a
leaq 0xacd1(%rip), %rdx      # 0x249d0
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
callq 0x3610
movq %rax, %rbp
jmp 0x19efb
movq %rdi, 0x8(%rsp)
movl $0x10, %edi
callq 0x34b0
movq %rax, %rbp
testq %rax, %rax
je 0x19efb
movq 0x8(%rsp), %rcx
jmp 0x19ecb
cmpl $0x29, %eax
jne 0x19e46
movq %rdi, 0x8(%rsp)
movl $0x10, %edi
callq 0x34b0
movq %rax, %rbp
testq %rax, %rax
je 0x19efb
movq 0x8(%rsp), %rax
movslq 0x8(%rax), %r12
movq %r12, %rdi
shlq $0x4, %rdi
callq 0x34b0
movq %rax, (%rbp)
testq %rax, %rax
je 0x19f27
movl %r12d, 0x8(%rbp)
testl %r12d, %r12d
jle 0x19efb
movq %rax, %rcx
movq %rbp, 0x20(%rsp)
movq %r13, 0x28(%rsp)
movq %rcx, %rbp
addq $0x8, %rbp
movl $0x8, %r13d
movl $0x1, %edx
xorl %esi, %esi
movq %rcx, 0x18(%rsp)
movq %r12, 0x38(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdx, 0x30(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %r12
movzwl -0x8(%r12,%r13), %eax
movw %ax, -0x8(%rcx,%r13)
movzwl -0x6(%r12,%r13), %edi
movq 0x18(%rsp), %rax
movw %di, -0x6(%rax,%r13)
callq 0x34b0
movq 0x18(%rsp), %rcx
movq %rax, (%rcx,%r13)
testq %rax, %rax
je 0x19f2c
movq (%r12,%r13), %rsi
movzwl -0x6(%rcx,%r13), %edx
movq %rax, %rdi
callq 0x32b0
movq 0x18(%rsp), %rcx
movq 0x40(%rsp), %rsi
incq %rsi
addq $0x10, %r13
movq 0x30(%rsp), %rdx
incq %rdx
addq $0x10, %rbp
movq 0x38(%rsp), %rax
cmpq %rsi, %rax
jne 0x19db8
movq 0x28(%rsp), %r13
movq 0x20(%rsp), %rbp
jmp 0x19efb
movq %rdi, 0x8(%rsp)
movq %rbp, %rdi
callq 0x34b0
movq %rax, %r12
testq %rax, %rax
je 0x19e6b
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq 0x32b0
movq %r12, %rbp
jmp 0x19efb
movq %rdi, 0x8(%rsp)
movl $0x10, %edi
callq 0x34b0
movq %rax, %rbp
testq %rax, %rax
je 0x19efb
movq 0x8(%rsp), %rcx
movzwl (%rcx), %eax
movw %ax, (%rbp)
jmp 0x19ee5
movq %rdi, 0x8(%rsp)
movl $0x28, %edi
callq 0x34b0
movq %rax, %rbp
testq %rax, %rax
je 0x19efb
movq 0x8(%rsp), %rcx
movq 0x20(%rcx), %rax
movq %rax, 0x20(%rbp)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups %xmm1, 0x10(%rbp)
movups %xmm0, (%rbp)
movq (%rcx), %rdi
testq %rdi, %rdi
je 0x19edf
callq 0x3610
movq 0x8(%rsp), %rcx
jmp 0x19ee1
xorl %eax, %eax
movq %rax, (%rbp)
movq 0x8(%rcx), %rdi
testq %rdi, %rdi
je 0x19ef5
callq 0x3610
jmp 0x19ef7
xorl %eax, %eax
movq %rax, 0x8(%rbp)
movq %rbp, 0x18(%r15)
testq %rbp, %rbp
je 0x19faa
movq 0x50(%rsp), %r15
incq %r15
incq %rbx
addq $0x20, %r14
cmpq 0x48(%rsp), %r15
jne 0x19c91
jmp 0x1a008
movq %rbp, %rdi
jmp 0x19f57
movq 0x28(%rsp), %r13
movq 0x30(%rsp), %r12
movq (%rbp), %rdi
callq 0x3450
addq $-0x10, %rbp
decq %r12
jg 0x19f36
movq 0x18(%rsp), %rdi
callq 0x3450
movq 0x20(%rsp), %rdi
callq 0x3450
xorl %ebp, %ebp
jmp 0x19efb
movq $0x0, 0x10(%rsp)
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x1a008
leaq 0xac54(%rip), %rsi      # 0x24bd4
leaq 0xac66(%rip), %rdx      # 0x24bed
leaq 0x8668(%rip), %r8       # 0x225f6
movq $0x0, 0x10(%rsp)
movl $0x3, %edi
movl $0xfa, %ecx
xorl %eax, %eax
callq 0x17d92
jmp 0x1a008
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x19fdc
leaq 0xac17(%rip), %rsi      # 0x24bd4
leaq 0xac29(%rip), %rdx      # 0x24bed
leaq 0x862b(%rip), %r8       # 0x225f6
movl $0x3, %edi
movl $0x10c, %ecx            # imm = 0x10C
xorl %eax, %eax
callq 0x17d92
movq %r14, %rdi
callq 0x1a01c
movq (%r14), %rdi
callq 0x3450
addq $-0x20, %r14
decq %rbx
jg 0x19fdc
movq 0x10(%rsp), %rdi
callq 0x3450
movq $0x0, 0x10(%rsp)
movq 0x10(%rsp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq