#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ Q_bstrcpy(char *, char *);
int /*<<< orphan*/ Q_strcat(char *, int, char *);
int /*<<< orphan*/ Q_stricmpn(char const *, char *, int);
int /*<<< orphan*/ Q_strncpyz(char *, char const *, int);
char *strchr(char *, char);
void HTTPSplitURL(const char *url, char *address, int lenaddress, char *wwwpath,
                  int lenwwwpath) {
  char *charloc;
  while (*url == ' ')
    url++;
  if (!Q_stricmpn(url, "http://", 7)) {
    url += 7;
  }
  Q_strncpyz(address, url, lenaddress);
  Q_strncpyz(wwwpath, url, lenwwwpath);
  charloc = strchr(address, '/');
  if (charloc) {
    charloc[0] = '\0';
  }
  if (strchr(address, ':') == NULL) {
    Q_strcat(address, lenaddress, ":80");
  }
  charloc = strchr(wwwpath, '/');
  if (charloc && charloc != wwwpath) {
    Q_bstrcpy(wwwpath, charloc);
  } else {
    wwwpath[0] = '/';
    wwwpath[1] = '\0';
  }
}


x86 assembly (clang, -O0):
<HTTPSplitURL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    118c <HTTPSplitURL+0x3c>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    116b <HTTPSplitURL+0x1b>
mov    -0x8(%rbp),%rdi
lea    0xe69(%rip),%rsi
mov    $0x7,%edx
call   1040 <Q_stricmpn@plt>
cmp    $0x0,%eax
jne    11b6 <HTTPSplitURL+0x66>
mov    -0x8(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1070 <Q_strncpyz@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1070 <Q_strncpyz@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11fa <HTTPSplitURL+0xaa>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    1225 <HTTPSplitURL+0xd5>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xde8(%rip),%rdx
call   1060 <Q_strcat@plt>
mov    -0x20(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1262 <HTTPSplitURL+0x112>
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     1262 <HTTPSplitURL+0x112>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <Q_bstrcpy@plt>
jmp    1271 <HTTPSplitURL+0x121>
mov    -0x20(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,0x1(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HTTPSplitURL>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r15d
mov    %rcx,%r12
mov    %edx,%r14d
mov    %rsi,%r13
mov    %rdi,%rbx
add    $0xffffffffffffffff,%rbx
xchg   %ax,%ax
cmpb   $0x20,0x1(%rbx)
lea    0x1(%rbx),%rbx
je     1170 <HTTPSplitURL+0x20>
lea    0xe7f(%rip),%rsi
mov    %rbx,%rdi
mov    $0x7,%edx
call   1040 <Q_stricmpn@plt>
lea    0x7(%rbx),%rbp
test   %eax,%eax
cmovne %rbx,%rbp
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1070 <Q_strncpyz@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
call   1070 <Q_strncpyz@plt>
mov    %r13,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11c9 <HTTPSplitURL+0x79>
movb   $0x0,(%rax)
mov    %r13,%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    11ed <HTTPSplitURL+0x9d>
lea    0xe26(%rip),%rdx
mov    %r13,%rdi
mov    %r14d,%esi
call   1060 <Q_strcat@plt>
mov    %r12,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     121d <HTTPSplitURL+0xcd>
cmp    %r12,%rax
je     121d <HTTPSplitURL+0xcd>
mov    %r12,%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <Q_bstrcpy@plt>
movw   $0x2f,(%r12)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"http://\00"
@.str.1 = [4 x i8] c":80\00"
define void @HTTPSplitURL(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
br label %12
12: ; preds = %17, %5
%13 = load i8*, i8** %6
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 32
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i8*, i8** %6
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %6
br label %12
20: ; preds = %12
%21 = load i8*, i8** %6
%22 = call i32 @Q_stricmpn(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%23 = icmp ne i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %20
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i64 7
store i8* %26, i8** %6
br label %27
27: ; preds = %24, %20
%28 = load i8*, i8** %7
%29 = load i8*, i8** %6
%30 = load i32, i32* %8
%31 = call i32 @Q_strncpyz(i8* %28, i8* %29, i32 %30)
%32 = load i8*, i8** %9
%33 = load i8*, i8** %6
%34 = load i32, i32* %10
%35 = call i32 @Q_strncpyz(i8* %32, i8* %33, i32 %34)
%36 = load i8*, i8** %7
%37 = call i8* @strchr(i8* %36, i8 signext 47)
store i8* %37, i8** %11
%38 = load i8*, i8** %11
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %43
40: ; preds = %27
%41 = load i8*, i8** %11
%42 = getelementptr inbounds i8, i8* %41, i64 0
store i8 0, i8* %42
br label %43
43: ; preds = %40, %27
%44 = load i8*, i8** %7
%45 = call i8* @strchr(i8* %44, i8 signext 58)
%46 = icmp eq i8* %45, null
br i1 %46, label %47, label %51
47: ; preds = %43
%48 = load i8*, i8** %7
%49 = load i32, i32* %8
%50 = call i32 @Q_strcat(i8* %48, i32 %49, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %51
51: ; preds = %47, %43
%52 = load i8*, i8** %9
%53 = call i8* @strchr(i8* %52, i8 signext 47)
store i8* %53, i8** %11
%54 = load i8*, i8** %11
%55 = icmp ne i8* %54, null
br i1 %55, label %56, label %64
56: ; preds = %51
%57 = load i8*, i8** %11
%58 = load i8*, i8** %9
%59 = icmp ne i8* %57, %58
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = load i8*, i8** %9
%62 = load i8*, i8** %11
%63 = call i32 @Q_bstrcpy(i8* %61, i8* %62)
br label %69
64: ; preds = %56, %51
%65 = load i8*, i8** %9
%66 = getelementptr inbounds i8, i8* %65, i64 0
store i8 47, i8* %66
%67 = load i8*, i8** %9
%68 = getelementptr inbounds i8, i8* %67, i64 1
store i8 0, i8* %68
br label %69
69: ; preds = %64, %60
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"http://\00"
@.str.1 = [4 x i8] c":80\00"
define void @HTTPSplitURL(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
br label %6
6: ; preds = %6, %5
%7 = phi i8* [ %0, %5 ], [ %10, %6 ]
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 32
%10 = getelementptr inbounds i8, i8* %7, i64 1
br i1 %9, label %6, label %11
11: ; preds = %6
%12 = tail call i32 @Q_stricmpn(i8* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i64 7, i64 0
%15 = getelementptr i8, i8* %7, i64 %14
%16 = tail call i32 @Q_strncpyz(i8* %1, i8* %15, i32 %2)
%17 = tail call i32 @Q_strncpyz(i8* %3, i8* %15, i32 %4)
%18 = tail call i8* @strchr(i8* dereferenceable(1) %1, i8 signext 47)
%19 = icmp eq i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %11
store i8 0, i8* %18
br label %21
21: ; preds = %20, %11
%22 = tail call i8* @strchr(i8* dereferenceable(1) %1, i8 signext 58)
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call i32 @Q_strcat(i8* %1, i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
%27 = tail call i8* @strchr(i8* dereferenceable(1) %3, i8 signext 47)
%28 = icmp eq i8* %27, null
%29 = icmp eq i8* %27, %3
%30 = or i1 %28, %29
br i1 %30, label %33, label %31
31: ; preds = %26
%32 = tail call i32 @Q_bstrcpy(i8* %3, i8* %27)
br label %35
33: ; preds = %26
store i8 47, i8* %3
%34 = getelementptr inbounds i8, i8* %3, i64 1
store i8 0, i8* %34
br label %35
35: ; preds = %33, %31
ret void
}