// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/tbx.c
// Function: index_load
static tbx_t *index_load(const char *fn, const char *fnidx, int flags)
{
    tbx_t *tbx;
    uint8_t *meta;
    char *nm, *p;
    uint32_t l_meta, l_nm;
    tbx = (tbx_t*)calloc(1, sizeof(tbx_t));
    if (!tbx)
        return NULL;
    tbx->idx = hts_idx_load3(fn, fnidx, HTS_FMT_TBI, flags);
    if ( !tbx->idx )
    {
        free(tbx);
        return NULL;
    }
    meta = hts_idx_get_meta(tbx->idx, &l_meta);
    if ( !meta || l_meta < 28) goto invalid;

    tbx->conf.preset = le_to_i32(&meta[0]);
    tbx->conf.sc = le_to_i32(&meta[4]);
    tbx->conf.bc = le_to_i32(&meta[8]);
    tbx->conf.ec = le_to_i32(&meta[12]);
    tbx->conf.meta_char = le_to_i32(&meta[16]);
    tbx->conf.line_skip = le_to_i32(&meta[20]);
    l_nm = le_to_u32(&meta[24]);
    if (l_nm > l_meta - 28) goto invalid;

    p = nm = (char*)meta + 28;
    // This assumes meta is NUL-terminated, so we can merrily strlen away.
    // hts_idx_load_local() assures this for us by adding a NUL on the end
    // of whatever it reads.
    for (; p - nm < l_nm; p += strlen(p) + 1) {
        if (get_tid(tbx, p, 1) < 0) {
            hts_log_error("%s", strerror(errno));
            goto fail;
        }
    }
    return tbx;

 invalid:
    hts_log_error("Invalid index header for %s", fnidx ? fnidx : fn);

 fail:
    tbx_destroy(tbx);
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %r15
movl $0x1, %edi
movl $0x28, %esi
callq 0x42f0
testq %rax, %rax
je 0x9e450
movq %rax, %rbx
movq %r15, %rdi
movq %r12, %rsi
movl $0x2, %edx
movl %ebp, %ecx
callq 0x10db6
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x9e448
leaq 0x24(%rsp), %r13
movq %rax, %rdi
movq %r13, %rsi
callq 0xce7e
movq %rax, %r14
testq %rax, %rax
sete %al
movl (%r13), %ecx
cmpl $0x1c, %ecx
setb %dl
orb %al, %dl
jne 0x9e41a
movl (%r14), %eax
movl %eax, (%rbx)
movl 0x4(%r14), %edx
movl %edx, 0x4(%rbx)
movl 0x8(%r14), %edx
movl %edx, 0x8(%rbx)
movl 0xc(%r14), %edx
movl %edx, 0xc(%rbx)
movl 0x10(%r14), %edx
movl %edx, 0x10(%rbx)
movl 0x14(%r14), %edx
movl %edx, 0x14(%rbx)
movl 0x18(%r14), %ebp
addl $-0x1c, %ecx
cmpl %ecx, %ebp
jbe 0x9e464
testq %r12, %r12
cmovneq %r12, %r15
leaq 0x19d07(%rip), %rsi     # 0xb812f
leaq 0x1ba8c(%rip), %rdx     # 0xb9ebb
movl $0x1, %edi
movq %r15, %rcx
xorl %eax, %eax
callq 0x9774
movq %rbx, %rdi
callq 0x9e22a
jmp 0x9e450
movq %rbx, %rdi
callq 0x45c0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rbp, %rbp
je 0x9e452
addq $0x1c, %r14
movzwl %ax, %r15d
movq %r14, %r12
movl %r15d, 0x8(%rsp)
cmpl $0x3, %r15d
je 0x9e52a
cmpq $0x0, 0x20(%rbx)
jne 0x9e493
callq 0x63f8
movq %rax, 0x20(%rbx)
movq 0x20(%rbx), %r13
testq %r13, %r13
je 0x9e54c
movq %rbp, %r15
movq %r13, %rdi
movq %r12, %rsi
leaq 0xc(%rsp), %rdx
callq 0x6836
cmpl $0x0, 0xc(%rsp)
js 0x9e54c
movl %eax, %ebp
movl %eax, %edx
je 0x9e511
movq %rdx, 0x10(%rsp)
movq %r12, %rdi
callq 0x4930
testq %rax, %rax
je 0x9e4f3
movq 0x18(%r13), %rcx
movq 0x10(%rsp), %rdx
movq %rax, (%rcx,%rdx,8)
movl 0x4(%r13), %esi
decl %esi
movq 0x20(%r13), %rcx
movq %rsi, (%rcx,%rdx,8)
jmp 0x9e50c
movq %r13, %rdi
movq %rax, 0x18(%rsp)
movl %ebp, %esi
callq 0x6a29
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rdx
testq %rax, %rax
je 0x9e54c
cmpl (%r13), %ebp
movq %r15, %rbp
movl 0x8(%rsp), %r15d
je 0x9e54c
movq 0x20(%r13), %rax
testb $-0x80, 0x3(%rax,%rdx,8)
jne 0x9e54c
movq %r12, %rdi
callq 0x41c0
addq %rax, %r12
incq %r12
movq %r12, %rax
subq %r14, %rax
cmpq %rbp, %rax
jl 0x9e479
jmp 0x9e452
callq 0x4050
movl (%rax), %edi
callq 0x4140
leaq 0x19bd0(%rip), %rsi     # 0xb812f
leaq 0x1005a(%rip), %rdx     # 0xae5c0
movl $0x1, %edi
movq %rax, %rcx
jmp 0x9e437