// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
callq 0x6470
movq %rax, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
movq 0x10(%r15), %rax
movq %rax, 0x10(%rbx)
movups (%r15), %xmm0
movups %xmm0, (%rbx)
testl %ebp, %ebp
jle 0x4b48c
pushq $0x21
popq %rax
movl %ebp, 0x10(%rsp)
subl %ebp, %eax
pushq $0x3
popq %rcx
cltd
idivl %ecx
movl %eax, 0xc(%rsp)
movl $0x0, 0x8(%rsp)
jmp 0x4b4a1
pushq $0x2
popq %rax
movl %eax, 0x8(%rsp)
pushq $0x5
popq %rax
movl %eax, 0xc(%rsp)
pushq $0xe
popq %rax
movl %eax, 0x10(%rsp)
movb $0x1, %cl
movq $0x0, 0x18(%rsp)
pushq $0xa
popq %r15
leaq 0x20(%rsp), %r12
xorl %r13d, %r13d
xorl %ebp, %ebp
movl %ecx, 0x14(%rsp)
movq %r14, %rdi
movl %r15d, %esi
movq %r12, %rdx
callq 0x5d4e1
testl %eax, %eax
js 0x4b585
movslq 0x14(%rbx), %rax
cmpq %rax, %r13
jl 0x4b4ea
movq 0x30(%rsp), %rax
movsbl (%rax), %eax
cmpl %eax, 0x10(%rbx)
jne 0x4b4ff
movq 0x10(%r14), %rax
shlq $0x10, %rax
movzwl 0xc(%r14), %ebp
orq %rax, %rbp
incq %r13
jmp 0x4b4be
testb $0x1, 0x14(%rsp)
je 0x4b521
xorl %edi, %edi
movl 0x8(%rsp), %esi
movq %rbp, %rdx
movl 0x10(%rsp), %ecx
movl 0xc(%rsp), %r8d
callq 0x487ad
movq %rax, 0x18(%rbx)
incq %r13
movq %rbx, %rdi
movq %r12, %rsi
leaq 0x40(%rsp), %rdx
pushq $0x1
popq %rcx
callq 0x4b26a
movq 0x18(%rbx), %rdi
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 %rdi, 0x18(%rsp)
pushq $0x1
popq %r9
callq 0x48ec6
xorl %ecx, %ecx
testl %eax, %eax
jns 0x4b4ba
movq 0x30(%rsp), %rdi
callq 0x68a0
movq %rbx, %rdi
callq 0x4b5f9
xorl %ebx, %ebx
jmp 0x4b5e7
movq 0x18(%rsp), %r15
testq %r15, %r15
jne 0x4b5ad
xorl %edi, %edi
movl 0x8(%rsp), %esi
movq %rbp, %rdx
movl 0x10(%rsp), %ecx
movl 0xc(%rsp), %r8d
callq 0x487ad
movq %rax, %r15
movq %rax, 0x18(%rbx)
cmpq $0x0, 0x20(%rbx)
jne 0x4b5bd
callq 0x45f7d
movq %rax, 0x20(%rbx)
movq 0x10(%r14), %rax
shlq $0x10, %rax
movzwl 0xc(%r14), %esi
orq %rax, %rsi
movq %r15, %rdi
callq 0x4887b
movq %rbx, %rdi
callq 0x4b320
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