// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x1, %edi
movl $0x18, %esi
callq 0x42f0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x50(%rax)
jne 0x116be
jmp 0x117d4
movq -0x18(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x11870
cmpl $0x0, %eax
jge 0x116d5
jmp 0x117d4
movq -0x28(%rbp), %rax
addq $0x1, %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movslq 0x4(%rax), %rdi
shlq $0x4, %rdi
callq 0x4650
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, 0x8(%rax)
jne 0x1172c
jmp 0x117d4
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %rax
movq $0x0, 0x8(%rax)
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x50(%rcx), %rcx
cmpl (%rcx), %eax
jge 0x117c8
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %rdi
movslq -0x2c(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
addq $0x8, %rdi
movq -0x18(%rbp), %rsi
callq 0x11870
cmpl $0x0, %eax
jge 0x11794
jmp 0x117d4
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %rdi
movslq -0x2c(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x11870
cmpl $0x0, %eax
jge 0x117bb
jmp 0x117d4
jmp 0x117bd
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1175a
movl $0x0, -0x4(%rbp)
jmp 0x11863
cmpq $0x0, -0x20(%rbp)
je 0x117e5
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x117f2
leaq 0xe114f(%rip), %rax     # 0xf293b
movq %rax, -0x38(%rbp)
jmp 0x117f2
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
callq 0x4050
movl (%rax), %edi
callq 0x4130
movq -0x40(%rbp), %rcx
movq %rax, %r8
movl $0x1, %edi
leaq 0xdd843(%rip), %rsi     # 0xef05c
leaq 0xdd852(%rip), %rdx     # 0xef072
movb $0x0, %al
callq 0x1b030
movq -0x10(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x1185c
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %rdi
callq 0x45a0
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x45a0
movq -0x10(%rbp), %rax
movq $0x0, 0x50(%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)