#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_FAILURE;
int /*<<< orphan*/ bruteForceAttack(char *);
int /*<<< orphan*/ dictionaryAttack(char *, char *);
int /*<<< orphan*/ encryptDecrypt(char *, char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  if (argc < 3 || argc > 4) {
    fprintf(stderr,
            "Error: The program must be called with 2 or 3 arguments\n");
    exit(EXIT_FAILURE);
  }
  if (strcmp(argv[1], "-e") && strcmp(argv[1], "-d") && strcmp(argv[1], "-a")) {
    fprintf(stderr, "Error: %s is not a valid option\n", argv[1]);
    exit(EXIT_FAILURE);
  }
  if ((!strcmp(argv[1], "-d") || !strcmp(argv[1], "-e")) && argc != 4) {
    fprintf(stderr,
            "Error: With %s the program must be called with 3 arguments",
            argv[1]);
    exit(EXIT_FAILURE);
  }
  if (!strcmp(argv[1], "-d") || !strcmp(argv[1], "-e"))
    encryptDecrypt(argv[1], argv[2], argv[3]);
  else {
    if (argc == 3)
      bruteForceAttack(argv[2]);
    else
      dictionaryAttack(argv[2], argv[3]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     118a <main+0x2a>
cmpl   $0x4,-0x8(%rbp)
jle    11af <main+0x4f>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1236 <main+0xd6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe60(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1236 <main+0xd6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe45(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1236 <main+0xd6>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe21(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf7(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1272 <main+0x112>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd6(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12a9 <main+0x149>
cmpl   $0x4,-0x8(%rbp)
je     12a9 <main+0x149>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdcf(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd84(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     12e5 <main+0x185>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd63(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1307 <main+0x1a7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
call   1040 <encryptDecrypt@plt>
jmp    133d <main+0x1dd>
cmpl   $0x3,-0x8(%rbp)
jne    1323 <main+0x1c3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <bruteForceAttack@plt>
jmp    1338 <main+0x1d8>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1030 <dictionaryAttack@plt>
jmp    133d <main+0x1dd>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
lea    -0x5(%r14),%eax
cmp    $0xfffffffd,%eax
jbe    126a <main+0x10a>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xeb7(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ba <main+0x5a>
mov    0x8(%rbx),%rdi
lea    0xea5(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ba <main+0x5a>
mov    0x8(%rbx),%rdi
lea    0xe93(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1283 <main+0x123>
mov    0x8(%rbx),%rdi
lea    0xe77(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1203 <main+0xa3>
mov    0x8(%rbx),%rdi
lea    0xe5f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x4,%r14d
je     1209 <main+0xa9>
test   %rax,%rax
jne    1209 <main+0xa9>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe65(%rip),%rsi
jmp    1297 <main+0x137>
cmp    $0x4,%r14d
jne    11ea <main+0x8a>
mov    0x8(%rbx),%rdi
lea    0xe28(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1244 <main+0xe4>
mov    0x8(%rbx),%rdi
lea    0xe10(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1244 <main+0xe4>
mov    0x10(%rbx),%rdi
cmp    $0x3,%r14d
jne    1257 <main+0xf7>
call   1070 <bruteForceAttack@plt>
jmp    1260 <main+0x100>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
mov    0x18(%rbx),%rdx
call   1040 <encryptDecrypt@plt>
jmp    1260 <main+0x100>
mov    0x18(%rbx),%rsi
call   1030 <dictionaryAttack@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
lea    0xd86(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    129e <main+0x13e>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xdab(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2d33(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [57 x i8] c"Error: The program must be called with 2 or 3 arguments\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"-e\00"
@.str.2 = [3 x i8] c"-d\00"
@.str.3 = [3 x i8] c"-a\00"
@.str.4 = [33 x i8] c"Error: %s is not a valid option\0A\00"
@.str.5 = [59 x i8] c"Error: With %s the program must be called with 3 arguments\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, 3
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 4
br i1 %10, label %11, label %16
11: ; preds = %8, %2
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %8
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %42
22: ; preds = %16
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %42
28: ; preds = %22
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %42
34: ; preds = %28
%35 = load i32, i32* @stderr
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* %38)
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %28, %22, %16
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %54
48: ; preds = %42
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%53 = icmp ne i64 %52, 0
br i1 %53, label %65, label %54
54: ; preds = %48, %42
%55 = load i32, i32* %4
%56 = icmp ne i32 %55, 4
br i1 %56, label %57, label %65
57: ; preds = %54
%58 = load i32, i32* @stderr
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 1
%61 = load i8*, i8** %60
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %61)
%63 = load i32, i32* @EXIT_FAILURE
%64 = call i32 @exit(i32 %63)
unreachable
65: ; preds = %54, %48
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 1
%68 = load i8*, i8** %67
%69 = call i64 @strcmp(i8* %68, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %77
71: ; preds = %65
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 1
%74 = load i8*, i8** %73
%75 = call i64 @strcmp(i8* %74, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%76 = icmp ne i64 %75, 0
br i1 %76, label %88, label %77
77: ; preds = %71, %65
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 1
%80 = load i8*, i8** %79
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 2
%83 = load i8*, i8** %82
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i64 3
%86 = load i8*, i8** %85
%87 = call i32 @encryptDecrypt(i8* %80, i8* %83, i8* %86)
br label %105
88: ; preds = %71
%89 = load i32, i32* %4
%90 = icmp eq i32 %89, 3
br i1 %90, label %91, label %96
91: ; preds = %88
%92 = load i8**, i8*** %5
%93 = getelementptr inbounds i8*, i8** %92, i64 2
%94 = load i8*, i8** %93
%95 = call i32 @bruteForceAttack(i8* %94)
br label %104
96: ; preds = %88
%97 = load i8**, i8*** %5
%98 = getelementptr inbounds i8*, i8** %97, i64 2
%99 = load i8*, i8** %98
%100 = load i8**, i8*** %5
%101 = getelementptr inbounds i8*, i8** %100, i64 3
%102 = load i8*, i8** %101
%103 = call i32 @dictionaryAttack(i8* %99, i8* %102)
br label %104
104: ; preds = %96, %91
br label %105
105: ; preds = %104, %77
%106 = load i32, i32* %3
ret i32 %106
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [57 x i8] c"Error: The program must be called with 2 or 3 arguments\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"-e\00"
@.str.2 = [3 x i8] c"-d\00"
@.str.3 = [3 x i8] c"-a\00"
@.str.4 = [33 x i8] c"Error: %s is not a valid option\0A\00"
@.str.5 = [59 x i8] c"Error: With %s the program must be called with 3 arguments\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add i32 %0, -5
%4 = icmp ult i32 %3, -2
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %29, label %15
15: ; preds = %10
%16 = load i8*, i8** %11
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %29, label %19
19: ; preds = %15
%20 = load i8*, i8** %11
%21 = tail call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %19
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %11
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = tail call i32 @exit(i32 %27)
unreachable
29: ; preds = %19, %15, %10
%30 = load i8*, i8** %11
%31 = tail call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %39, label %33
33: ; preds = %29
%34 = load i8*, i8** %11
%35 = tail call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
%37 = icmp ne i32 %0, 4
%38 = and i1 %37, %36
br i1 %38, label %41, label %47
39: ; preds = %29
%40 = icmp eq i32 %0, 4
br i1 %40, label %47, label %41
41: ; preds = %33, %39
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %11
%44 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0), i8* %43)
%45 = load i32, i32* @EXIT_FAILURE
%46 = tail call i32 @exit(i32 %45)
unreachable
47: ; preds = %39, %33
%48 = load i8*, i8** %11
%49 = tail call i64 @strcmp(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %55, label %51
51: ; preds = %47
%52 = load i8*, i8** %11
%53 = tail call i64 @strcmp(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %62
55: ; preds = %51, %47
%56 = load i8*, i8** %11
%57 = getelementptr inbounds i8*, i8** %1, i64 2
%58 = load i8*, i8** %57
%59 = getelementptr inbounds i8*, i8** %1, i64 3
%60 = load i8*, i8** %59
%61 = tail call i32 @encryptDecrypt(i8* %56, i8* %58, i8* %60)
br label %72
62: ; preds = %51
%63 = icmp eq i32 %0, 3
%64 = getelementptr inbounds i8*, i8** %1, i64 2
%65 = load i8*, i8** %64
br i1 %63, label %66, label %68
66: ; preds = %62
%67 = tail call i32 @bruteForceAttack(i8* %65)
br label %72
68: ; preds = %62
%69 = getelementptr inbounds i8*, i8** %1, i64 3
%70 = load i8*, i8** %69
%71 = tail call i32 @dictionaryAttack(i8* %65, i8* %70)
br label %72
72: ; preds = %66, %68, %55
ret i32 0
}