// File: /workspace/github_c_makefile_star2_O2/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, %r12
movq 0x30(%rdi), %r15
movl 0x4(%r15), %r14d
movl %r14d, 0x1c(%rsp)
movslq %r14d, %rdi
pushq $0x8
popq %rsi
callq 0x42f0
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x27c51
movq %r12, 0x20(%rsp)
xorl %r12d, %r12d
pushq $0xc
popq %r13
xorl %ebp, %ebp
movl (%r15), %eax
cmpq %rax, %rbp
jae 0x27bdb
movq 0x10(%r15), %rax
movq %rbp, %rcx
shrq $0x4, %rcx
movl (%rax,%rcx,4), %eax
movl %r12d, %ecx
andb $0x1e, %cl
shrl %cl, %eax
testb $0x3, %al
jne 0x27bcb
movq 0x20(%r15), %rax
cmpq $0x0, -0x18(%rax,%r13,4)
je 0x27bcb
movslq (%rax,%r13,4), %rbx
cmpl %r14d, %ebx
jl 0x27bba
leaq 0x1(%rbx), %r14
leaq 0x5eda1(%rip), %rax     # 0x8692e
movq %rax, (%rsp)
pushq $0x8
popq %rdi
movq %r14, %rsi
pushq $0x4
popq %rdx
leaq 0x1c(%rsp), %rcx
leaq 0x10(%rsp), %r8
pushq $0x1
popq %r9
callq 0x9cc8
testl %eax, %eax
js 0x27c82
movl %r14d, 0x1c(%rsp)
movq 0x18(%r15), %rax
movq (%rax,%rbp,8), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
incq %rbp
addl $0x2, %r12d
addq $0xe, %r13
jmp 0x27b47
movslq %r14d, %rax
movl %eax, %edx
negl %edx
xorl %ecx, %ecx
movabsq $0x100000000, %rsi      # imm = 0x100000000
xorl %edi, %edi
movq 0x20(%rsp), %r11
movq 0x10(%rsp), %rbx
cmpl %r14d, %edi
jge 0x27c4c
movslq %edi, %r9
movq %r9, %r8
shlq $0x20, %r8
incl %edi
cmpq %r9, %rax
je 0x27c4c
cmpq $0x0, (%rbx,%r9,8)
jne 0x27c1f
incq %r9
addq %rsi, %r8
jmp 0x27c09
leal (%rdx,%rdi), %r10d
cmpl $0x1, %r10d
je 0x27c4c
movl %r9d, %r9d
cmpq %r9, %rcx
je 0x27c47
sarq $0x1d, %r8
movq (%rbx,%r8), %r9
movq %r9, (%rbx,%rcx,8)
movq 0x10(%rsp), %r9
andq $0x0, (%r9,%r8)
incq %rcx
jmp 0x27bf5
movl %ecx, (%r11)
jmp 0x27c70
leaq 0x5ecd6(%rip), %rsi     # 0x8692e
leaq 0x5ece0(%rip), %rdx     # 0x8693f
xorl %ebx, %ebx
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x8132
andl $0x0, (%r12)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5eca5(%rip), %rsi     # 0x8692e
leaq 0x5ecaf(%rip), %rdx     # 0x8693f
xorl %ebx, %ebx
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x8132
movq 0x20(%rsp), %rax
andl $0x0, (%rax)
movq 0x10(%rsp), %rdi
callq 0x45c0
jmp 0x27c70