// File: karel-brinda[P]ococo/ext/htslib/cram/open_trace_file.c
// Function: tokenise_search_path
char *tokenise_search_path(char *searchpath) {
    char *newsearch;
    unsigned int i, j;
    size_t len;
#ifdef _WIN32
    char path_sep = ';';
#else
    char path_sep = ':';
#endif

    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], "ftp:",      4) ||
		 !strncmp(&searchpath[i], "|http:",    6) ||
		 !strncmp(&searchpath[i], "|ftp:",     5) ||
		 !strncmp(&searchpath[i], "URL=http:", 9) ||
		 !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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movb $0x3a, -0x29(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x57262
leaq 0x2526e(%rip), %rax     # 0x7c4cc
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4230
movq %rax, %rdi
movq %rdi, -0x28(%rbp)
addq $0x5, %rdi
callq 0x47a0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x57293
movq $0x0, -0x8(%rbp)
jmp 0x5767f
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x1c(%rbp), %eax
cmpq -0x28(%rbp), %rax
jae 0x57608
movl -0x1c(%rbp), %eax
movq -0x28(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x57306
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
jne 0x57306
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
jne 0x57306
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x20(%rbp)
movl %ecx, %ecx
movb $0x3a, (%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x575fa
movsbl -0x29(%rbp), %eax
cmpl $0x3a, %eax
jne 0x57595
cmpl $0x0, -0x1c(%rbp)
je 0x5733c
cmpl $0x0, -0x1c(%rbp)
jbe 0x57593
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
jne 0x57593
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %eax
addq %rax, %rdi
leaq 0x26385(%rip), %rsi     # 0x7d6d2
movl $0x5, %edx
callq 0x4290
cmpl $0x0, %eax
je 0x57408
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %eax
addq %rax, %rdi
leaq 0x2636b(%rip), %rsi     # 0x7d6dc
movl $0x4, %edx
callq 0x4290
cmpl $0x0, %eax
je 0x57408
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %eax
addq %rax, %rdi
leaq 0x2632c(%rip), %rsi     # 0x7d6c1
movl $0x6, %edx
callq 0x4290
cmpl $0x0, %eax
je 0x57408
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %eax
addq %rax, %rdi
leaq 0x26313(%rip), %rsi     # 0x7d6c8
movl $0x5, %edx
callq 0x4290
cmpl $0x0, %eax
je 0x57408
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %eax
addq %rax, %rdi
leaq 0x262f9(%rip), %rsi     # 0x7d6ce
movl $0x9, %edx
callq 0x4290
cmpl $0x0, %eax
je 0x57408
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %eax
addq %rax, %rdi
leaq 0x262e3(%rip), %rsi     # 0x7d6d8
movl $0x8, %edx
callq 0x4290
cmpl $0x0, %eax
jne 0x57593
jmp 0x5740a
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movl -0x1c(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
cmpq -0x28(%rbp), %rcx
movb %al, -0x2a(%rbp)
jae 0x57456
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
setne %al
movb %al, -0x2a(%rbp)
movb -0x2a(%rbp), %al
testb $0x1, %al
jne 0x5740a
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
jne 0x57476
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0x574ae
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movl %ecx, %ecx
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0x574e6
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movl %ecx, %ecx
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
jmp 0x574e8
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movl %ecx, %ecx
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movl -0x1c(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
cmpq -0x28(%rbp), %rcx
movb %al, -0x2b(%rbp)
jae 0x57549
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0x3a, %ecx
movb %al, -0x2b(%rbp)
je 0x57549
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
setne %al
movb %al, -0x2b(%rbp)
movb -0x2b(%rbp), %al
testb $0x1, %al
jne 0x574e8
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movl %ecx, %ecx
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
jne 0x57591
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x57593
jmp 0x57595
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movsbl (%rax,%rcx), %eax
movsbl -0x29(%rbp), %ecx
cmpl %ecx, %eax
jne 0x575da
cmpl $0x0, -0x20(%rbp)
je 0x575d8
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x575d8
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x20(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
jmp 0x575f8
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
jmp 0x575fa
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x572a1
cmpl $0x0, -0x20(%rbp)
je 0x57623
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x20(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x20(%rbp)
movl %ecx, %ecx
movb $0x2e, (%rax,%rcx)
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x20(%rbp)
movl %ecx, %ecx
movb $0x2f, (%rax,%rcx)
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x20(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x20(%rbp)
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)