// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/test/sam.c
// Function: faidx1
static void faidx1(const char *filename)
{
    int n, n_exp = 0, n_fq_exp = 0;
    char tmpfilename[FILENAME_MAX], line[500];
    FILE *fin, *fout;
    faidx_t *fai;

    fin = fopen(filename, "rb");
    if (fin == NULL) fail("can't open %s", filename);
    snprintf(tmpfilename, sizeof(tmpfilename), "%s.tmp", filename);
    fout = fopen(tmpfilename, "wb");
    if (fout == NULL) fail("can't create temporary %s", tmpfilename);
    while (fgets(line, sizeof line, fin)) {
        if (line[0] == '>') n_exp++;
        if (line[0] == '+' && line[1] == '\n') n_fq_exp++;
        fputs(line, fout);
    }
    fclose(fin);
    fclose(fout);

    if (n_exp == 0 && n_fq_exp != 0) {
        // probably a fastq file
        n_exp = n_fq_exp;
    }

    if (fai_build(tmpfilename) < 0) fail("can't index %s", tmpfilename);
    fai = fai_load(tmpfilename);
    if (fai == NULL) { fail("can't load faidx file %s", tmpfilename); return; }

    n = faidx_fetch_nseq(fai);
    if (n != n_exp)
        fail("%s: faidx_fetch_nseq returned %d, expected %d", filename, n, n_exp);

    n = faidx_nseq(fai);
    if (n != n_exp)
        fail("%s: faidx_nseq returned %d, expected %d", filename, n, n_exp);

    fai_destroy(fai);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1240, %rsp           # imm = 0x1240
movq %rdi, -0x8(%rbp)
movl $0x0, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x8(%rbp), %rdi
leaq 0xe7fc0(%rip), %rsi     # 0xf2a58
callq 0x4590
movq %rax, -0x1228(%rbp)
cmpq $0x0, -0x1228(%rbp)
jne 0xaac0
movq -0x8(%rbp), %rsi
leaq 0xe7fa2(%rip), %rdi     # 0xf2a5b
movb $0x0, %al
callq 0x5b50
leaq -0x1020(%rbp), %rdi
movq -0x8(%rbp), %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0xe7f92(%rip), %rdx     # 0xf2a69
movb $0x0, %al
callq 0x47f0
leaq -0x1020(%rbp), %rdi
leaq 0xe6a6f(%rip), %rsi     # 0xf155b
callq 0x4590
movq %rax, -0x1230(%rbp)
cmpq $0x0, -0x1230(%rbp)
jne 0xab17
leaq -0x1020(%rbp), %rsi
leaq 0xe7f60(%rip), %rdi     # 0xf2a70
movb $0x0, %al
callq 0x5b50
jmp 0xab19
leaq -0x1220(%rbp), %rdi
movq -0x1228(%rbp), %rdx
movl $0x1f4, %esi            # imm = 0x1F4
callq 0x47d0
cmpq $0x0, %rax
je 0xab82
movsbl -0x1220(%rbp), %eax
cmpl $0x3e, %eax
jne 0xab4c
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movsbl -0x1220(%rbp), %eax
cmpl $0x2b, %eax
jne 0xab6d
movsbl -0x121f(%rbp), %eax
cmpl $0xa, %eax
jne 0xab6d
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
leaq -0x1220(%rbp), %rdi
movq -0x1230(%rbp), %rsi
callq 0x4530
jmp 0xab19
movq -0x1228(%rbp), %rdi
callq 0x4490
movq -0x1230(%rbp), %rdi
callq 0x4490
cmpl $0x0, -0x10(%rbp)
jne 0xabac
cmpl $0x0, -0x14(%rbp)
je 0xabac
movl -0x14(%rbp), %eax
movl %eax, -0x10(%rbp)
leaq -0x1020(%rbp), %rdi
callq 0xf2c0
cmpl $0x0, %eax
jge 0xabd2
leaq -0x1020(%rbp), %rsi
leaq 0xe7ebf(%rip), %rdi     # 0xf2a8a
movb $0x0, %al
callq 0x5b50
leaq -0x1020(%rbp), %rdi
callq 0xf8e0
movq %rax, -0x1238(%rbp)
cmpq $0x0, -0x1238(%rbp)
jne 0xac06
leaq -0x1020(%rbp), %rsi
leaq 0xe7e9c(%rip), %rdi     # 0xf2a99
movb $0x0, %al
callq 0x5b50
jmp 0xac70
movq -0x1238(%rbp), %rdi
callq 0x10040
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
je 0xac35
movq -0x8(%rbp), %rsi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
leaq 0xe7e84(%rip), %rdi     # 0xf2ab2
movb $0x0, %al
callq 0x5b50
movq -0x1238(%rbp), %rdi
callq 0x10060
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
je 0xac64
movq -0x8(%rbp), %rsi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
leaq 0xe7e83(%rip), %rdi     # 0xf2ae0
movb $0x0, %al
callq 0x5b50
movq -0x1238(%rbp), %rdi
callq 0xeda0
addq $0x1240, %rsp           # imm = 0x1240
popq %rbp
retq
nopl (%rax)