// File: /workspace/github_c_makefile_star2_O1/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 0x52cff
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 0x52d19
movl $0x2, 0x8(%rsp)
movl $0x5, %eax
movq %rax, 0x10(%rsp)
movl $0xe, 0xc(%rsp)
movb $0x1, %r15b
xorl %ebp, %ebp
leaq 0x20(%rsp), %r12
xorl %r13d, %r13d
movq %r14, %rdi
movl $0xa, %esi
movq %r12, %rdx
callq 0x686c1
testl %eax, %eax
js 0x52e0b
movl %r15d, 0x1c(%rsp)
movslq 0x14(%rbx), %r15
cmpq %r15, %rbp
jl 0x52d59
movq 0x30(%rsp), %rax
movsbl (%rax), %eax
cmpl %eax, 0x10(%rbx)
jne 0x52d85
movq 0x10(%r14), %rax
shlq $0x10, %rax
movzwl 0xc(%r14), %r13d
orq %rax, %r13
movq %r14, %rdi
movl $0xa, %esi
movq %r12, %rdx
callq 0x686c1
incq %rbp
testl %eax, %eax
jns 0x52d47
jmp 0x52e0b
testb $0x1, 0x1c(%rsp)
je 0x52da7
xorl %edi, %edi
movl 0x8(%rsp), %esi
movq %r13, %rdx
movl 0xc(%rsp), %ecx
movq 0x10(%rsp), %r8
callq 0x4f58f
movq %rax, 0x18(%rbx)
incq %rbp
movq %rbx, %rdi
movq %r12, %rsi
leaq 0x40(%rsp), %rdx
movl $0x1, %ecx
callq 0x52a1e
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
movl $0x1, %r9d
callq 0x4fe91
xorl %r15d, %r15d
testl %eax, %eax
jns 0x52d26
movq 0x30(%rsp), %rdi
callq 0x68a0
movq %rbx, %rdi
callq 0x52e7a
xorl %ebx, %ebx
jmp 0x52e68
cmpq $0x0, 0x18(%rbx)
jne 0x52e2d
xorl %edi, %edi
movl 0x8(%rsp), %esi
movq %r13, %rdx
movl 0xc(%rsp), %ecx
movq 0x10(%rsp), %r8
callq 0x4f58f
movq %rax, 0x18(%rbx)
cmpq $0x0, 0x20(%rbx)
jne 0x52e3d
callq 0x4c5a1
movq %rax, 0x20(%rbx)
movq 0x18(%rbx), %rdi
movq 0x10(%r14), %rax
shlq $0x10, %rax
movzwl 0xc(%r14), %esi
orq %rax, %rsi
callq 0x4f675
movq %rbx, %rdi
callq 0x52b55
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