// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/hts.c
// Function: idx_find_and_load
static hts_idx_t *idx_find_and_load(const char *fn, int fmt, int flags)
{
    char *fnidx = strstr(fn, HTS_IDX_DELIM);
    hts_idx_t *idx;

    if ( fnidx ) {
        char *fn2 = strdup(fn);
        if (!fn2) {
            hts_log_error("%s", strerror(errno));
            return NULL;
        }
        fn2[fnidx - fn] = '\0';
        fnidx += strlen(HTS_IDX_DELIM);
        idx = hts_idx_load3(fn2, fnidx, fmt, flags);
        free(fn2);
        return idx;
    }

    if (hts_idx_check_local(fn, fmt, &fnidx) == 0 && hisremote(fn)) {
        if (flags & HTS_IDX_SAVE_REMOTE) {
            fnidx = idx_filename(fn, ".csi", HTS_IDX_SAVE_REMOTE);
            if (!fnidx) {
                switch (fmt) {
                case HTS_FMT_BAI: fnidx = idx_filename(fn, ".bai", HTS_IDX_SAVE_REMOTE); break;
                case HTS_FMT_TBI: fnidx = idx_filename(fn, ".tbi", HTS_IDX_SAVE_REMOTE); break;
                default: break;
                }
            }
        } else {
            fnidx = idx_filename(fn, ".csi", 0);
            if (!fnidx) {
                switch (fmt) {
                case HTS_FMT_BAI: fnidx = idx_filename(fn, ".bai", 0); break;
                case HTS_FMT_TBI: fnidx = idx_filename(fn, ".tbi", 0); break;
                default: break;
                }
            }
        }
    }
    if (!fnidx) {
        if (!(flags & HTS_IDX_SILENT_FAIL))
            hts_log_error("Could not retrieve index file for '%s'", fn);
        return 0;
    }

    if (flags & HTS_IDX_SAVE_REMOTE)
        idx = hts_idx_load3(fn, fnidx, fmt, flags);
    else
        idx = idx_read(fnidx);
    free(fnidx);
    return idx;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xca61b(%rip), %rsi     # 0xf0118
callq 0x40c0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x25ba7
movq -0x10(%rbp), %rdi
callq 0x4920
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x25b5b
callq 0x4050
movl (%rax), %edi
callq 0x4130
movq %rax, %rcx
movl $0x1, %edi
leaq 0xcb1d6(%rip), %rsi     # 0xf0d16
leaq 0xccead(%rip), %rdx     # 0xf29f4
movb $0x0, %al
callq 0x1b030
movq $0x0, -0x8(%rbp)
jmp 0x25d38
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rdx
subq %rdx, %rcx
movb $0x0, (%rax,%rcx)
movq -0x20(%rbp), %rax
addq $0x7, %rax
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x25d80
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rdi
callq 0x45a0
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x25d38
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0x20(%rbp), %rdx
callq 0x25370
cmpl $0x0, %eax
jne 0x25cbc
movq -0x10(%rbp), %rdi
callq 0x15cf0
cmpl $0x0, %eax
je 0x25cbc
movl -0x18(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x25c50
movq -0x10(%rbp), %rdi
leaq 0xcac0a(%rip), %rsi     # 0xf07f2
movl $0x1, %edx
callq 0x25970
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x25c4e
movl -0x14(%rbp), %eax
movl %eax, -0x34(%rbp)
subl $0x1, %eax
je 0x25c14
jmp 0x25c0a
movl -0x34(%rbp), %eax
subl $0x2, %eax
je 0x25c2f
jmp 0x25c4a
movq -0x10(%rbp), %rdi
leaq 0xcabce(%rip), %rsi     # 0xf07ed
movl $0x1, %edx
callq 0x25970
movq %rax, -0x20(%rbp)
jmp 0x25c4c
movq -0x10(%rbp), %rdi
leaq 0xcabbd(%rip), %rsi     # 0xf07f7
movl $0x1, %edx
callq 0x25970
movq %rax, -0x20(%rbp)
jmp 0x25c4c
jmp 0x25c4c
jmp 0x25c4e
jmp 0x25cba
movq -0x10(%rbp), %rdi
leaq 0xcab97(%rip), %rsi     # 0xf07f2
xorl %edx, %edx
callq 0x25970
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x25cb8
movl -0x14(%rbp), %eax
movl %eax, -0x38(%rbp)
subl $0x1, %eax
je 0x25c84
jmp 0x25c7a
movl -0x38(%rbp), %eax
subl $0x2, %eax
je 0x25c9c
jmp 0x25cb4
movq -0x10(%rbp), %rdi
leaq 0xcab5e(%rip), %rsi     # 0xf07ed
xorl %edx, %edx
callq 0x25970
movq %rax, -0x20(%rbp)
jmp 0x25cb6
movq -0x10(%rbp), %rdi
leaq 0xcab50(%rip), %rsi     # 0xf07f7
xorl %edx, %edx
callq 0x25970
movq %rax, -0x20(%rbp)
jmp 0x25cb6
jmp 0x25cb6
jmp 0x25cb8
jmp 0x25cba
jmp 0x25cbc
cmpq $0x0, -0x20(%rbp)
jne 0x25cf6
movl -0x18(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x25cec
movq -0x10(%rbp), %rcx
movl $0x1, %edi
leaq 0xcb038(%rip), %rsi     # 0xf0d16
leaq 0xcb043(%rip), %rdx     # 0xf0d28
movb $0x0, %al
callq 0x1b030
movq $0x0, -0x8(%rbp)
jmp 0x25d38
movl -0x18(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x25d1a
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x25d80
movq %rax, -0x28(%rbp)
jmp 0x25d27
movq -0x20(%rbp), %rdi
callq 0x26610
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x45a0
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)