// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/open_trace_file.c
// Function: tokenise_search_path
char *tokenise_search_path(const char *searchpath) {
    char *newsearch;
    unsigned int i, j;
    size_t len;
    char path_sep = HTS_PATH_SEPARATOR_CHAR;

    if (!searchpath)
        searchpath="";

    newsearch = (char *)malloc((len = strlen(searchpath))+5);
    if (!newsearch)
        return NULL;

    for (i = 0, j = 0; i < len; i++) {
        /* "::" => ":". Used for escaping colons in http://foo */
        if (i < len-1 && searchpath[i] == ':' && searchpath[i+1] == ':') {
            newsearch[j++] = ':';
            i++;
            continue;
        }

        /* Handle http:// and ftp:// too without :: */
        if (path_sep == ':') {
            if ((i == 0 || (i > 0 && searchpath[i-1] == ':')) &&
                (!strncmp(&searchpath[i], "http:",     5) ||
                 !strncmp(&searchpath[i], "https:",    6) ||
                 !strncmp(&searchpath[i], "ftp:",      4) ||
                 !strncmp(&searchpath[i], "|http:",    6) ||
                 !strncmp(&searchpath[i], "|https:",   7) ||
                 !strncmp(&searchpath[i], "|ftp:",     5) ||
                 !strncmp(&searchpath[i], "URL=http:", 9) ||
                 !strncmp(&searchpath[i], "URL=https:",10)||
                 !strncmp(&searchpath[i], "URL=ftp:",  8))) {
                do {
                    newsearch[j++] = searchpath[i];
                } while (i<len && searchpath[i++] != ':');
                if (searchpath[i] == ':')
                    i++;
                if (searchpath[i]=='/')
                    newsearch[j++] = searchpath[i++];
                if (searchpath[i]=='/')
                    newsearch[j++] = searchpath[i++];
                // Look for host:port
                do {
                    newsearch[j++] = searchpath[i++];
                } while (i<len && searchpath[i] != ':' && searchpath[i] != '/');
                newsearch[j++] = searchpath[i++];
                if (searchpath[i] == ':')
                    i++;
            }
        }

        if (searchpath[i] == path_sep) {
            /* Skip blank path components */
            if (j && newsearch[j-1] != 0)
                newsearch[j++] = 0;
        } else {
            newsearch[j++] = searchpath[i];
        }
    }

    if (j)
        newsearch[j++] = 0;
    newsearch[j++] = '.';
    newsearch[j++] = '/';
    newsearch[j++] = 0;
    newsearch[j++] = 0;

    return newsearch;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
leaq 0x2f62a(%rip), %r14     # 0x77d56
cmovneq %rdi, %r14
movq %r14, %rdi
callq 0x41d0
movq %rax, %r15
leaq 0x5(%rax), %rdi
callq 0x4680
movq %rax, %rbx
testq %rax, %rax
je 0x489a3
leaq -0x1(%r15), %rax
movq %rax, 0x10(%rsp)
xorl %r13d, %r13d
xorl %r12d, %r12d
movl %r13d, %ebp
cmpq %rbp, %r15
jbe 0x4896d
cmpq %rbp, 0x10(%rsp)
jbe 0x4878e
cmpb $0x3a, (%r14,%rbp)
jne 0x4878e
leal 0x1(%r13), %ecx
movb $0x3a, %al
cmpb $0x3a, (%r14,%rcx)
jne 0x4878e
movl %ecx, %r13d
jmp 0x48957
testl %r13d, %r13d
je 0x487a2
leal -0x1(%r13), %eax
cmpb $0x3a, (%r14,%rax)
jne 0x4893d
leaq (%r14,%rbp), %rdi
movq %rdi, 0x8(%rsp)
leaq 0x34fc6(%rip), %rsi     # 0x7d778
pushq $0x5
popq %rdx
callq 0x4210
testl %eax, %eax
je 0x4888e
movq 0x8(%rsp), %rdi
leaq 0x34fb4(%rip), %rsi     # 0x7d782
pushq $0x6
popq %rdx
callq 0x4210
testl %eax, %eax
je 0x4888e
movq 0x8(%rsp), %rdi
leaq 0x34fa3(%rip), %rsi     # 0x7d78d
pushq $0x4
popq %rdx
callq 0x4210
testl %eax, %eax
je 0x4888e
movq 0x8(%rsp), %rdi
leaq 0x34f59(%rip), %rsi     # 0x7d75f
pushq $0x6
popq %rdx
callq 0x4210
testl %eax, %eax
je 0x4888e
movq 0x8(%rsp), %rdi
leaq 0x34f48(%rip), %rsi     # 0x7d766
pushq $0x7
popq %rdx
callq 0x4210
testl %eax, %eax
je 0x4888e
movq 0x8(%rsp), %rdi
leaq 0x34f38(%rip), %rsi     # 0x7d76e
pushq $0x5
popq %rdx
callq 0x4210
testl %eax, %eax
je 0x4888e
movq 0x8(%rsp), %rdi
leaq 0x34f26(%rip), %rsi     # 0x7d774
pushq $0x9
popq %rdx
callq 0x4210
testl %eax, %eax
je 0x4888e
movq 0x8(%rsp), %rdi
leaq 0x34f18(%rip), %rsi     # 0x7d77e
pushq $0xa
popq %rdx
callq 0x4210
testl %eax, %eax
je 0x4888e
movq 0x8(%rsp), %rdi
leaq 0x34f0b(%rip), %rsi     # 0x7d789
pushq $0x8
popq %rdx
callq 0x4210
testl %eax, %eax
jne 0x4893d
movl %r12d, %eax
movl %r13d, %ecx
movb (%r14,%rcx), %dl
movl %r12d, %esi
movb %dl, (%rbx,%rsi)
cmpq %rcx, %r15
jbe 0x488b6
incl %r13d
leal 0x1(%rax), %r12d
cmpb $0x3a, %dl
jne 0x4888e
movl %r13d, %ecx
movb (%r14,%rcx), %dl
xorl %ecx, %ecx
cmpb $0x3a, %dl
sete %cl
addl %r13d, %ecx
leal 0x1(%rax), %edi
cmpb $0x2f, (%r14,%rcx)
jne 0x488f2
leal 0x1(%rcx), %esi
leal 0x2(%rax), %edx
movl %edi, %edi
movb $0x2f, (%rbx,%rdi)
cmpb $0x2f, (%r14,%rsi)
jne 0x488ee
addl $0x2, %ecx
addl $0x3, %eax
movl %edx, %edx
movb $0x2f, (%rbx,%rdx)
movl %eax, %edi
jmp 0x488f2
movl %esi, %ecx
movl %edx, %edi
movl %ecx, %eax
movb (%r14,%rax), %al
addl $0x3, %ecx
movl %edi, %esi
movl %ecx, %edx
leal -0x2(%rdx), %ecx
movl %edi, %edi
movb %al, (%rbx,%rdi)
movb (%r14,%rcx), %al
cmpq %rcx, %r15
jbe 0x48926
movzbl %al, %r8d
cmpl $0x3a, %r8d
je 0x48926
leal 0x1(%rdx), %ecx
leal 0x1(%rsi), %edi
cmpl $0x2f, %r8d
jne 0x488fb
leal -0x1(%rdx), %ebp
leal 0x2(%rsi), %r12d
incl %esi
movb %al, (%rbx,%rsi)
cmpb $0x3a, (%r14,%rbp)
cmovel %edx, %ebp
movl %ebp, %r13d
movb (%r14,%rbp), %al
cmpb $0x3a, %al
jne 0x48957
testl %r12d, %r12d
je 0x48968
leal -0x1(%r12), %eax
cmpb $0x0, (%rbx,%rax)
je 0x48960
xorl %eax, %eax
movl %r12d, %ecx
incl %r12d
movb %al, (%rbx,%rcx)
incl %r13d
jmp 0x4875f
xorl %r12d, %r12d
jmp 0x48960
testl %r12d, %r12d
je 0x4897e
movl %r12d, %eax
incl %r12d
movb $0x0, (%rbx,%rax)
jmp 0x48981
xorl %r12d, %r12d
leal 0x1(%r12), %eax
movl %r12d, %ecx
movb $0x2e, (%rbx,%rcx)
leal 0x2(%r12), %ecx
movb $0x2f, (%rbx,%rax)
addl $0x3, %r12d
xorl %eax, %eax
movb %al, (%rbx,%rcx)
movb %al, (%rbx,%r12)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq