// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/bgzf.c
// Function: bgzf_index_load_hfile
int bgzf_index_load_hfile(BGZF *fp, struct hFILE *idx, const char *name)
{
    fp->idx = (bgzidx_t*) calloc(1,sizeof(bgzidx_t));
    if (fp->idx == NULL) goto fail;
    uint64_t x;
    if (hread_uint64(&x, idx) < 0) goto fail;

    fp->idx->noffs = fp->idx->moffs = x + 1;
    fp->idx->offs  = (bgzidx1_t*) malloc(fp->idx->moffs*sizeof(bgzidx1_t));
    if (fp->idx->offs == NULL) goto fail;
    fp->idx->offs[0].caddr = fp->idx->offs[0].uaddr = 0;

    int i;
    for (i=1; i<fp->idx->noffs; i++)
    {
        if (hread_uint64(&fp->idx->offs[i].caddr, idx) < 0) goto fail;
        if (hread_uint64(&fp->idx->offs[i].uaddr, idx) < 0) goto fail;
    }

    return 0;

 fail:
    hts_log_error("Error reading %s : %s", name ? name : "index", strerror(errno));
    if (fp->idx) {
        free(fp->idx->offs);
        free(fp->idx);
        fp->idx = NULL;
    }
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, 0x10(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
movl $0x1, %edi
movl $0x18, %esi
callq 0x4300
movq %rax, 0x50(%rbx)
testq %rax, %rax
je 0xe4a4
movq 0x8(%r15), %r13
movq 0x10(%r15), %r14
subq %r13, %r14
cmpq $0x8, %r14
movl $0x8, %r12d
cmovbq %r14, %r12
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x43c0
addq %r12, %r13
movq %r13, 0x8(%r15)
cmpq $0x7, %r14
ja 0xe36c
testb $0x2, 0x30(%r15)
je 0xe36c
leaq 0x8(%rsp), %rsi
movl $0x8, %edx
movq %r15, %rdi
movq %r12, %rcx
callq 0xf2cd
movq %rax, %r12
cmpq $0x8, %r12
jne 0xe4a4
movl 0x8(%rsp), %eax
incl %eax
movq 0x50(%rbx), %r14
movl %eax, 0x4(%r14)
movl %eax, (%r14)
movslq %eax, %rdi
shlq $0x4, %rdi
callq 0x4680
movq %rax, 0x8(%r14)
testq %rax, %rax
je 0xe4a4
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq 0x50(%rbx), %rax
xorl %ebp, %ebp
cmpl $0x2, (%rax)
jl 0xe50b
movl $0x1, %r14d
movl $0x18, %ebp
movq %rbx, (%rsp)
movq 0x8(%rax), %r13
addq %rbp, %r13
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rbx
subq %rsi, %rbx
cmpq $0x8, %rbx
movl $0x8, %r12d
cmovbq %rbx, %r12
movq %r13, %rdi
movq %r12, %rdx
callq 0x43c0
addq %r12, 0x8(%r15)
cmpq $0x7, %rbx
ja 0xe416
testb $0x2, 0x30(%r15)
je 0xe416
movl $0x8, %edx
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rcx
callq 0xf2cd
movq %rax, %r12
movq (%rsp), %rbx
cmpq $0x8, %r12
jne 0xe4a4
movq 0x50(%rbx), %rax
movq 0x8(%rax), %rax
leaq (%rax,%rbp), %r13
addq $-0x8, %r13
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rbx
subq %rsi, %rbx
cmpq $0x8, %rbx
movl $0x8, %r12d
cmovbq %rbx, %r12
movq %r13, %rdi
movq %r12, %rdx
callq 0x43c0
addq %r12, 0x8(%r15)
cmpq $0x7, %rbx
ja 0xe47f
testb $0x2, 0x30(%r15)
je 0xe47f
movl $0x8, %edx
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rcx
callq 0xf2cd
movq %rax, %r12
movq (%rsp), %rbx
cmpq $0x8, %r12
jne 0xe4a4
incq %r14
movq 0x50(%rbx), %rax
movslq (%rax), %rcx
addq $0x10, %rbp
cmpq %rcx, %r14
jl 0xe3c4
xorl %ebp, %ebp
jmp 0xe50b
movq 0x10(%rsp), %rax
testq %rax, %rax
leaq 0x8cf5b(%rip), %r15     # 0x9b40e
cmovneq %rax, %r15
callq 0x4050
movl (%rax), %edi
callq 0x4150
leaq 0x8998d(%rip), %rsi     # 0x97e57
leaq 0x8999c(%rip), %rdx     # 0x97e6d
movl $0x1, %edi
movq %r15, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x14378
movq 0x50(%rbx), %rax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0xe50b
movq 0x8(%rax), %rdi
callq 0x45c0
movq 0x50(%rbx), %rdi
callq 0x45c0
movq $0x0, 0x50(%rbx)
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq