// File: /workspace/github_c_makefile_star2_O3/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
movl 0x4(%r13), %r14d
movl %r14d, 0x1c(%rsp)
movslq %r14d, %rdi
movl $0x8, %esi
callq 0x42f0
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x31fb0
movq %rbx, 0x20(%rsp)
movl (%r13), %eax
testl %eax, %eax
je 0x31f46
movl $0xc, %ebp
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x10(%r13), %rcx
movq %r12, %rdx
shrq $0x4, %rdx
movl (%rcx,%rdx,4), %edx
movl %r15d, %ecx
andb $0x1e, %cl
shrl %cl, %edx
testb $0x3, %dl
jne 0x31f30
movq 0x20(%r13), %rcx
cmpq $0x0, -0x18(%rcx,%rbp,4)
je 0x31f30
movslq (%rcx,%rbp,4), %rbx
cmpl %r14d, %ebx
jl 0x31f1f
leaq 0x1(%rbx), %r14
leaq 0x79ced(%rip), %rax     # 0xabbd5
movq %rax, (%rsp)
movl $0x8, %edi
movl $0x4, %edx
movq %r14, %rsi
leaq 0x1c(%rsp), %rcx
leaq 0x10(%rsp), %r8
movl $0x1, %r9d
callq 0xb0b1
testl %eax, %eax
js 0x31ff1
movl %r14d, 0x1c(%rsp)
movl (%r13), %eax
movq 0x18(%r13), %rcx
movq (%rcx,%r12,8), %rcx
movq 0x10(%rsp), %rdx
movq %rcx, (%rdx,%rbx,8)
incq %r12
movl %eax, %ecx
addq $0xe, %rbp
addl $0x2, %r15d
cmpq %rcx, %r12
jb 0x31ead
testl %r14d, %r14d
movq 0x20(%rsp), %r9
jle 0x31fd5
movl %r14d, %ecx
xorl %eax, %eax
xorl %edx, %edx
movq 0x10(%rsp), %rsi
movslq %edx, %rdi
leal 0x1(%rdi), %edx
cmpl %edx, %r14d
cmovgl %r14d, %edx
cmpq $0x0, (%rsi,%rdi,8)
jne 0x31f7e
incq %rdi
cmpq %rcx, %rdi
jl 0x31f6d
jmp 0x31f80
movl %edi, %edx
cmpl %r14d, %edx
je 0x31fd7
movl %edx, %edi
cmpq %rdi, %rax
je 0x31fa4
movslq %edx, %rdi
movq (%rsi,%rdi,8), %r8
movq %r8, (%rsi,%rax,8)
movq 0x10(%rsp), %rsi
movq $0x0, (%rsi,%rdi,8)
incq %rax
incl %edx
cmpl %r14d, %edx
jl 0x31f5b
jmp 0x31fd7
leaq 0x79c1e(%rip), %rsi     # 0xabbd5
leaq 0x79c28(%rip), %rdx     # 0xabbe6
xorl %r14d, %r14d
movl $0x1, %edi
xorl %eax, %eax
callq 0x942d
movl $0x0, (%rbx)
jmp 0x31fdf
xorl %eax, %eax
movl %eax, (%r9)
movq 0x10(%rsp), %r14
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x79bdd(%rip), %rsi     # 0xabbd5
leaq 0x79be7(%rip), %rdx     # 0xabbe6
xorl %r14d, %r14d
movl $0x1, %edi
xorl %eax, %eax
callq 0x942d
movq 0x20(%rsp), %rax
movl $0x0, (%rax)
movq 0x10(%rsp), %rdi
callq 0x45c0
jmp 0x31fdf