// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/faidx.c
// Function: fai_load
faidx_t *fai_load(const char *fn)
{
    char *str;
    FILE *fp;
    faidx_t *fai;
    str = (char*)calloc(strlen(fn) + 5, 1);
    sprintf(str, "%s.fai", fn);

    if (hisremote(str))
    {
        fp = download_and_open(str);
        if ( !fp )
        {
            fprintf(stderr, "[fai_load] failed to open remote FASTA index %s\n", str);
            free(str);
            return 0;
        }
    }
    else
        fp = fopen(str, "rb");

    if (fp == 0) {
        fprintf(stderr, "[fai_load] build FASTA index.\n");
        fai_build(fn);
        fp = fopen(str, "rb");
        if (fp == 0) {
            fprintf(stderr, "[fai_load] fail to open FASTA index.\n");
            free(str);
            return 0;
        }
    }

    fai = fai_read(fp);
    fclose(fp);

    fai->bgzf = bgzf_open(fn, "rb");
    free(str);
    if (fai->bgzf == 0) {
        fprintf(stderr, "[fai_load] fail to open FASTA file.\n");
        return 0;
    }
    if ( fai->bgzf->is_compressed==1 )
    {
        if ( bgzf_index_load(fai->bgzf, fn, ".gzi") < 0 )
        {
            fprintf(stderr, "[fai_load] failed to load .gzi index: %s[.gzi]\n", fn);
            fai_destroy(fai);
            return NULL;
        }
    }
    return fai;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x62c0
movq %rax, %rdi
addq $0x5, %rdi
movl $0x1, %esi
callq 0x6460
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x42c9a(%rip), %rsi     # 0xe30f3
movb $0x0, %al
callq 0x6160
movq -0x18(%rbp), %rdi
callq 0xa2db0
cmpl $0x0, %eax
je 0xa04b6
movq -0x18(%rbp), %rdi
callq 0xa0620
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xa04b4
movq 0x64b47(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
leaq 0x439dd(%rip), %rsi     # 0xe3e74
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0xa060b
jmp 0xa04ca
movq -0x18(%rbp), %rdi
leaq 0x37e7d(%rip), %rsi     # 0xd833e
callq 0x6860
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xa053d
movq 0x64af8(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
leaq 0x439c3(%rip), %rsi     # 0xe3ea5
movb $0x0, %al
callq 0x6a80
movq -0x10(%rbp), %rdi
callq 0xa0250
movq -0x18(%rbp), %rdi
leaq 0x37e41(%rip), %rsi     # 0xd833e
callq 0x6860
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xa053b
movq 0x64abc(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
leaq 0x439a6(%rip), %rsi     # 0xe3ec4
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0xa060b
jmp 0xa053d
movq -0x20(%rbp), %rdi
callq 0xa00c0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x66e0
movq -0x10(%rbp), %rdi
leaq 0x37de0(%rip), %rsi     # 0xd833e
callq 0x9afb0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rdi
callq 0x6880
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xa05a2
movq 0x64a49(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
leaq 0x43959(%rip), %rsi     # 0xe3eea
movb $0x0, %al
callq 0x6a80
movq $0x0, -0x8(%rbp)
jmp 0xa060b
movq -0x28(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
shrl $0x1d, %eax
andl $0x3, %eax
cmpl $0x1, %eax
jne 0xa0603
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
leaq 0x42b32(%rip), %rdx     # 0xe30fa
callq 0x9e170
cmpl $0x0, %eax
jge 0xa0601
movq 0x649f7(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x43928(%rip), %rsi     # 0xe3f0f
movb $0x0, %al
callq 0x6a80
movq -0x28(%rbp), %rdi
callq 0x9fe30
movq $0x0, -0x8(%rbp)
jmp 0xa060b
jmp 0xa0603
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)