// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/hts.c
// Function: hts_open_format
htsFile *hts_open_format(const char *fn, const char *mode, const htsFormat *fmt)
{
    char smode[102], *cp, *cp2, *mode_c;
    htsFile *fp = NULL;
    hFILE *hfile;
    char fmt_code = '\0';

    strncpy(smode, mode, 100);
    smode[100]=0;
    if ((cp = strchr(smode, ',')))
        *cp = '\0';

    // Migrate format code (b or c) to the end of the smode buffer.
    for (cp2 = cp = smode; *cp; cp++) {
        if (*cp == 'b')
            fmt_code = 'b';
        else if (*cp == 'c')
            fmt_code = 'c';
        else
            *cp2++ = *cp;
    }
    mode_c = cp2;
    *cp2++ = fmt_code;
    *cp2++ = 0;
    *cp2++ = 0;

    // Set or reset the format code if opts->format is used
    if (fmt && fmt->format != unknown_format)
        *mode_c = "\0g\0\0b\0c\0\0b\0g\0\0"[fmt->format];

    hfile = hopen(fn, smode);
    if (hfile == NULL) goto error;

    fp = hts_hopen(hfile, fn, smode);
    if (fp == NULL) goto error;

    if (fmt && fmt->specific)
        if (hts_opt_apply(fp, fmt->specific) != 0)
            goto error;

    return fp;

error:
    if (hts_verbose >= 2)
        fprintf(stderr, "[E::%s] fail to open file '%s'\n", __func__, fn);

    if (hfile)
        hclose_abruptly(hfile);

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0xb0(%rbp)
movb $0x0, -0xb9(%rbp)
leaq -0x90(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x64, %edx
callq 0x6370
movb $0x0, -0x2c(%rbp)
leaq -0x90(%rbp), %rdi
movl $0x2c, %esi
callq 0x6260
movq %rax, -0x98(%rbp)
cmpq $0x0, %rax
je 0x70e8a
movq -0x98(%rbp), %rax
movb $0x0, (%rax)
leaq -0x90(%rbp), %rax
movq %rax, -0x98(%rbp)
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rax
cmpb $0x0, (%rax)
je 0x70f13
movq -0x98(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x62, %eax
jne 0x70ec3
movb $0x62, -0xb9(%rbp)
jmp 0x70efd
movq -0x98(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x63, %eax
jne 0x70edb
movb $0x63, -0xb9(%rbp)
jmp 0x70efb
movq -0x98(%rbp), %rax
movb (%rax), %cl
movq -0xa0(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0xa0(%rbp)
movb %cl, (%rax)
jmp 0x70efd
jmp 0x70eff
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0x70e9f
movq -0xa0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movb -0xb9(%rbp), %cl
movq -0xa0(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0xa0(%rbp)
movb %cl, (%rax)
movq -0xa0(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0xa0(%rbp)
movb $0x0, (%rax)
movq -0xa0(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0xa0(%rbp)
movb $0x0, (%rax)
cmpq $0x0, -0x20(%rbp)
je 0x70f9b
movq -0x20(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x70f9b
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %ecx
leaq 0x712c6(%rip), %rax     # 0xe2255
movb (%rax,%rcx), %cl
movq -0xa8(%rbp), %rax
movb %cl, (%rax)
movq -0x10(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xa2a70
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0xb8(%rbp)
jne 0x70fbe
jmp 0x71024
movq -0xb8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x71080
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
jne 0x70fe8
jmp 0x71024
cmpq $0x0, -0x20(%rbp)
je 0x71017
movq -0x20(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x71017
movq -0xb0(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x71610
cmpl $0x0, %eax
je 0x71015
jmp 0x71024
jmp 0x71017
movq -0xb0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x7106e
cmpl $0x2, 0x95fb5(%rip)     # 0x106fe0
jl 0x71050
movq 0x93f9c(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
movq -0x10(%rbp), %rcx
leaq 0x71307(%rip), %rsi     # 0xe2349
leaq 0x71320(%rip), %rdx     # 0xe2369
movb $0x0, %al
callq 0x6a80
cmpq $0x0, -0xb8(%rbp)
je 0x71066
movq -0xb8(%rbp), %rdi
callq 0xa2480
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax,%rax)