// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x27323
movq $0x0, -0x8(%rbp)
jmp 0x27513
movslq -0x14(%rbp), %rdi
shlq $0x5, %rdi
callq 0x34d0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x2737e
jmp 0x2733d
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x2736f
movl $0x3, %edi
leaq 0x110bf(%rip), %rsi     # 0x38414
leaq 0x110d1(%rip), %rdx     # 0x3842d
movl $0xfa, %ecx
leaq 0xe864(%rip), %r8       # 0x35bcc
movb $0x0, %al
callq 0x243b0
jmp 0x27371
movq $0x0, -0x8(%rbp)
jmp 0x27513
movq -0x20(%rbp), %rdi
movslq -0x14(%rbp), %rdx
shlq $0x5, %rdx
xorl %esi, %esi
callq 0x3200
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2750b
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
je 0x273e6
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0x3620
movq %rax, -0x40(%rbp)
jmp 0x273ee
xorl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0x273ee
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movw 0x8(%rax), %cx
movq -0x28(%rbp), %rax
movw %cx, 0x8(%rax)
movq -0x30(%rbp), %rax
movw 0xa(%rax), %cx
movq -0x28(%rbp), %rax
movw %cx, 0xa(%rax)
movq -0x30(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x30(%rbp), %rax
movw 0x10(%rax), %cx
movq -0x28(%rbp), %rax
movw %cx, 0x10(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x274fb
movq -0x30(%rbp), %rdi
callq 0x27520
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x274f9
jmp 0x27477
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x274a9
movl $0x3, %edi
leaq 0x10f85(%rip), %rsi     # 0x38414
leaq 0x10f97(%rip), %rdx     # 0x3842d
movl $0x10c, %ecx            # imm = 0x10C
leaq 0xe72a(%rip), %r8       # 0x35bcc
movb $0x0, %al
callq 0x243b0
jmp 0x274ab
jmp 0x274ad
cmpl $0x0, -0x34(%rbp)
jl 0x274e6
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x275d0
movq -0x28(%rbp), %rax
movq (%rax), %rdi
callq 0x3460
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x274ad
movq -0x20(%rbp), %rdi
callq 0x3460
movq $0x0, -0x8(%rbp)
jmp 0x27513
jmp 0x274fb
jmp 0x274fd
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x27398
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)