// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/open_trace_file.c
// Function: open_path_mfile
mFILE *open_path_mfile(const char *file, char *path, char *relative_to,
                       int *local) {
    char *newsearch;
    char *ele;
    mFILE *fp;

    if (local)
        *local = 1;

    /* Use path first */
    if (!path)
        path = getenv("RAWDATA");
    if (NULL == (newsearch = tokenise_search_path(path)))
        return NULL;

    /*
     * Step through the search path testing out each component.
     * We now look through each path element treating some prefixes as
     * special, otherwise we treat the element as a directory.
     */
    for (ele = newsearch; *ele; ele += strlen(ele)+1) {
        char *ele2;

        /*
         * '|' prefixing a path component indicates that we do not
         * wish to perform the compression extension searching in that
         * location.
         *
         * NB: this has been removed from the htslib implementation.
         */
        if (*ele == '|') {
            ele2 = ele+1;
        } else {
            ele2 = ele;
        }

        if (0 == strncmp(ele2, "URL=", 4)) {
            if ((fp = find_file_url(file, ele2+4))) {
                if (local)
                    *local = strncmp(ele2+4, "file:", 5) == 0 ? 1 : 0;
                free(newsearch);
                return fp;
            }
        } else if (hisremote(ele2)) {
            if ((fp = find_file_url(file, ele2))) {
                free(newsearch);
                if (local)
                    *local = 0;
                return fp;
            }
        } else if ((fp = find_file_dir(file, ele2))) {
            free(newsearch);
            return fp;
        }
    }

    free(newsearch);

    /* Look in the same location as the incoming 'relative_to' filename */
    if (relative_to) {
        char *cp;
        char relative_path[PATH_MAX+1];
        strcpy(relative_path, relative_to);
        if ((cp = strrchr(relative_path, '/')))
            *cp = 0;
        if ((fp = find_file_dir(file, relative_path)))
            return fp;
    }

    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1028, %rsp           # imm = 0x1028
movq %rcx, %rbx
movq %rdx, %r15
movq %rdi, %r14
testq %rcx, %rcx
je 0x48d9e
movl $0x1, (%rbx)
testq %rsi, %rsi
jne 0x48db2
leaq 0x34a3a(%rip), %rdi     # 0x7d7e4
callq 0x4600
movq %rax, %rsi
movq %rsi, %rdi
callq 0x48714
testq %rax, %rax
je 0x48ea8
movq %r15, 0x18(%rsp)
movq %rbx, 0x10(%rsp)
leaq 0x34a18(%rip), %r13     # 0x7d7ec
pushq $0x4
popq %rbp
movq %rax, 0x8(%rsp)
movq %rax, %r15
movzbl (%r15), %eax
cmpl $0x7c, %eax
je 0x48df1
movq %r15, %r12
testl %eax, %eax
jne 0x48df5
jmp 0x48e5f
leaq 0x1(%r15), %r12
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x4210
testl %eax, %eax
je 0x48e28
movq %r12, %rdi
callq 0xe4f2
movq %r14, %rdi
movq %r12, %rsi
testl %eax, %eax
je 0x48e41
callq 0x489b5
testq %rax, %rax
je 0x48e4f
jmp 0x48eac
addq $0x4, %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x489b5
testq %rax, %rax
je 0x48e4f
jmp 0x48ec8
callq 0x48f15
testq %rax, %rax
jne 0x48ef3
movq %r15, %rdi
callq 0x41d0
addq %rax, %r15
incq %r15
jmp 0x48ddf
movq 0x8(%rsp), %rdi
callq 0x45c0
movq 0x18(%rsp), %rsi
testq %rsi, %rsi
je 0x48ea8
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x4460
pushq $0x2f
popq %rsi
movq %rbx, %rdi
callq 0x4530
testq %rax, %rax
je 0x48e93
movb $0x0, (%rax)
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x48f15
movq %rax, %rbx
testq %rax, %rax
jne 0x48f00
xorl %ebx, %ebx
jmp 0x48f00
movq %rax, %rbx
movq 0x8(%rsp), %rdi
callq 0x45c0
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x48f00
andl $0x0, (%rax)
jmp 0x48f00
movq %rax, %rbx
movq 0x10(%rsp), %r14
testq %r14, %r14
je 0x48ef6
leaq 0x345d8(%rip), %rsi     # 0x7d4b4
pushq $0x5
popq %rdx
movq %r12, %rdi
callq 0x4210
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl %ecx, (%r14)
jmp 0x48ef6
movq %rax, %rbx
movq 0x8(%rsp), %rdi
callq 0x45c0
movq %rbx, %rax
addq $0x1028, %rsp           # imm = 0x1028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq