// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/vcf.c
// Function: vcf_idx_init
static int vcf_idx_init(htsFile *fp, bcf_hdr_t *h, int min_shift, const char *fnidx) {
    int n_lvls, fmt;

    if (min_shift == 0) {
        min_shift = 14;
        n_lvls = 5;
        fmt = HTS_FMT_TBI;
    } else {
        // Set initial n_lvls to match tbx_index()
        int starting_n_lvls = (TBX_MAX_SHIFT - min_shift + 2) / 3;
        // Increase if necessary
        n_lvls = idx_calc_n_lvls_ids(h, min_shift, starting_n_lvls, NULL);
        fmt = HTS_FMT_CSI;
    }

    fp->idx = hts_idx_init(0, fmt, bgzf_tell(fp->fp.bgzf), min_shift, n_lvls);
    if (!fp->idx) return -1;

    // Tabix meta data, added even in CSI for VCF
    uint8_t conf[4*7];
    u32_to_le(TBX_VCF, conf+0);  // fmt
    u32_to_le(1,       conf+4);  // name col
    u32_to_le(2,       conf+8);  // beg col
    u32_to_le(0,       conf+12); // end col
    u32_to_le('#',     conf+16); // comment
    u32_to_le(0,       conf+20); // n.skip
    u32_to_le(0,       conf+24); // ref name len
    if (hts_idx_set_meta(fp->idx, sizeof(conf)*sizeof(*conf), (uint8_t *)conf, 1) < 0) {
        hts_idx_destroy(fp->idx);
        fp->idx = NULL;
        return -1;
    }
    fp->fnidx = fnidx;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x4ae04
movl $0xe, -0x1c(%rbp)
movl $0x5, -0x2c(%rbp)
movl $0x2, -0x30(%rbp)
jmp 0x4ae37
movl $0x1f, %eax
subl -0x1c(%rbp), %eax
addl $0x2, %eax
movl $0x3, %ecx
cltd
idivl %ecx
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl -0x34(%rbp), %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x4a920
movl %eax, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %esi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x18(%rax), %rdx
shlq $0x10, %rdx
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movl 0x10(%rax), %eax
andl $0xffff, %eax           # imm = 0xFFFF
cltq
orq %rax, %rdx
movl -0x1c(%rbp), %ecx
movl -0x2c(%rbp), %r8d
xorl %edi, %edi
callq 0xda10
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x68(%rax)
jne 0x4ae8f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4af55
leaq -0x50(%rbp), %rsi
movl $0x2, %edi
callq 0x40b90
leaq -0x50(%rbp), %rsi
addq $0x4, %rsi
movl $0x1, %edi
callq 0x40b90
leaq -0x50(%rbp), %rsi
addq $0x8, %rsi
movl $0x2, %edi
callq 0x40b90
leaq -0x50(%rbp), %rsi
addq $0xc, %rsi
xorl %edi, %edi
callq 0x40b90
leaq -0x50(%rbp), %rsi
addq $0x10, %rsi
movl $0x23, %edi
callq 0x40b90
leaq -0x50(%rbp), %rsi
addq $0x14, %rsi
xorl %edi, %edi
callq 0x40b90
leaq -0x50(%rbp), %rsi
addq $0x18, %rsi
xorl %edi, %edi
callq 0x40b90
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rdi
leaq -0x50(%rbp), %rdx
movl $0x1c, %esi
movl $0x1, %ecx
callq 0xf4f0
cmpl $0x0, %eax
jge 0x4af42
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0xc2c0
movq -0x10(%rbp), %rax
movq $0x0, 0x68(%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4af55
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x70(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop