// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/faidx.c
// Function: fai_build
int fai_build(const char *fn)
{
    char *str;
    BGZF *bgzf;
    FILE *fp;
    faidx_t *fai;
    str = (char*)calloc(strlen(fn) + 5, 1);
    sprintf(str, "%s.fai", fn);
    bgzf = bgzf_open(fn, "r");
    if ( !bgzf ) {
        fprintf(stderr, "[fai_build] fail to open the FASTA file %s\n",fn);
        free(str);
        return -1;
    }
    if ( bgzf->is_compressed ) bgzf_index_build_init(bgzf);
    fai = fai_build_core(bgzf);
    if ( !fai )
    {
        if ( bgzf->is_compressed && bgzf->is_gzip ) fprintf(stderr,"Cannot index files compressed with gzip, please use bgzip\n");
        bgzf_close(bgzf);
        free(str);
        return -1;
    }
    if ( bgzf->is_compressed ) bgzf_index_dump(bgzf, fn, ".gzi");
    bgzf_close(bgzf);
    fp = fopen(str, "wb");
    if ( !fp ) {
        fprintf(stderr, "[fai_build] fail to write FASTA index %s\n",str);
        fai_destroy(fai); free(str);
        return -1;
    }
    fai_save(fai, fp);
    fclose(fp);
    free(str);
    fai_destroy(fai);
    return 0;
}

// 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 0x42e6a(%rip), %rsi     # 0xe30f3
movb $0x0, %al
callq 0x6160
movq -0x10(%rbp), %rdi
leaq 0x3fafb(%rip), %rsi     # 0xdfd96
callq 0x9afb0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xa02dc
movq 0x64d1e(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x43b23(%rip), %rsi     # 0xe3de3
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rdi
callq 0x6880
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa040e
movq -0x20(%rbp), %rax
movl (%rax), %eax
shrl $0x1d, %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0xa02f6
movq -0x20(%rbp), %rdi
callq 0x9de00
movq -0x20(%rbp), %rdi
callq 0x9f6b0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0xa035f
movq -0x20(%rbp), %rax
movl (%rax), %eax
shrl $0x1d, %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0xa0341
movq -0x20(%rbp), %rax
movl (%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0xa0341
movq 0x64ca0(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
leaq 0x43ad5(%rip), %rsi     # 0xe3e0f
movb $0x0, %al
callq 0x6a80
movq -0x20(%rbp), %rdi
callq 0x9d380
movq -0x18(%rbp), %rdi
callq 0x6880
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa040e
movq -0x20(%rbp), %rax
movl (%rax), %eax
shrl $0x1d, %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0xa0384
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq 0x42d7b(%rip), %rdx     # 0xe30fa
callq 0x9de60
movq -0x20(%rbp), %rdi
callq 0x9d380
movq -0x18(%rbp), %rdi
leaq 0x3c67d(%rip), %rsi     # 0xdca15
callq 0x6860
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xa03df
movq 0x64c21(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
leaq 0x43a8d(%rip), %rsi     # 0xe3e4a
movb $0x0, %al
callq 0x6a80
movq -0x30(%rbp), %rdi
callq 0x9fe30
movq -0x18(%rbp), %rdi
callq 0x6880
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa040e
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x9feb0
movq -0x28(%rbp), %rdi
callq 0x66e0
movq -0x18(%rbp), %rdi
callq 0x6880
movq -0x30(%rbp), %rdi
callq 0x9fe30
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)