// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
pushq $0x1
popq %rdi
pushq $0x30
popq %rsi
callq 0x42f0
testq %rax, %rax
je 0x22a4e
movq %rax, %r13
movl (%rbx), %eax
movl %eax, (%r13)
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
movq %rbx, (%rsp)
je 0x2290c
callq 0x4930
movq (%rsp), %rbx
movq %rax, 0x8(%r13)
testq %rax, %rax
je 0x22a17
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x2292b
callq 0x4930
movq (%rsp), %rbx
movq %rax, 0x10(%r13)
testq %rax, %rax
je 0x22a17
movslq 0x18(%rbx), %r12
movl %r12d, 0x18(%r13)
movq %r12, 0x8(%rsp)
shlq $0x3, %r12
movq %r12, %rdi
callq 0x46a0
movq %rax, 0x20(%r13)
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x22a17
movq %r12, %rdi
callq 0x46a0
movq (%rsp), %rcx
movq %rax, 0x28(%r13)
testq %rax, %rax
je 0x22a17
xorl %r12d, %r12d
movq 0x8(%rsp), %rax
testl %eax, %eax
movl $0x0, %r15d
cmovgl %eax, %r15d
xorl %ebp, %ebp
cmpq %r12, %r15
je 0x22a63
movq %r13, %r14
movq 0x20(%rcx), %rax
movq (%rax,%r12,8), %r13
movslq %ebp, %rbx
testq %r13, %r13
je 0x229de
leaq 0x60122(%rip), %rdi     # 0x82aca
movq %r13, %rsi
callq 0x46e0
testl %eax, %eax
je 0x22a08
movq %r13, %rdi
callq 0x4930
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
movq %r14, %r13
movq 0x20(%r14), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, (%rax,%rbx,8)
movq (%rsp), %rcx
jne 0x229e1
jmp 0x22a17
movq %r14, %r13
movq 0x28(%rcx), %rax
movq (%rax,%r12,8), %rdi
testq %rdi, %rdi
je 0x22a04
callq 0x4930
movq 0x28(%r13), %rcx
movq %rax, (%rcx,%rbx,8)
movq (%rsp), %rcx
testq %rax, %rax
je 0x22a17
incl %ebp
jmp 0x22a0f
movq %r14, %r13
movq (%rsp), %rcx
incq %r12
jmp 0x22985
callq 0x4050
movq %rax, %r14
movl (%rax), %ebp
movl %ebp, %edi
callq 0x4140
leaq 0x63894(%rip), %rsi     # 0x862c3
leaq 0x6388a(%rip), %rdx     # 0x862c0
pushq $0x1
popq %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x8132
movq %r13, %rdi
callq 0x22854
movl %ebp, (%r14)
xorl %r13d, %r13d
movq %r13, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl %ebp, %r15d
je 0x22a51
movq 0x8(%rsp), %rax
subl %r15d, %eax
addl %ebp, %eax
movl %eax, 0x18(%r13)
jmp 0x22a51