#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 */
typedef int /*<<< orphan*/ parse;

/* Variables and functions */
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 FTP_SplitURL(const char *url, char *address, int lenaddress, char *path,
                  int lenpath, char *loginname, int loginnamelen,
                  char *password, int passwdlen) {
  char *charloc;
  char parse[1024];
  path[0] = '\0';
  address[0] = '\0';
  password[0] = '\0';
  loginname[0] = '\0';
  while (*url == ' ')
    url++;
  if (!Q_stricmpn(url, "ftp://", 6)) {
    url += 6;
  }
  Q_strncpyz(parse, url, sizeof(parse));
  charloc = strchr(parse, '/');
  if (charloc) {
    charloc[0] = '\0';
    Q_strncpyz(path, &charloc[1], lenpath);
  }
  charloc = strchr(parse, '@');
  if (charloc) {
    charloc[0] = '\0';
    Q_strncpyz(address, &charloc[1], lenaddress);
  } else {
    Q_strncpyz(address, parse, lenaddress);
  }
  if (strchr(address, ':') == NULL) {
    Q_strcat(address, lenaddress, ":21");
  }
  if (charloc == NULL) {
    return;
  }
  charloc = strchr(parse, ':');
  if (charloc) {
    charloc[0] = '\0';
    Q_strncpyz(password, &charloc[1], passwdlen);
  }
  Q_strncpyz(loginname, parse, loginnamelen);
}


x86 assembly (clang, -O0):
<FTP_SplitURL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11a9 <FTP_SplitURL+0x69>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1188 <FTP_SplitURL+0x48>
mov    -0x8(%rbp),%rdi
lea    0xe4c(%rip),%rsi
mov    $0x6,%edx
call   1030 <Q_stricmpn@plt>
cmp    $0x0,%eax
jne    11d3 <FTP_SplitURL+0x93>
mov    -0x8(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x8(%rbp)
lea    -0x440(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x400,%edx
call   1060 <Q_strncpyz@plt>
lea    -0x440(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1223 <FTP_SplitURL+0xe3>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
add    $0x1,%rsi
mov    -0x24(%rbp),%edx
call   1060 <Q_strncpyz@plt>
lea    -0x440(%rbp),%rdi
mov    $0x40,%esi
call   1040 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1263 <FTP_SplitURL+0x123>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
add    $0x1,%rsi
mov    -0x14(%rbp),%edx
call   1060 <Q_strncpyz@plt>
jmp    1276 <FTP_SplitURL+0x136>
mov    -0x10(%rbp),%rdi
lea    -0x440(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <Q_strncpyz@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    12a1 <FTP_SplitURL+0x161>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xd6b(%rip),%rdx
call   1050 <Q_strcat@plt>
cmpq   $0x0,-0x38(%rbp)
jne    12b1 <FTP_SplitURL+0x171>
jmp    12ff <FTP_SplitURL+0x1bf>
lea    -0x440(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     12ec <FTP_SplitURL+0x1ac>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    0x18(%rbp),%rdi
mov    -0x38(%rbp),%rsi
add    $0x1,%rsi
mov    0x20(%rbp),%edx
call   1060 <Q_strncpyz@plt>
mov    -0x30(%rbp),%rdi
lea    -0x440(%rbp),%rsi
mov    0x10(%rbp),%edx
call   1060 <Q_strncpyz@plt>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FTP_SplitURL>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %edx,%r13d
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    0x458(%rsp),%rax
movb   $0x0,(%rcx)
movb   $0x0,(%rsi)
movb   $0x0,(%rax)
mov    %r9,0x8(%rsp)
movb   $0x0,(%r9)
add    $0xffffffffffffffff,%rbp
xchg   %ax,%ax
cmpb   $0x20,0x1(%rbp)
lea    0x1(%rbp),%rbp
je     1180 <FTP_SplitURL+0x40>
lea    0xe6f(%rip),%rsi
mov    %rbp,%rdi
mov    $0x6,%edx
call   1030 <Q_stricmpn@plt>
lea    0x6(%rbp),%rsi
test   %eax,%eax
cmovne %rbp,%rsi
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x400,%edx
call   1060 <Q_strncpyz@plt>
mov    %r12,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11e1 <FTP_SplitURL+0xa1>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %r15,%rdi
mov    %rax,%rsi
mov    %r14d,%edx
call   1060 <Q_strncpyz@plt>
mov    %r12,%rdi
mov    $0x40,%esi
call   1040 <strchr@plt>
mov    %rax,%rbp
test   %rax,%rax
je     11fe <FTP_SplitURL+0xbe>
movb   $0x0,0x0(%rbp)
lea    0x1(%rbp),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
call   1060 <Q_strncpyz@plt>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1225 <FTP_SplitURL+0xe5>
test   %rbp,%rbp
jne    123c <FTP_SplitURL+0xfc>
jmp    1284 <FTP_SplitURL+0x144>
lea    0xddb(%rip),%rdx
mov    %rbx,%rdi
mov    %r13d,%esi
call   1050 <Q_strcat@plt>
test   %rbp,%rbp
je     1284 <FTP_SplitURL+0x144>
lea    0x10(%rsp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     126e <FTP_SplitURL+0x12e>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    0x458(%rsp),%rdi
mov    %rax,%rsi
mov    0x460(%rsp),%edx
call   1060 <Q_strncpyz@plt>
lea    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdi
mov    0x450(%rsp),%edx
call   1060 <Q_strncpyz@plt>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"ftp://\00"
@.str.1 = [4 x i8] c":21\00"
define void @FTP_SplitURL(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4, i8* %5, i32 %6, i8* %7, i32 %8) {
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i32
%19 = alloca i8*
%20 = alloca [1024 x i8]
store i8* %0, i8** %10
store i8* %1, i8** %11
store i32 %2, i32* %12
store i8* %3, i8** %13
store i32 %4, i32* %14
store i8* %5, i8** %15
store i32 %6, i32* %16
store i8* %7, i8** %17
store i32 %8, i32* %18
%21 = load i8*, i8** %13
%22 = getelementptr inbounds i8, i8* %21, i64 0
store i8 0, i8* %22
%23 = load i8*, i8** %11
%24 = getelementptr inbounds i8, i8* %23, i64 0
store i8 0, i8* %24
%25 = load i8*, i8** %17
%26 = getelementptr inbounds i8, i8* %25, i64 0
store i8 0, i8* %26
%27 = load i8*, i8** %15
%28 = getelementptr inbounds i8, i8* %27, i64 0
store i8 0, i8* %28
br label %29
29: ; preds = %34, %9
%30 = load i8*, i8** %10
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 32
br i1 %33, label %34, label %37
34: ; preds = %29
%35 = load i8*, i8** %10
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %10
br label %29
37: ; preds = %29
%38 = load i8*, i8** %10
%39 = call i32 @Q_stricmpn(i8* %38, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%40 = icmp ne i32 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %37
%42 = load i8*, i8** %10
%43 = getelementptr inbounds i8, i8* %42, i64 6
store i8* %43, i8** %10
br label %44
44: ; preds = %41, %37
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %20, i64 0, i64 0
%46 = load i8*, i8** %10
%47 = call i32 @Q_strncpyz(i8* %45, i8* %46, i32 1024)
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %20, i64 0, i64 0
%49 = call i8* @strchr(i8* %48, i8 signext 47)
store i8* %49, i8** %19
%50 = load i8*, i8** %19
%51 = icmp ne i8* %50, null
br i1 %51, label %52, label %60
52: ; preds = %44
%53 = load i8*, i8** %19
%54 = getelementptr inbounds i8, i8* %53, i64 0
store i8 0, i8* %54
%55 = load i8*, i8** %13
%56 = load i8*, i8** %19
%57 = getelementptr inbounds i8, i8* %56, i64 1
%58 = load i32, i32* %14
%59 = call i32 @Q_strncpyz(i8* %55, i8* %57, i32 %58)
br label %60
60: ; preds = %52, %44
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %20, i64 0, i64 0
%62 = call i8* @strchr(i8* %61, i8 signext 64)
store i8* %62, i8** %19
%63 = load i8*, i8** %19
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %73
65: ; preds = %60
%66 = load i8*, i8** %19
%67 = getelementptr inbounds i8, i8* %66, i64 0
store i8 0, i8* %67
%68 = load i8*, i8** %11
%69 = load i8*, i8** %19
%70 = getelementptr inbounds i8, i8* %69, i64 1
%71 = load i32, i32* %12
%72 = call i32 @Q_strncpyz(i8* %68, i8* %70, i32 %71)
br label %78
73: ; preds = %60
%74 = load i8*, i8** %11
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %20, i64 0, i64 0
%76 = load i32, i32* %12
%77 = call i32 @Q_strncpyz(i8* %74, i8* %75, i32 %76)
br label %78
78: ; preds = %73, %65
%79 = load i8*, i8** %11
%80 = call i8* @strchr(i8* %79, i8 signext 58)
%81 = icmp eq i8* %80, null
br i1 %81, label %82, label %86
82: ; preds = %78
%83 = load i8*, i8** %11
%84 = load i32, i32* %12
%85 = call i32 @Q_strcat(i8* %83, i32 %84, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %86
86: ; preds = %82, %78
%87 = load i8*, i8** %19
%88 = icmp eq i8* %87, null
br i1 %88, label %89, label %90
89: ; preds = %86
br label %108
90: ; preds = %86
%91 = getelementptr inbounds [1024 x i8], [1024 x i8]* %20, i64 0, i64 0
%92 = call i8* @strchr(i8* %91, i8 signext 58)
store i8* %92, i8** %19
%93 = load i8*, i8** %19
%94 = icmp ne i8* %93, null
br i1 %94, label %95, label %103
95: ; preds = %90
%96 = load i8*, i8** %19
%97 = getelementptr inbounds i8, i8* %96, i64 0
store i8 0, i8* %97
%98 = load i8*, i8** %17
%99 = load i8*, i8** %19
%100 = getelementptr inbounds i8, i8* %99, i64 1
%101 = load i32, i32* %18
%102 = call i32 @Q_strncpyz(i8* %98, i8* %100, i32 %101)
br label %103
103: ; preds = %95, %90
%104 = load i8*, i8** %15
%105 = getelementptr inbounds [1024 x i8], [1024 x i8]* %20, i64 0, i64 0
%106 = load i32, i32* %16
%107 = call i32 @Q_strncpyz(i8* %104, i8* %105, i32 %106)
br label %108
108: ; preds = %103, %89
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"ftp://\00"
@.str.1 = [4 x i8] c":21\00"
define void @FTP_SplitURL(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4, i8* %5, i32 %6, i8* %7, i32 %8) {
%10 = alloca [1024 x i8]
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
store i8 0, i8* %3
store i8 0, i8* %1
store i8 0, i8* %7
store i8 0, i8* %5
br label %12
12: ; preds = %12, %9
%13 = phi i8* [ %0, %9 ], [ %16, %12 ]
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 32
%16 = getelementptr inbounds i8, i8* %13, i64 1
br i1 %15, label %12, label %17
17: ; preds = %12
%18 = tail call i32 @Q_stricmpn(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i64 6, i64 0
%21 = getelementptr i8, i8* %13, i64 %20
%22 = call i32 @Q_strncpyz(i8* %11, i8* %21, i32 1024)
%23 = call i8* @strchr(i8* %11, i8 signext 47)
%24 = icmp eq i8* %23, null
br i1 %24, label %28, label %25
25: ; preds = %17
store i8 0, i8* %23
%26 = getelementptr inbounds i8, i8* %23, i64 1
%27 = call i32 @Q_strncpyz(i8* %3, i8* %26, i32 %4)
br label %28
28: ; preds = %25, %17
%29 = call i8* @strchr(i8* %11, i8 signext 64)
%30 = icmp eq i8* %29, null
br i1 %30, label %33, label %31
31: ; preds = %28
store i8 0, i8* %29
%32 = getelementptr inbounds i8, i8* %29, i64 1
br label %33
33: ; preds = %28, %31
%34 = phi i8* [ %32, %31 ], [ %11, %28 ]
%35 = call i32 @Q_strncpyz(i8* %1, i8* %34, i32 %2)
%36 = call i8* @strchr(i8* %1, i8 signext 58)
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = 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 %40
40: ; preds = %38, %33
br i1 %30, label %49, label %41
41: ; preds = %40
%42 = call i8* @strchr(i8* %11, i8 signext 58)
%43 = icmp eq i8* %42, null
br i1 %43, label %47, label %44
44: ; preds = %41
store i8 0, i8* %42
%45 = getelementptr inbounds i8, i8* %42, i64 1
%46 = call i32 @Q_strncpyz(i8* %7, i8* %45, i32 %8)
br label %47
47: ; preds = %44, %41
%48 = call i32 @Q_strncpyz(i8* %5, i8* %11, i32 %6)
br label %49
49: ; preds = %40, %47
ret void
}