#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*/ exit(int);
int /*<<< orphan*/ printf(char *);
int sscanf(char *, char *, char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
void check_URL(char *url, char *user, char *password, char *host, char *path) {
  if (sscanf(url, "ftp://%[^:]:%[^@]@%[^/]/%[^\n]", user, password, host,
             path) == 4) {
    return;
  } else if (sscanf(url, "ftp://%[^@]@%[^/]/%[^\n]", user, host, path) == 3) {
    strcpy(password, "empty");
    return;
  } else if (sscanf(url, "ftp://%[^:@/]/%[^\n]", host, path) == 2) {
    strcpy(password, "empty");
    strcpy(user, "anonymous");
    return;
  } else {
    printf("Error! URL should be in the following format: "
           "ftp://<user>:<password>@<host>/<url-path>\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<check_URL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x4,%eax
jne    118c <check_URL+0x4c>
jmp    1226 <check_URL+0xe6>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x3,%eax
jne    11c8 <check_URL+0x88>
mov    -0x18(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1226 <check_URL+0xe6>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x2,%eax
jne    1210 <check_URL+0xd0>
mov    -0x18(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1226 <check_URL+0xe6>
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_URL>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%r12
mov    %rcx,%r13
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xea1(%rip),%rsi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %r13,%r8
mov    %r12,%r9
xor    %eax,%eax
call   1050 <sscanf@plt>
cmp    $0x4,%eax
jne    1181 <check_URL+0x41>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r13,%rcx
mov    %r12,%r8
xor    %eax,%eax
call   1050 <sscanf@plt>
cmp    $0x3,%eax
jne    11ac <check_URL+0x6c>
lea    0xe8f(%rip),%rsi
mov    %r14,%rdi
jmp    11e1 <check_URL+0xa1>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
mov    %r13,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1050 <sscanf@plt>
cmp    $0x2,%eax
jne    11ef <check_URL+0xaf>
lea    0xe67(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xe72(%rip),%rsi
mov    %r15,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <strcpy@plt>
lea    0xe64(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"ftp://%[^:]:%[^@]@%[^/]/%[^\0A]\00"
@.str.1 = [24 x i8] c"ftp://%[^@]@%[^/]/%[^\0A]\00"
@.str.2 = [6 x i8] c"empty\00"
@.str.3 = [20 x i8] c"ftp://%[^:@/]/%[^\0A]\00"
@.str.4 = [10 x i8] c"anonymous\00"
@.str.5 = [89 x i8] c"Error! URL should be in the following format: ftp://<user>:<password>@<host>/<url-path>\0A\00"
define void @check_URL(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%11 = load i8*, i8** %6
%12 = load i8*, i8** %7
%13 = load i8*, i8** %8
%14 = load i8*, i8** %9
%15 = load i8*, i8** %10
%16 = call i32 (i8*, i8*, i8*, i8*, ...) @sscanf(i8* %11, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %13, i8* %14, i8* %15)
%17 = icmp eq i32 %16, 4
br i1 %17, label %18, label %19
18: ; preds = %5
br label %43
19: ; preds = %5
%20 = load i8*, i8** %6
%21 = load i8*, i8** %7
%22 = load i8*, i8** %9
%23 = load i8*, i8** %10
%24 = call i32 (i8*, i8*, i8*, i8*, ...) @sscanf(i8* %20, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %22, i8* %23)
%25 = icmp eq i32 %24, 3
br i1 %25, label %26, label %29
26: ; preds = %19
%27 = load i8*, i8** %8
%28 = call i32 @strcpy(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %43
29: ; preds = %19
%30 = load i8*, i8** %6
%31 = load i8*, i8** %9
%32 = load i8*, i8** %10
%33 = call i32 (i8*, i8*, i8*, i8*, ...) @sscanf(i8* %30, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %31, i8* %32)
%34 = icmp eq i32 %33, 2
br i1 %34, label %35, label %40
35: ; preds = %29
%36 = load i8*, i8** %8
%37 = call i32 @strcpy(i8* %36, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%38 = load i8*, i8** %7
%39 = call i32 @strcpy(i8* %38, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %43
40: ; preds = %29
%41 = call i32 @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.5, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %35, %26, %18
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"ftp://%[^:]:%[^@]@%[^/]/%[^\0A]\00"
@.str.1 = [24 x i8] c"ftp://%[^@]@%[^/]/%[^\0A]\00"
@.str.2 = [6 x i8] c"empty\00"
@.str.3 = [20 x i8] c"ftp://%[^:@/]/%[^\0A]\00"
@.str.4 = [10 x i8] c"anonymous\00"
@str = [88 x i8] c"Error! URL should be in the following format: ftp://<user>:<password>@<host>/<url-path>\00"
define void @check_URL(i8* nocapture %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2, i8* %3, i8* %4)
%7 = icmp eq i32 %6, 4
br i1 %7, label %22, label %8
8: ; preds = %5
%9 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %3, i8* %4)
%10 = icmp eq i32 %9, 3
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %22
13: ; preds = %8
%14 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %3, i8* %4)
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %22
19: ; preds = %13
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([88 x i8], [88 x i8]* @str, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %5, %16, %11
ret void
}