// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/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 ) return -1;

    fp->idx = (bgzidx_t*) calloc(1,sizeof(bgzidx_t));
    uint64_t x;
    if ( fread(&x, 1, sizeof(x), idx) != sizeof(x) ) return -1;

    fp->idx->noffs = fp->idx->moffs = 1 + (fp->is_be ? ed_swap_8(x) : x);
    fp->idx->offs  = (bgzidx1_t*) malloc(fp->idx->moffs*sizeof(bgzidx1_t));
    fp->idx->offs[0].caddr = fp->idx->offs[0].uaddr = 0;

    int i;
    if ( fp->is_be )
    {
        int ret = 0;
        for (i=1; i<fp->idx->noffs; i++)
        {
            ret += fread(&x, 1, sizeof(x), idx); fp->idx->offs[i].caddr = ed_swap_8(x);
            ret += fread(&x, 1, sizeof(x), idx); fp->idx->offs[i].uaddr = ed_swap_8(x);
        }
        if ( ret != sizeof(x)*2*(fp->idx->noffs-1) ) return -1;
    }
    else
    {
        int ret = 0;
        for (i=1; i<fp->idx->noffs; i++)
        {
            ret += fread(&x, 1, sizeof(x), idx); fp->idx->offs[i].caddr = x;
            ret += fread(&x, 1, sizeof(x), idx); fp->idx->offs[i].uaddr = x;
        }
        if ( ret != sizeof(x)*2*(fp->idx->noffs-1) ) return -1;
    }
    fclose(idx);
    return 0;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x9e201
movq -0x18(%rbp), %rdi
callq 0x62c0
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rdi
callq 0x62c0
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
addl -0x30(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x69c0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x9e1d3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9e519
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
movslq -0x2c(%rbp), %rdx
callq 0x6570
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 0x6570
cmpq $0x0, -0x28(%rbp)
je 0x9e212
movq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x9e21a
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
leaq 0x3a119(%rip), %rsi     # 0xd833e
callq 0x6860
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x9e23e
movq -0x28(%rbp), %rdi
callq 0x6880
cmpq $0x0, -0x38(%rbp)
jne 0x9e251
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9e519
movl $0x1, %edi
movl $0x18, %esi
callq 0x6460
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x38(%rbp), %rcx
leaq -0x40(%rbp), %rdi
movl $0x1, %esi
movl $0x8, %edx
callq 0x6b20
cmpq $0x8, %rax
je 0x9e294
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9e519
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x12, %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x9e2b4
movq -0x40(%rbp), %rdi
callq 0x9e530
movq %rax, -0x60(%rbp)
jmp 0x9e2bc
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%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 0x69c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rcx, 0x8(%rax)
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)
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x12, %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x9e42d
movl $0x0, -0x48(%rbp)
movl $0x1, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
cmpl (%rcx), %eax
jge 0x9e3ff
movq -0x38(%rbp), %rcx
leaq -0x40(%rbp), %rdi
movl $0x1, %esi
movl $0x8, %edx
callq 0x6b20
movq %rax, %rcx
movslq -0x48(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
callq 0x9e530
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movslq -0x44(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rcx
leaq -0x40(%rbp), %rdi
movl $0x1, %esi
movl $0x8, %edx
callq 0x6b20
movq %rax, %rcx
movslq -0x48(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
callq 0x9e530
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movslq -0x44(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x9e349
movslq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
cmpq %rcx, %rax
je 0x9e428
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9e519
jmp 0x9e509
movl $0x0, -0x4c(%rbp)
movl $0x1, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
cmpl (%rcx), %eax
jge 0x9e4e1
movq -0x38(%rbp), %rcx
leaq -0x40(%rbp), %rdi
movl $0x1, %esi
movl $0x8, %edx
callq 0x6b20
movq %rax, %rcx
movslq -0x4c(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x4c(%rbp)
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movslq -0x44(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rcx
leaq -0x40(%rbp), %rdi
movl $0x1, %esi
movl $0x8, %edx
callq 0x6b20
movq %rax, %rcx
movslq -0x4c(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x4c(%rbp)
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movslq -0x44(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x9e43b
movslq -0x4c(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
cmpq %rcx, %rax
je 0x9e507
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9e519
jmp 0x9e509
movq -0x38(%rbp), %rdi
callq 0x66e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)