// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x1060, %rsp           # imm = 0x1060
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x81aec
movq -0x28(%rbp), %rax
movl $0x1, (%rax)
cmpq $0x0, -0x18(%rbp)
jne 0x81b03
leaq 0x746c2(%rip), %rdi     # 0xf61bc
callq 0x45e0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x81020
movq %rax, %rcx
movq %rcx, -0x30(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x81b27
movq $0x0, -0x8(%rbp)
jmp 0x81cee
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpb $0x0, (%rax)
je 0x81c7e
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7c, %eax
jne 0x81b56
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x81b5e
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x7465b(%rip), %rsi     # 0xf61c4
movl $0x4, %edx
callq 0x4200
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x81be3
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
addq $0x4, %rsi
callq 0x814e0
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0x81be1
cmpq $0x0, -0x28(%rbp)
je 0x81bcb
movq -0x48(%rbp), %rdi
addq $0x4, %rdi
leaq 0x742e0(%rip), %rsi     # 0xf5e8c
movl $0x5, %edx
callq 0x4200
movl %eax, %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovel %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rdi
callq 0x45a0
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x81cee
jmp 0x81c62
movq -0x48(%rbp), %rdi
callq 0x15cf0
cmpl $0x0, %eax
je 0x81c31
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x814e0
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0x81c2f
movq -0x30(%rbp), %rdi
callq 0x45a0
cmpq $0x0, -0x28(%rbp)
je 0x81c22
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x81cee
jmp 0x81c60
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x81d00
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0x81c5e
movq -0x30(%rbp), %rdi
callq 0x45a0
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x81cee
jmp 0x81c60
jmp 0x81c62
jmp 0x81c64
movq -0x38(%rbp), %rdi
callq 0x41b0
addq $0x1, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x81b2f
movq -0x30(%rbp), %rdi
callq 0x45a0
cmpq $0x0, -0x20(%rbp)
je 0x81ce6
leaq -0x1060(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4450
leaq -0x1060(%rbp), %rdi
movl $0x2f, %esi
callq 0x4510
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x81cc0
movq -0x50(%rbp), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rdi
leaq -0x1060(%rbp), %rsi
callq 0x81d00
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0x81ce4
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x81cee
jmp 0x81ce6
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x1060, %rsp           # imm = 0x1060
popq %rbp
retq
nopl (%rax,%rax)