#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*/ atoi(char *);
int /*<<< orphan*/ convertUser(int /*<<< orphan*/);
int /*<<< orphan*/ encryptString(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ printUsage(int);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  if (argc < 2 || argv[1][0] != '-') {
    printUsage(0);
  }
  switch (argv[1][1]) {
  case 's':
    if (argc != 3) {
      printf("Invalid number of arguments for -s\n\n");
      printUsage(10);
    }
    encryptString(argv[2]);
    break;
  case 'u':
    if (argc != 3) {
      printf("Invalid number of arguments for -u\n\n");
      printUsage(10);
    }
    if (!isdigit(argv[2][0])) {
      printf("Invalid userid\n");
      exit(10);
    }
    convertUser(atoi(argv[2]));
    break;
  case 'a':
    if (argc != 2) {
      printf("No argument allowed for -a\n\n");
      printUsage(10);
    }
    printf("-a option is not implemented yet..\n");
    break;
  default:
    printf("Invalid option.\n\n");
    printUsage(10);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     11a4 <main+0x34>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     11ab <main+0x3b>
xor    %edi,%edi
call   1070 <printUsage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0x61,%eax
je     1284 <main+0x114>
jmp    11c8 <main+0x58>
mov    -0x14(%rbp),%eax
sub    $0x73,%eax
je     11ea <main+0x7a>
jmp    11d9 <main+0x69>
mov    -0x14(%rbp),%eax
sub    $0x75,%eax
je     121c <main+0xac>
jmp    12b5 <main+0x145>
cmpl   $0x3,-0x8(%rbp)
je     120a <main+0x9a>
lea    0xe05(%rip),%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
call   1070 <printUsage@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <encryptString@plt>
jmp    12cb <main+0x15b>
cmpl   $0x3,-0x8(%rbp)
je     123c <main+0xcc>
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
call   1070 <printUsage@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    126b <main+0xfb>
lea    0xdee(%rip),%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1060 <convertUser@plt>
jmp    12cb <main+0x15b>
cmpl   $0x2,-0x8(%rbp)
je     12a4 <main+0x134>
lea    0xdc5(%rip),%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
call   1070 <printUsage@plt>
lea    0xdcc(%rip),%rdi
call   1040 <printf@plt>
jmp    12cb <main+0x15b>
lea    0xddf(%rip),%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
call   1070 <printUsage@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x2,%edi
jl     1186 <main+0x16>
mov    0x8(%rbx),%rax
cmpb   $0x2d,(%rax)
je     1191 <main+0x21>
xor    %edi,%edi
call   1070 <printUsage@plt>
mov    0x8(%rbx),%rax
movsbl 0x1(%rax),%eax
cmp    $0x61,%eax
je     11ce <main+0x5e>
cmp    $0x75,%eax
je     11f7 <main+0x87>
cmp    $0x73,%eax
jne    1234 <main+0xc4>
cmp    $0x3,%ebp
je     11c3 <main+0x53>
lea    0xebe(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1070 <printUsage@plt>
mov    0x10(%rbx),%rdi
call   1050 <encryptString@plt>
jmp    124a <main+0xda>
cmp    $0x2,%ebp
je     11e9 <main+0x79>
lea    0xe49(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1070 <printUsage@plt>
lea    0xe10(%rip),%rdi
call   1040 <puts@plt>
jmp    124a <main+0xda>
cmp    $0x3,%ebp
je     1212 <main+0xa2>
lea    0xe4b(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1070 <printUsage@plt>
mov    0x10(%rbx),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     1253 <main+0xe3>
mov    0x10(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1060 <convertUser@plt>
jmp    124a <main+0xda>
lea    0xe5b(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1070 <printUsage@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xde5(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"Invalid number of arguments for -s\0A\0A\00"
@.str.1 = [37 x i8] c"Invalid number of arguments for -u\0A\0A\00"
@.str.2 = [16 x i8] c"Invalid userid\0A\00"
@.str.3 = [29 x i8] c"No argument allowed for -a\0A\0A\00"
@.str.4 = [36 x i8] c"-a option is not implemented yet..\0A\00"
@.str.5 = [18 x i8] c"Invalid option.\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %16, label %8
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 45
br i1 %15, label %16, label %18
16: ; preds = %8, %2
%17 = call i32 @printUsage(i32 0)
br label %18
18: ; preds = %16, %8
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
switch i32 %24, label %67 [
i32 115, label %25
i32 117, label %36
i32 97, label %59
]
25: ; preds = %18
%26 = load i32, i32* %4
%27 = icmp ne i32 %26, 3
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @printUsage(i32 10)
br label %31
31: ; preds = %28, %25
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i32 @encryptString(i8* %34)
br label %70
36: ; preds = %18
%37 = load i32, i32* %4
%38 = icmp ne i32 %37, 3
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%41 = call i32 @printUsage(i32 10)
br label %42
42: ; preds = %39, %36
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = getelementptr inbounds i8, i8* %45, i64 0
%47 = load i8, i8* %46
%48 = call i32 @isdigit(i8 signext %47)
%49 = icmp ne i32 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %42
%51 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%52 = call i32 @exit(i32 10)
unreachable
53: ; preds = %42
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 2
%56 = load i8*, i8** %55
%57 = call i32 @atoi(i8* %56)
%58 = call i32 @convertUser(i32 %57)
br label %70
59: ; preds = %18
%60 = load i32, i32* %4
%61 = icmp ne i32 %60, 2
br i1 %61, label %62, label %65
62: ; preds = %59
%63 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%64 = call i32 @printUsage(i32 10)
br label %65
65: ; preds = %62, %59
%66 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
br label %70
67: ; preds = %18
%68 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%69 = call i32 @printUsage(i32 10)
br label %70
70: ; preds = %67, %65, %53, %31
ret i32 0
}

LLVM IR (-O2):
@str = [35 x i8] c"-a option is not implemented yet..\00"
@str.6 = [28 x i8] c"No argument allowed for -a\0A\00"
@str.7 = [15 x i8] c"Invalid userid\00"
@str.8 = [36 x i8] c"Invalid number of arguments for -u\0A\00"
@str.9 = [36 x i8] c"Invalid number of arguments for -s\0A\00"
@str.10 = [17 x i8] c"Invalid option.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 45
br i1 %8, label %13, label %9
9: ; preds = %4, %2
%10 = tail call i32 @printUsage(i32 0)
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
br label %13
13: ; preds = %9, %4
%14 = phi i8* [ %12, %9 ], [ %6, %4 ]
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %52 [
i32 115, label %18
i32 117, label %27
i32 97, label %45
]
18: ; preds = %13
%19 = icmp eq i32 %0, 3
br i1 %19, label %23, label %20
20: ; preds = %18
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.9, i64 0, i64 0))
%22 = tail call i32 @printUsage(i32 10)
br label %23
23: ; preds = %20, %18
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32 @encryptString(i8* %25)
br label %55
27: ; preds = %13
%28 = icmp eq i32 %0, 3
br i1 %28, label %32, label %29
29: ; preds = %27
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.8, i64 0, i64 0))
%31 = tail call i32 @printUsage(i32 10)
br label %32
32: ; preds = %29, %27
%33 = getelementptr inbounds i8*, i8** %1, i64 2
%34 = load i8*, i8** %33
%35 = load i8, i8* %34
%36 = tail call i32 @isdigit(i8 signext %35)
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %32
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.7, i64 0, i64 0))
%40 = tail call i32 @exit(i32 10)
unreachable
41: ; preds = %32
%42 = load i8*, i8** %33
%43 = tail call i32 @atoi(i8* %42)
%44 = tail call i32 @convertUser(i32 %43)
br label %55
45: ; preds = %13
%46 = icmp eq i32 %0, 2
br i1 %46, label %50, label %47
47: ; preds = %45
%48 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.6, i64 0, i64 0))
%49 = tail call i32 @printUsage(i32 10)
br label %50
50: ; preds = %47, %45
%51 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %55
52: ; preds = %13
%53 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.10, i64 0, i64 0))
%54 = tail call i32 @printUsage(i32 10)
br label %55
55: ; preds = %52, %50, %41, %23
ret i32 0
}