// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/vcf.c
// Function: bcf_index_build3
int bcf_index_build3(const char *fn, const char *fnidx, int min_shift, int n_threads)
{
    htsFile *fp;
    hts_idx_t *idx;
    tbx_t *tbx;
    int ret;
    if ((fp = hts_open(fn, "rb")) == 0) return -2;
    if (n_threads)
        hts_set_threads(fp, n_threads);
    if ( fp->format.compression!=bgzf ) { hts_close(fp); return -3; }
    switch (fp->format.format) {
        case bcf:
            if (!min_shift) {
                hts_log_error("TBI indices for BCF files are not supported");
                ret = -1;
            } else {
                idx = bcf_index(fp, min_shift);
                if (idx) {
                    ret = hts_idx_save_as(idx, fn, fnidx, HTS_FMT_CSI);
                    if (ret < 0) ret = -4;
                    hts_idx_destroy(idx);
                }
                else ret = -1;
            }
            break;

        case vcf:
            tbx = tbx_index(hts_get_bgzfp(fp), min_shift, &tbx_conf_vcf);
            if (tbx) {
                ret = hts_idx_save_as(tbx->idx, fn, fnidx, min_shift > 0 ? HTS_FMT_CSI : HTS_FMT_TBI);
                if (ret < 0) ret = -4;
                tbx_destroy(tbx);
            }
            else ret = -1;
            break;

        default:
            ret = -3;
            break;
    }
    hts_close(fp);
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xbd495(%rip), %rsi     # 0x107f76
callq 0x9eb0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x4aafc
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x4ac50
cmpl $0x0, -0x20(%rbp)
je 0x4ab0e
movq -0x28(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0xc660
movq -0x28(%rbp), %rax
cmpl $0x2, 0x54(%rax)
je 0x4ab2d
movq -0x28(%rbp), %rdi
callq 0xbfd0
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x4ac50
movq -0x28(%rbp), %rax
movl 0x4c(%rax), %eax
movl %eax, -0x40(%rbp)
subl $0x8, %eax
je 0x4abc9
jmp 0x4ab42
movl -0x40(%rbp), %eax
subl $0x9, %eax
jne 0x4ac3a
jmp 0x4ab50
cmpl $0x0, -0x1c(%rbp)
jne 0x4ab79
movl $0x1, %edi
leaq 0xbd417(%rip), %rsi     # 0x107f79
leaq 0xbd421(%rip), %rdx     # 0x107f8a
movb $0x0, %al
callq 0x9d90
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
jmp 0x4abc7
movq -0x28(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x4a770
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x4abbe
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
xorl %ecx, %ecx
callq 0xf1c0
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jge 0x4abb3
movl $0xfffffffc, -0x3c(%rbp) # imm = 0xFFFFFFFC
movq -0x30(%rbp), %rdi
callq 0xc2c0
jmp 0x4abc5
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
jmp 0x4abc7
jmp 0x4ac41
movq -0x28(%rbp), %rdi
callq 0xc910
movq %rax, %rdi
movl -0x1c(%rbp), %esi
leaq 0xc4609(%rip), %rdx     # 0x10f1e8
callq 0xf18e0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x4ac31
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %r8d
movl $0x2, %ecx
xorl %eax, %eax
cmpl $0x0, %r8d
cmovgl %eax, %ecx
callq 0xf1c0
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jge 0x4ac26
movl $0xfffffffc, -0x3c(%rbp) # imm = 0xFFFFFFFC
movq -0x38(%rbp), %rdi
callq 0xf2040
jmp 0x4ac38
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
jmp 0x4ac41
movl $0xfffffffd, -0x3c(%rbp) # imm = 0xFFFFFFFD
movq -0x28(%rbp), %rdi
callq 0xbfd0
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)