// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/cram/open_trace_file.c
// Function: open_path_mfile
mFILE *open_path_mfile(char *file, char *path, char *relative_to) {
    char *newsearch;
    char *ele;
    mFILE *fp;

    /* 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))) {
		free(newsearch);
		return fp;
	    }
	} else if (!strncmp(ele2, "http:", 5) ||
		   !strncmp(ele2, "ftp:", 4)) {
	    if ((fp = find_file_url(file, ele2))) {
		free(newsearch);
		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 $0x1018, %rsp           # imm = 0x1018
movq %rdx, %r14
movq %rdi, %rbx
testq %rsi, %rsi
jne 0x5f17e
leaq 0x3a317(%rip), %rdi     # 0x9948d
callq 0x68f0
movq %rax, %rsi
movq %rsi, %rdi
callq 0x5ed8c
testq %rax, %rax
je 0x5f291
movq %rax, %rbp
movq %r14, 0x8(%rsp)
leaq 0x3a2f7(%rip), %r13     # 0x99495
movq %rax, %r15
movzbl (%r15), %eax
cmpl $0x7c, %eax
je 0x5f1b6
movq %r15, %r12
testl %eax, %eax
jne 0x5f1ba
jmp 0x5f247
leaq 0x1(%r15), %r12
movl $0x4, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x6330
testl %eax, %eax
je 0x5f20b
movl $0x5, %edx
movq %r12, %rdi
leaq 0x3a2a1(%rip), %rsi     # 0x9947e
callq 0x6330
testl %eax, %eax
je 0x5f20f
movl $0x4, %edx
movq %r12, %rdi
leaq 0x3a293(%rip), %rsi     # 0x99488
callq 0x6330
testl %eax, %eax
je 0x5f20f
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5f2a9
jmp 0x5f21a
addq $0x4, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5efe1
testq %rax, %rax
je 0x5f22e
movq %rax, %r14
movq %rbp, %rdi
callq 0x68a0
xorl %eax, %eax
jmp 0x5f230
movb $0x1, %al
testb %al, %al
je 0x5f294
movq %r15, %rdi
callq 0x62d0
addq %rax, %r15
incq %r15
jmp 0x5f1a1
movq %rbp, %rdi
callq 0x68a0
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
je 0x5f291
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x6680
movq %r15, %rdi
movl $0x2f, %esi
callq 0x67c0
testq %rax, %rax
je 0x5f27b
movb $0x0, (%rax)
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x5f2a9
testq %rax, %rax
cmovneq %rax, %r14
jne 0x5f294
xorl %r14d, %r14d
movq %r14, %rax
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq