// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x2c(%rbp)
movslq -0x2c(%rbp), %rdi
movl $0x8, %esi
callq 0x42e0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x43fb0
movl $0x1, %edi
leaq 0xc3d17(%rip), %rsi     # 0x107ca2
leaq 0xc3d21(%rip), %rdx     # 0x107cb3
movb $0x0, %al
callq 0x9d90
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0x441a4
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x440ee
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x3c(%rbp), %ecx
shrl $0x4, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x3c(%rbp), %ecx
andl $0xf, %ecx
shll %ecx
shrl %cl, %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x43ff0
jmp 0x440e0
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x3c(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x18(%rax)
jne 0x4400e
jmp 0x440e0
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x3c(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x30(%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jl 0x440c5
movl -0x28(%rbp), %eax
addl $0x1, %eax
cmpl -0x2c(%rbp), %eax
jle 0x44073
movl -0x28(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
movl $0x8, %edi
movl $0x4, %edx
leaq -0x2c(%rbp), %rcx
leaq -0x38(%rbp), %r8
movl $0x1, %r9d
leaq 0xc3c3d(%rip), %rax     # 0x107ca2
movq %rax, (%rsp)
callq 0xd200
movl %eax, -0x40(%rbp)
jmp 0x4407a
xorl %eax, %eax
movl %eax, -0x40(%rbp)
jmp 0x4407a
movl -0x40(%rbp), %eax
cmpl $0x0, %eax
jge 0x440bc
movl $0x1, %edi
leaq 0xc3c14(%rip), %rsi     # 0x107ca2
leaq 0xc3c1e(%rip), %rdx     # 0x107cb3
movb $0x0, %al
callq 0x9d90
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x38(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x441a4
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x3c(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
movq -0x38(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x43fb7
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x44193
jmp 0x4410a
movl -0x28(%rbp), %ecx
xorl %eax, %eax
cmpl -0x2c(%rbp), %ecx
movb %al, -0x41(%rbp)
jge 0x4412c
movq -0x38(%rbp), %rax
movslq -0x28(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
setne %al
xorb $-0x1, %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x44135
jmp 0x44140
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x4410a
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0x4414a
jmp 0x44193
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jne 0x44154
jmp 0x4417c
movq -0x38(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x38(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x38(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x440fc
movl -0x24(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nop