// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/samtools-0.1.18/knetfile.c
// Function: khttp_parse_url
knetFile *khttp_parse_url(const char *fn, const char *mode)
{
	knetFile *fp;
	char *p, *proxy, *q;
	int l;
	if (strstr(fn, "http://") != fn) return 0;
	// set ->http_host
	for (p = (char*)fn + 7; *p && *p != '/'; ++p);
	l = p - fn - 7;
	fp = calloc(1, sizeof(knetFile));
	fp->http_host = calloc(l + 1, 1);
	strncpy(fp->http_host, fn + 7, l);
	fp->http_host[l] = 0;
	for (q = fp->http_host; *q && *q != ':'; ++q);
	if (*q == ':') *q++ = 0;
	// get http_proxy
	proxy = getenv("http_proxy");
	// set ->host, ->port and ->path
	if (proxy == 0) {
		fp->host = strdup(fp->http_host); // when there is no proxy, server name is identical to http_host name.
		fp->port = strdup(*q? q : "80");
		fp->path = strdup(*p? p : "/");
	} else {
		fp->host = (strstr(proxy, "http://") == proxy)? strdup(proxy + 7) : strdup(proxy);
		for (q = fp->host; *q && *q != ':'; ++q);
		if (*q == ':') *q++ = 0; 
		fp->port = strdup(*q? q : "80");
		fp->path = strdup(fn);
	}
	fp->type = KNF_TYPE_HTTP;
	fp->ctrl_fd = fp->fd = -1;
	fp->seek_offset = 0;
	return fp;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq 0x58(%rsp), %rdi
leaq 0xf6c97(%rip), %rsi     # 0x57a251
callq 0x31a20
cmpq 0x58(%rsp), %rax
je 0x4835d4
movq $0x0, 0x60(%rsp)
jmp 0x483904
movq 0x58(%rsp), %rax
addq $0x7, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0x2b(%rsp)
je 0x483607
movq 0x40(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
setne %al
movb %al, 0x2b(%rsp)
movb 0x2b(%rsp), %al
testb $0x1, %al
jne 0x483611
jmp 0x483623
jmp 0x483613
movq 0x40(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x40(%rsp)
jmp 0x4835e2
movq 0x40(%rsp), %rax
movq 0x58(%rsp), %rcx
subq %rcx, %rax
subq $0x7, %rax
movl %eax, 0x2c(%rsp)
movl $0x1, %edi
movl $0x80, %esi
callq 0x32f50
movq %rax, 0x48(%rsp)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rdi
movl $0x1, %esi
callq 0x32f50
movq %rax, %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x78(%rax)
movq 0x48(%rsp), %rax
movq 0x78(%rax), %rdi
movq 0x58(%rsp), %rsi
addq $0x7, %rsi
movslq 0x2c(%rsp), %rdx
callq 0x33190
movq 0x48(%rsp), %rax
movq 0x78(%rax), %rax
movslq 0x2c(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq 0x48(%rsp), %rax
movq 0x78(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0x2a(%rsp)
je 0x4836cd
movq 0x30(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
setne %al
movb %al, 0x2a(%rsp)
movb 0x2a(%rsp), %al
testb $0x1, %al
jne 0x4836d7
jmp 0x4836e9
jmp 0x4836d9
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x4836a8
movq 0x30(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0x48370a
movq 0x30(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x30(%rsp)
movb $0x0, (%rax)
leaq 0xf784a(%rip), %rdi     # 0x57af5b
callq 0x32470
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
jne 0x4837c0
movq 0x48(%rsp), %rax
movq 0x78(%rax), %rdi
callq 0x326e0
movq %rax, %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x30(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x48375a
movq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0x483768
leaq 0x7356a(%rip), %rax     # 0x4f6ccb
movq %rax, 0x20(%rsp)
jmp 0x483768
movq 0x20(%rsp), %rdi
callq 0x326e0
movq %rax, %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x40(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x483797
movq 0x40(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x4837a5
leaq 0x7908d(%rip), %rax     # 0x4fc82b
movq %rax, 0x18(%rsp)
jmp 0x4837a5
movq 0x18(%rsp), %rdi
callq 0x326e0
movq %rax, %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x70(%rax)
jmp 0x4838ca
movq 0x38(%rsp), %rdi
leaq 0xf6a85(%rip), %rsi     # 0x57a251
callq 0x31a20
cmpq 0x38(%rsp), %rax
jne 0x4837ed
movq 0x38(%rsp), %rdi
addq $0x7, %rdi
callq 0x326e0
movq %rax, 0x10(%rsp)
jmp 0x4837fc
movq 0x38(%rsp), %rdi
callq 0x326e0
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0xf(%rsp)
je 0x48383d
movq 0x30(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
setne %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x483847
jmp 0x483859
jmp 0x483849
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x483818
movq 0x30(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0x48387a
movq 0x30(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x30(%rsp)
movb $0x0, (%rax)
movq 0x30(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x483892
movq 0x30(%rsp), %rax
movq %rax, (%rsp)
jmp 0x48389f
leaq 0x73432(%rip), %rax     # 0x4f6ccb
movq %rax, (%rsp)
jmp 0x48389f
movq (%rsp), %rdi
callq 0x326e0
movq %rax, %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x58(%rsp), %rdi
callq 0x326e0
movq %rax, %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x70(%rax)
movq 0x48(%rsp), %rax
movl $0x3, (%rax)
movq 0x48(%rsp), %rax
movl $0xffffffff, 0x4(%rax)  # imm = 0xFFFFFFFF
movq 0x48(%rsp), %rax
movl $0xffffffff, 0x20(%rax) # imm = 0xFFFFFFFF
movq 0x48(%rsp), %rax
movq $0x0, 0x60(%rax)
movq 0x48(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
addq $0x68, %rsp
retq
nop