// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/vcf.c
// Function: bcf_hrec_dup
bcf_hrec_t *bcf_hrec_dup(bcf_hrec_t *hrec)
{
    int save_errno;
    bcf_hrec_t *out = (bcf_hrec_t*) calloc(1,sizeof(bcf_hrec_t));
    if (!out) return NULL;

    out->type = hrec->type;
    if ( hrec->key ) {
        out->key = strdup(hrec->key);
        if (!out->key) goto fail;
    }
    if ( hrec->value ) {
        out->value = strdup(hrec->value);
        if (!out->value) goto fail;
    }
    out->nkeys = hrec->nkeys;
    out->keys = (char**) malloc(sizeof(char*)*hrec->nkeys);
    if (!out->keys) goto fail;
    out->vals = (char**) malloc(sizeof(char*)*hrec->nkeys);
    if (!out->vals) goto fail;
    int i, j = 0;
    for (i=0; i<hrec->nkeys; i++)
    {
        if ( hrec->keys[i] && !strcmp("IDX",hrec->keys[i]) ) continue;
        if ( hrec->keys[i] ) {
            out->keys[j] = strdup(hrec->keys[i]);
            if (!out->keys[j]) goto fail;
        }
        if ( hrec->vals[i] ) {
            out->vals[j] = strdup(hrec->vals[i]);
            if (!out->vals[j]) goto fail;
        }
        j++;
    }
    if ( i!=j ) out->nkeys -= i-j;   // IDX was omitted
    return out;

 fail:
    save_errno = errno;
    hts_log_error("%s", strerror(errno));
    bcf_hrec_destroy(out);
    errno = save_errno;
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl $0x1, %edi
movl $0x30, %esi
callq 0x42e0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x3b123
movq $0x0, -0x8(%rbp)
jmp 0x3b38c
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x3b164
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x4920
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x3b162
jmp 0x3b338
jmp 0x3b164
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x3b199
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x4920
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x3b197
jmp 0x3b338
jmp 0x3b199
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movslq 0x18(%rax), %rdi
shlq $0x3, %rdi
callq 0x4670
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x3b1d3
jmp 0x3b338
movq -0x10(%rbp), %rax
movslq 0x18(%rax), %rdi
shlq $0x3, %rdi
callq 0x4670
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x3b1ff
jmp 0x3b338
movl $0x0, -0x28(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x3b314
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x3b256
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xc88af(%rip), %rdi     # 0x103af6
callq 0x46b0
cmpl $0x0, %eax
jne 0x3b256
jmp 0x3b306
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x3b2ab
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x4920
movq %rax, %rdx
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x28(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x28(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x3b2a9
jmp 0x3b338
jmp 0x3b2ab
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x24(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x3b2fd
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x4920
movq %rax, %rdx
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x28(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x28(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x3b2fb
jmp 0x3b338
jmp 0x3b2fd
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x3b20d
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
je 0x3b32e
movl -0x24(%rbp), %edx
subl -0x28(%rbp), %edx
movq -0x20(%rbp), %rax
movl 0x18(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x18(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x3b38c
callq 0x4050
movl (%rax), %eax
movl %eax, -0x14(%rbp)
callq 0x4050
movl (%rax), %edi
callq 0x4120
movq %rax, %rcx
movl $0x1, %edi
leaq 0xcc2a6(%rip), %rsi     # 0x107603
leaq 0xcc29c(%rip), %rdx     # 0x107600
movb $0x0, %al
callq 0x9d90
movq -0x20(%rbp), %rdi
callq 0x3b040
movl -0x14(%rbp), %eax
movl %eax, -0x2c(%rbp)
callq 0x4050
movl -0x2c(%rbp), %ecx
movl %ecx, (%rax)
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)