// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl $0x1, %edi
movl $0x28, %esi
callq 0x42e0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xf22aa
movq $0x0, -0x8(%rbp)
jmp 0xf2483
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %ecx
movl $0x2, %edx
callq 0x14ae0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0xf22eb
movq -0x28(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0xf2483
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x44(%rbp), %rsi
callq 0xf5c0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xf230d
cmpl $0x1c, -0x44(%rbp)
jae 0xf2312
jmp 0xf243b
movq -0x30(%rbp), %rdi
callq 0xf2710
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rdi
addq $0x4, %rdi
callq 0xf2710
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x30(%rbp), %rdi
addq $0x8, %rdi
callq 0xf2710
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x30(%rbp), %rdi
addq $0xc, %rdi
callq 0xf2710
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x30(%rbp), %rdi
addq $0x10, %rdi
callq 0xf2710
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x30(%rbp), %rdi
addq $0x14, %rdi
callq 0xf2710
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x30(%rbp), %rdi
addq $0x18, %rdi
callq 0xf2760
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl -0x44(%rbp), %ecx
subl $0x1c, %ecx
cmpl %ecx, %eax
jbe 0xf23b3
jmp 0xf243b
movq -0x30(%rbp), %rax
addq $0x1c, %rax
movq %rax, -0x38(%rbp)
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
movl -0x48(%rbp), %ecx
cmpq %rcx, %rax
jge 0xf2431
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl $0x1, %edx
callq 0xf0790
cmpl $0x0, %eax
jge 0xf2418
callq 0x4050
movl (%rax), %edi
callq 0x4120
movq %rax, %rcx
movl $0x1, %edi
leaq 0x1b29c(%rip), %rsi     # 0x10d6a4
leaq 0x151f1(%rip), %rdx     # 0x107600
movb $0x0, %al
callq 0x9d90
jmp 0xf2472
jmp 0xf241a
movq -0x40(%rbp), %rdi
callq 0x41a0
addq $0x1, %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0xf23c3
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xf2483
cmpq $0x0, -0x18(%rbp)
je 0xf244c
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0xf2454
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rcx
movl $0x1, %edi
leaq 0x1b240(%rip), %rsi     # 0x10d6a4
leaq 0x1cf90(%rip), %rdx     # 0x10f3fb
movb $0x0, %al
callq 0x9d90
movq -0x28(%rbp), %rdi
callq 0xf2040
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)