// File: /workspace/github_c_makefile_star2_O3/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 0xe375
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 0xe23a
testb $0x2, 0x30(%r15)
je 0xe23a
leaq 0x8(%rsp), %rsi
movl $0x8, %edx
movq %r15, %rdi
movq %r12, %rcx
callq 0xf129
movq %rax, %r12
cmpq $0x8, %r12
jne 0xe375
movl 0x8(%rsp), %ebp
incl %ebp
movq 0x50(%rbx), %r12
movl %ebp, 0x4(%r12)
movl %ebp, (%r12)
movslq %ebp, %rdi
shlq $0x4, %rdi
callq 0x4680
movq %rax, 0x8(%r12)
testq %rax, %rax
je 0xe375
xorl %r14d, %r14d
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
cmpl $0x2, %ebp
jl 0xe3dd
movl $0x1, %r14d
movl $0x18, %ebp
movq %rbx, (%rsp)
movq 0x8(%r12), %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 0xe2e5
testb $0x2, 0x30(%r15)
je 0xe2e5
movl $0x8, %edx
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rcx
callq 0xf129
movq %rax, %r12
movq (%rsp), %rbx
cmpq $0x8, %r12
jne 0xe375
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 0xe34e
testb $0x2, 0x30(%r15)
je 0xe34e
movl $0x8, %edx
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rcx
callq 0xf129
movq %rax, %r12
movq (%rsp), %rbx
cmpq $0x8, %r12
jne 0xe375
incq %r14
movq 0x50(%rbx), %r12
movslq (%r12), %rax
addq $0x10, %rbp
cmpq %rax, %r14
jl 0xe292
xorl %r14d, %r14d
jmp 0xe3dd
movq 0x10(%rsp), %rax
testq %rax, %rax
leaq 0x8a095(%rip), %r15     # 0x98419
cmovneq %rax, %r15
callq 0x4050
movl (%rax), %edi
callq 0x4150
leaq 0x86afc(%rip), %rsi     # 0x94e97
leaq 0x86b0b(%rip), %rdx     # 0x94ead
movl $0x1, %edi
movq %r15, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x13de5
movq 0x50(%rbx), %rax
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testq %rax, %rax
je 0xe3dd
movq 0x8(%rax), %rdi
callq 0x45c0
movq 0x50(%rbx), %rdi
callq 0x45c0
movq $0x0, 0x50(%rbx)
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq