// File: /workspace/github_c_makefile_star2_O0/zhou-lab[P]tbmate/htslib/bgzf.c
// Function: bgzf_index_load
int bgzf_index_load(BGZF *fp, const char *bname, const char *suffix)
{
    char *tmp = NULL;
    if ( suffix )
    {
        int blen = strlen(bname);
        int slen = strlen(suffix);
        tmp = (char*) malloc(blen + slen + 1);
        if ( !tmp ) return -1;
        memcpy(tmp,bname,blen);
        memcpy(tmp+blen,suffix,slen+1);
    }

    FILE *idx = fopen(tmp?tmp:bname,"rb");
    if ( tmp ) free(tmp);
    if ( !idx ) {
        if (hts_verbose > 1) {
            fprintf(stderr, "[E::%s] Error opening %s%s : %s\n",
                    __func__, bname, suffix ? suffix : "", strerror(errno));
        }
        return -1;
    }

    fp->idx = (bgzidx_t*) calloc(1,sizeof(bgzidx_t));
    if (fp->idx == NULL) goto fail;
    uint64_t x;
    if (fread_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 (fread_uint64(&fp->idx->offs[i].caddr, idx) < 0) goto fail;
        if (fread_uint64(&fp->idx->offs[i].uaddr, idx) < 0) goto fail;
    }

    if (fclose(idx) != 0) goto fail;
    return 0;

 fail:
    if (hts_verbose > 1)
    {
        fprintf(stderr, "[E::%s] Error reading %s%s : %s\n",
                __func__, bname, suffix ? suffix : "", strerror(errno));
    }
    fclose(idx);
    if (fp->idx) {
        free(fp->idx->offs);
        free(fp->idx);
        fp->idx = NULL;
    }
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x3d0b4
movq -0x18(%rbp), %rdi
callq 0x3380
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rdi
callq 0x3380
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
addl -0x30(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x3250
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x3d086
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3d39c
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
movslq -0x2c(%rbp), %rdx
callq 0x3860
movq -0x28(%rbp), %rdi
movslq -0x2c(%rbp), %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
movl -0x30(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdx
callq 0x3860
cmpq $0x0, -0x28(%rbp)
je 0x3d0c5
movq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x3d0cd
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
leaq 0x387aa(%rip), %rsi     # 0x75882
callq 0x3260
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x3d0f1
movq -0x28(%rbp), %rdi
callq 0x3370
cmpq $0x0, -0x38(%rbp)
jne 0x3d180
leaq 0x4838d(%rip), %rax     # 0x85490
cmpl $0x1, (%rax)
jle 0x3d174
movq 0x47ed9(%rip), %rax     # 0x84fe8
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x3d12f
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x3d13c
leaq 0x3cd86(%rip), %rax     # 0x79ebc
movq %rax, -0x68(%rbp)
jmp 0x3d13c
movq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
callq 0x35d0
movl (%rax), %edi
callq 0x34e0
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rcx
movq -0x70(%rbp), %r8
movq %rax, %r9
leaq 0x3b292(%rip), %rsi     # 0x783f8
leaq 0x3b304(%rip), %rdx     # 0x78471
movb $0x0, %al
callq 0x37f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3d39c
movl $0x1, %edi
movl $0x18, %esi
callq 0x36b0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x3d1aa
jmp 0x3d2d0
movq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x3d3b0
cmpl $0x0, %eax
jge 0x3d1c1
jmp 0x3d2d0
movq -0x40(%rbp), %rax
addq $0x1, %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movslq 0x4(%rax), %rdi
shlq $0x4, %rdi
callq 0x3250
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x8(%rax)
jne 0x3d218
jmp 0x3d2d0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq $0x0, 0x8(%rax)
movl $0x1, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
cmpl (%rcx), %eax
jge 0x3d2b4
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rdi
movslq -0x44(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
addq $0x8, %rdi
movq -0x38(%rbp), %rsi
callq 0x3d3b0
cmpl $0x0, %eax
jge 0x3d280
jmp 0x3d2d0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rdi
movslq -0x44(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x3d3b0
cmpl $0x0, %eax
jge 0x3d2a7
jmp 0x3d2d0
jmp 0x3d2a9
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x3d246
movq -0x38(%rbp), %rdi
callq 0x36d0
cmpl $0x0, %eax
je 0x3d2c4
jmp 0x3d2d0
movl $0x0, -0x4(%rbp)
jmp 0x3d39c
leaq 0x481b9(%rip), %rax     # 0x85490
cmpl $0x1, (%rax)
jle 0x3d357
movq 0x47d05(%rip), %rax     # 0x84fe8
movq (%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x3d306
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x3d316
leaq 0x3cbaf(%rip), %rax     # 0x79ebc
movq %rax, -0x88(%rbp)
jmp 0x3d316
movq -0x88(%rbp), %rax
movq %rax, -0x90(%rbp)
callq 0x35d0
movl (%rax), %edi
callq 0x34e0
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rcx
movq -0x90(%rbp), %r8
movq %rax, %r9
leaq 0x3b138(%rip), %rsi     # 0x78481
leaq 0x3b121(%rip), %rdx     # 0x78471
movb $0x0, %al
callq 0x37f0
movq -0x38(%rbp), %rdi
callq 0x36d0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x3d395
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rdi
callq 0x3370
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x3370
movq -0x10(%rbp), %rax
movq $0x0, 0x48(%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)