// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/htslib/tbx.c
// Function: tbx_index
tbx_t *tbx_index(BGZF *fp, int min_shift, const tbx_conf_t *conf)
{
    tbx_t *tbx;
    kstring_t str;
    int ret, first = 0, n_lvls, fmt;
    int64_t lineno = 0;
    uint64_t last_off = 0;
    tbx_intv_t intv;

    str.s = 0; str.l = str.m = 0;
    tbx = (tbx_t*)calloc(1, sizeof(tbx_t));
    tbx->conf = *conf;
    if (min_shift > 0) n_lvls = (TBX_MAX_SHIFT - min_shift + 2) / 3, fmt = HTS_FMT_CSI;
    else min_shift = 14, n_lvls = 5, fmt = HTS_FMT_TBI;
    while ((ret = bgzf_getline(fp, '\n', &str)) >= 0) {
        ++lineno;
        if (lineno <= tbx->conf.line_skip || str.s[0] == tbx->conf.meta_char) {
            last_off = bgzf_tell(fp);
            continue;
        }
        if (first == 0) {
            tbx->idx = hts_idx_init(0, fmt, last_off, min_shift, n_lvls);
            first = 1;
        }
        get_intv(tbx, &str, &intv, 1);
        ret = hts_idx_push(tbx->idx, intv.tid, intv.beg, intv.end, bgzf_tell(fp), 1);
        if (ret < 0)
        {
            free(str.s);
            tbx_destroy(tbx);
            return NULL;
        }
    }
    if ( !tbx->idx ) tbx->idx = hts_idx_init(0, fmt, last_off, min_shift, n_lvls);   // empty file
    if ( !tbx->dict ) tbx->dict = kh_init(s2i);
    hts_idx_finish(tbx->idx, bgzf_tell(fp));
    tbx_set_meta(tbx);
    free(str.s);
    return tbx;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %r14
movl $0x1, %edi
movl $0x28, %esi
callq 0x6470
movq %rax, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x10(%r15), %rax
movq %rax, 0x10(%rbx)
movups (%r15), %xmm0
movups %xmm0, (%rbx)
testl %ebp, %ebp
jle 0x52f6a
movl $0x21, %eax
movl %ebp, 0xc(%rsp)
subl %ebp, %eax
cltq
imulq $0x55555556, %rax, %rcx # imm = 0x55555556
movq %rcx, %rax
shrq $0x3f, %rax
shrq $0x20, %rcx
addl %eax, %ecx
movq %rcx, 0x10(%rsp)
movl $0x0, 0x8(%rsp)
jmp 0x52f84
movl $0x2, 0x8(%rsp)
movl $0x5, %eax
movq %rax, 0x10(%rsp)
movl $0xe, 0xc(%rsp)
movb $0x1, %cl
xorl %r13d, %r13d
leaq 0x20(%rsp), %rbp
xorl %r15d, %r15d
xorl %r12d, %r12d
movl %ecx, 0x1c(%rsp)
movq %r13, 0x38(%rsp)
movq %r14, %rdi
movl $0xa, %esi
movq %rbp, %rdx
callq 0x687af
testl %eax, %eax
js 0x5307f
movslq 0x14(%rbx), %r13
cmpq %r13, %r15
jl 0x52fcb
movq 0x30(%rsp), %rax
movsbl (%rax), %eax
cmpl %eax, 0x10(%rbx)
jne 0x52ff7
movq 0x10(%r14), %rax
shlq $0x10, %rax
movzwl 0xc(%r14), %r12d
orq %rax, %r12
movq %r14, %rdi
movl $0xa, %esi
movq %rbp, %rdx
callq 0x687af
incq %r15
testl %eax, %eax
jns 0x52fb9
jmp 0x5307f
testb $0x1, 0x1c(%rsp)
je 0x53019
xorl %edi, %edi
movl 0x8(%rsp), %esi
movq %r12, %rdx
movl 0xc(%rsp), %ecx
movq 0x10(%rsp), %r8
callq 0x4f7dc
movq %rax, 0x18(%rbx)
incq %r15
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0x40(%rsp), %rdx
movl $0x1, %ecx
callq 0x52c85
movq 0x18(%rbx), %r13
movl 0x60(%rsp), %esi
movl 0x40(%rsp), %edx
movl 0x48(%rsp), %ecx
movq 0x10(%r14), %rax
shlq $0x10, %rax
movzwl 0xc(%r14), %r8d
orq %rax, %r8
movq %r13, %rdi
movl $0x1, %r9d
callq 0x501d6
xorl %ecx, %ecx
testl %eax, %eax
jns 0x52f94
movq 0x30(%rsp), %rdi
callq 0x68a0
movq %rbx, %rdi
callq 0x530f3
xorl %ebx, %ebx
jmp 0x530e1
movq 0x38(%rsp), %r15
testq %r15, %r15
jne 0x530a7
xorl %edi, %edi
movl 0x8(%rsp), %esi
movq %r12, %rdx
movl 0xc(%rsp), %ecx
movq 0x10(%rsp), %r8
callq 0x4f7dc
movq %rax, %r15
movq %rax, 0x18(%rbx)
cmpq $0x0, 0x20(%rbx)
jne 0x530b7
callq 0x4c7e7
movq %rax, 0x20(%rbx)
movq 0x10(%r14), %rax
shlq $0x10, %rax
movzwl 0xc(%r14), %esi
orq %rax, %rsi
movq %r15, %rdi
callq 0x4f8bc
movq %rbx, %rdi
callq 0x52dbc
movq 0x30(%rsp), %rdi
callq 0x68a0
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq