// File: /workspace/github_c_makefile_star2_O1/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
pushq %rax
testq %rdi, %rdi
leaq 0x3ef3c(%rip), %r14     # 0x98ccd
cmovneq %rdi, %r14
movq %r14, %rdi
callq 0x41d0
movq %rax, %r15
leaq 0x5(%rax), %rdi
callq 0x4680
xorl %r12d, %r12d
testq %rax, %rax
je 0x59fea
movq %rax, %rbx
testq %r15, %r15
je 0x59fd9
leaq -0x1(%r15), %rax
movq %rax, (%rsp)
xorl %r13d, %r13d
xorl %r12d, %r12d
xorl %ebp, %ebp
cmpq %r13, (%rsp)
jbe 0x59df1
cmpb $0x3a, (%r14,%r13)
jne 0x59df1
leal 0x1(%rbp), %ecx
movb $0x3a, %al
cmpb $0x3a, (%r14,%rcx)
jne 0x59df1
movl %ecx, %ebp
jmp 0x59fbb
testl %ebp, %ebp
je 0x59e03
leal -0x1(%rbp), %eax
cmpb $0x3a, (%r14,%rax)
jne 0x59f9f
addq %r14, %r13
movl $0x5, %edx
movq %r13, %rdi
leaq 0x44970(%rip), %rsi     # 0x9e785
callq 0x4210
testl %eax, %eax
je 0x59eee
movl $0x6, %edx
movq %r13, %rdi
leaq 0x4495e(%rip), %rsi     # 0x9e78f
callq 0x4210
testl %eax, %eax
je 0x59eee
movl $0x4, %edx
movq %r13, %rdi
leaq 0x4494d(%rip), %rsi     # 0x9e79a
callq 0x4210
testl %eax, %eax
je 0x59eee
movl $0x6, %edx
movq %r13, %rdi
leaq 0x44903(%rip), %rsi     # 0x9e76c
callq 0x4210
testl %eax, %eax
je 0x59eee
movl $0x7, %edx
movq %r13, %rdi
leaq 0x448f2(%rip), %rsi     # 0x9e773
callq 0x4210
testl %eax, %eax
je 0x59eee
movl $0x5, %edx
movq %r13, %rdi
leaq 0x448e2(%rip), %rsi     # 0x9e77b
callq 0x4210
testl %eax, %eax
je 0x59eee
movl $0x9, %edx
movq %r13, %rdi
leaq 0x448d0(%rip), %rsi     # 0x9e781
callq 0x4210
testl %eax, %eax
je 0x59eee
movl $0xa, %edx
movq %r13, %rdi
leaq 0x448c2(%rip), %rsi     # 0x9e78b
callq 0x4210
testl %eax, %eax
je 0x59eee
movl $0x8, %edx
movq %r13, %rdi
leaq 0x448b5(%rip), %rsi     # 0x9e796
callq 0x4210
testl %eax, %eax
jne 0x59f9f
movl %r12d, %edx
movl %ebp, %ecx
movb (%r14,%rcx), %al
movl %r12d, %esi
movb %al, (%rbx,%rsi)
cmpq %rcx, %r15
jbe 0x59f0c
incl %ebp
leal 0x1(%rdx), %r12d
cmpb $0x3a, %al
jne 0x59eee
movl %ebp, %ecx
xorl %eax, %eax
cmpb $0x3a, (%r14,%rcx)
sete %al
addl %ebp, %eax
movb (%r14,%rax), %sil
leal 0x1(%rdx), %ecx
cmpb $0x2f, %sil
jne 0x59f34
incl %eax
addl $0x2, %edx
movl %ecx, %ecx
movb %sil, (%rbx,%rcx)
movl %edx, %ecx
movl %eax, %edx
movb (%r14,%rdx), %dl
cmpb $0x2f, %dl
jne 0x59f48
incl %eax
movl %ecx, %esi
incl %ecx
movb %dl, (%rbx,%rsi)
xorl %edi, %edi
movl %edi, %edx
leal (%rax,%rdx), %edi
leal (%rcx,%rdx), %r8d
leal (%rax,%rdx), %esi
incl %esi
movb (%r14,%rdi), %dil
movb %dil, (%rbx,%r8)
cmpq %rsi, %r15
jbe 0x59f79
movzbl (%r14,%rsi), %r8d
cmpl $0x3a, %r8d
je 0x59f79
leal 0x1(%rdx), %edi
cmpl $0x2f, %r8d
jne 0x59f4a
leal (%rax,%rdx), %edi
addl $0x2, %edi
movb (%r14,%rsi), %sil
leal (%rcx,%rdx), %r8d
incl %r8d
movb %sil, (%rbx,%r8)
cmpb $0x3a, (%r14,%rdi)
leal 0x2(%rcx,%rdx), %r12d
leal 0x3(%rax,%rdx), %ebp
cmovnel %edi, %ebp
movl %ebp, %eax
movb (%r14,%rax), %al
cmpb $0x3a, %al
jne 0x59fbb
testl %r12d, %r12d
je 0x59fd4
leal -0x1(%r12), %eax
cmpb $0x0, (%rbx,%rax)
je 0x59fc4
xorl %eax, %eax
movl %r12d, %ecx
incl %r12d
movb %al, (%rbx,%rcx)
incl %ebp
movq %rbp, %r13
cmpq %rbp, %r15
ja 0x59dd1
jmp 0x59fd9
xorl %r12d, %r12d
jmp 0x59fc4
testl %r12d, %r12d
je 0x59fee
movl %r12d, %eax
incl %r12d
movb $0x0, (%rbx,%rax)
jmp 0x59ff1
xorl %ebx, %ebx
jmp 0x5a013
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 $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq