// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/vcf.c
// Function: bcf_hdr_seqnames
const char **bcf_hdr_seqnames(const bcf_hdr_t *h, int *n)
{
    vdict_t *d = (vdict_t*)h->dict[BCF_DT_CTG];
    int i, tid, m = kh_size(d);
    const char **names = (const char**) calloc(m,sizeof(const char*));
    if ( !names )
    {
        hts_log_error("Failed to allocate memory");
        *n = 0;
        return NULL;
    }
    khint_t k;
    for (k=kh_begin(d); k<kh_end(d); k++)
    {
        if ( !kh_exist(d,k) ) continue;
        if ( !kh_val(d, k).hrec[0] ) continue;  // removed via bcf_hdr_remove
        tid = kh_val(d,k).id;
        if ( tid >= m )
        {
            // This can happen after a contig has been removed from BCF header via bcf_hdr_remove()
            if ( hts_resize(const char*, tid + 1, &m, &names, HTS_RESIZE_CLEAR)<0 )
            {
                hts_log_error("Failed to allocate memory");
                *n = 0;
                free(names);
                return NULL;
            }
            m = tid + 1;
        }
        names[tid] = kh_key(d,k);
    }
    // ensure there are no gaps
    for (i=0,tid=0; tid<m; i++,tid++)
    {
        while ( tid<m && !names[tid] ) tid++;
        if ( tid==m ) break;
        if ( i==tid ) continue;
        names[i] = names[tid];
        names[tid] = 0;
    }
    *n = i;
    return names;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq 0x30(%rdi), %r13
movslq 0x4(%r13), %rdi
movl %edi, 0x14(%rsp)
movl $0x8, %esi
callq 0x42f0
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x331a3
movq %rbx, 0x20(%rsp)
cmpl $0x0, (%r13)
je 0x33136
movl $0xc, %ebp
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x10(%r13), %rax
movl %r15d, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %eax
movl %r14d, %ecx
andb $0x1e, %cl
shrl %cl, %eax
testb $0x3, %al
jne 0x3311e
movq 0x20(%r13), %rax
cmpq $0x0, -0x18(%rax,%rbp,4)
je 0x3311e
movslq (%rax,%rbp,4), %rbx
cmpl 0x14(%rsp), %ebx
jl 0x3310d
leaq 0x1(%rbx), %r12
leaq 0x7bb4b(%rip), %rax     # 0xaec25
movq %rax, (%rsp)
movl $0x8, %edi
movl $0x4, %edx
movq %r12, %rsi
leaq 0x14(%rsp), %rcx
leaq 0x18(%rsp), %r8
movl $0x1, %r9d
callq 0xb422
testl %eax, %eax
js 0x331e7
movl %r12d, 0x14(%rsp)
movq 0x18(%r13), %rax
movq (%rax,%r15,8), %rax
movq 0x18(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
incq %r15
movl (%r13), %eax
addq $0xe, %rbp
addl $0x2, %r14d
cmpq %rax, %r15
jb 0x330a0
movslq 0x14(%rsp), %rcx
xorl %eax, %eax
testq %rcx, %rcx
jle 0x331c8
xorl %edx, %edx
movq 0x20(%rsp), %r9
movq 0x18(%rsp), %rdi
movslq %edx, %rsi
leal 0x1(%rsi), %edx
cmpl %edx, %ecx
cmovgl %ecx, %edx
cmpq $0x0, (%rdi,%rsi,8)
jne 0x3316e
incq %rsi
cmpq %rcx, %rsi
jl 0x3315d
jmp 0x33170
movl %esi, %edx
cmpl %ecx, %edx
je 0x331cd
movl %edx, %esi
cmpq %rsi, %rax
je 0x33198
movq 0x18(%rsp), %rsi
movslq %edx, %rdi
movq (%rsi,%rdi,8), %r8
movq %r8, (%rsi,%rax,8)
movq 0x18(%rsp), %rsi
movq $0x0, (%rsi,%rdi,8)
incq %rax
incl %edx
cmpl %ecx, %edx
jl 0x3314d
jmp 0x331cd
leaq 0x7ba7b(%rip), %rsi     # 0xaec25
leaq 0x7ba85(%rip), %rdx     # 0xaec36
xorl %r14d, %r14d
movl $0x1, %edi
xorl %eax, %eax
callq 0x9774
movl $0x0, (%rbx)
jmp 0x331d5
movq 0x20(%rsp), %r9
movl %eax, (%r9)
movq 0x18(%rsp), %r14
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7ba37(%rip), %rsi     # 0xaec25
leaq 0x7ba41(%rip), %rdx     # 0xaec36
xorl %r14d, %r14d
movl $0x1, %edi
xorl %eax, %eax
callq 0x9774
movq 0x20(%rsp), %rax
movl $0x0, (%rax)
movq 0x18(%rsp), %rdi
callq 0x45c0
jmp 0x331d5