// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/sam.c
// Function: sam_open_mode
int sam_open_mode(char *mode, const char *fn, const char *format)
{
    // TODO Parse "bam5" etc for compression level
    if (format == NULL) {
        // Try to pick a format based on the filename extension
        char extension[HTS_MAX_EXT_LEN];
        if (find_file_extension(fn, extension) < 0) return -1;
        return sam_open_mode(mode, fn, extension);
    }
    else if (strcasecmp(format, "bam") == 0) strcpy(mode, "b");
    else if (strcasecmp(format, "cram") == 0) strcpy(mode, "c");
    else if (strcasecmp(format, "sam") == 0) strcpy(mode, "");
    else if (strcasecmp(format, "sam.gz") == 0) strcpy(mode, "z");
    else if (strcasecmp(format, "fastq") == 0 ||
             strcasecmp(format, "fq") == 0) strcpy(mode, "f");
    else if (strcasecmp(format, "fastq.gz") == 0 ||
             strcasecmp(format, "fq.gz") == 0) strcpy(mode, "fz");
    else if (strcasecmp(format, "fasta") == 0 ||
             strcasecmp(format, "fa") == 0) strcpy(mode, "F");
    else if (strcasecmp(format, "fasta.gz") == 0 ||
             strcasecmp(format, "fa.gz") == 0) strcpy(mode, "Fz");
    else return -1;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x41e22
movq -0x18(%rbp), %rdi
leaq -0x29(%rbp), %rsi
callq 0x41ff0
cmpl $0x0, %eax
jge 0x41e09
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x41fe0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x29(%rbp), %rdx
callq 0x41dd0
movl %eax, -0x4(%rbp)
jmp 0x41fe0
movq -0x20(%rbp), %rdi
leaq 0xae650(%rip), %rsi     # 0xf047d
callq 0x4500
cmpl $0x0, %eax
jne 0x41e4c
movq -0x10(%rbp), %rdi
leaq 0xb38c4(%rip), %rsi     # 0xf5706
callq 0x4450
jmp 0x41fd7
movq -0x20(%rbp), %rdi
leaq 0xae9b3(%rip), %rsi     # 0xf080a
callq 0x4500
cmpl $0x0, %eax
jne 0x41e76
movq -0x10(%rbp), %rdi
leaq 0xb28cf(%rip), %rsi     # 0xf473b
callq 0x4450
jmp 0x41fd5
movq -0x20(%rbp), %rdi
leaq 0xb0da8(%rip), %rsi     # 0xf2c29
callq 0x4500
cmpl $0x0, %eax
jne 0x41ea0
movq -0x10(%rbp), %rdi
leaq 0xae0df(%rip), %rsi     # 0xeff75
callq 0x4450
jmp 0x41fd3
movq -0x20(%rbp), %rdi
leaq 0xae5cb(%rip), %rsi     # 0xf0476
callq 0x4500
cmpl $0x0, %eax
jne 0x41eca
movq -0x10(%rbp), %rdi
leaq 0xb04af(%rip), %rsi     # 0xf236f
callq 0x4450
jmp 0x41fd1
movq -0x20(%rbp), %rdi
leaq 0xae5ac(%rip), %rsi     # 0xf0481
callq 0x4500
cmpl $0x0, %eax
je 0x41ef4
movq -0x20(%rbp), %rdi
leaq 0xae59d(%rip), %rsi     # 0xf0487
callq 0x4500
cmpl $0x0, %eax
jne 0x41f09
movq -0x10(%rbp), %rdi
leaq 0xae755(%rip), %rsi     # 0xf0654
callq 0x4450
jmp 0x41fcf
movq -0x20(%rbp), %rdi
leaq 0xae576(%rip), %rsi     # 0xf048a
callq 0x4500
cmpl $0x0, %eax
je 0x41f33
movq -0x20(%rbp), %rdi
leaq 0xae56a(%rip), %rsi     # 0xf0493
callq 0x4500
cmpl $0x0, %eax
jne 0x41f48
movq -0x10(%rbp), %rdi
leaq 0xb042d(%rip), %rsi     # 0xf236b
callq 0x4450
jmp 0x41fcd
movq -0x20(%rbp), %rdi
leaq 0xae546(%rip), %rsi     # 0xf0499
callq 0x4500
cmpl $0x0, %eax
je 0x41f72
movq -0x20(%rbp), %rdi
leaq 0xae537(%rip), %rsi     # 0xf049f
callq 0x4500
cmpl $0x0, %eax
jne 0x41f84
movq -0x10(%rbp), %rdi
leaq 0xb225c(%rip), %rsi     # 0xf41d9
callq 0x4450
jmp 0x41fcb
movq -0x20(%rbp), %rdi
leaq 0xae513(%rip), %rsi     # 0xf04a2
callq 0x4500
cmpl $0x0, %eax
je 0x41fae
movq -0x20(%rbp), %rdi
leaq 0xae507(%rip), %rsi     # 0xf04ab
callq 0x4500
cmpl $0x0, %eax
jne 0x41fc0
movq -0x10(%rbp), %rdi
leaq 0xb03b5(%rip), %rsi     # 0xf236e
callq 0x4450
jmp 0x41fc9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x41fe0
jmp 0x41fcb
jmp 0x41fcd
jmp 0x41fcf
jmp 0x41fd1
jmp 0x41fd3
jmp 0x41fd5
jmp 0x41fd7
jmp 0x41fd9
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)