#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*/ decryptCBC(char *, char *);
int /*<<< orphan*/ decryptECB(char *, char *);
int /*<<< orphan*/ encryptCBC(char *, char *);
int /*<<< orphan*/ encryptECB(char *, char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  if (argv[1] == NULL || argv[2] == NULL || argv[3] == NULL ||
      argv[4] == NULL) {
    printf("Upss, something is wrong, check your parameters!\n");
    printf("Correct format: encrypt/decrypt ecb/cbc inFileName outFileName\n");
    return 1;
  }
  int mode;
  if (strcmp(argv[1], "encrypt") == 0) {
    if (strcmp(argv[2], "ecb") == 0) {
      mode = 1;
    } else if (strcmp(argv[2], "cbc") == 0) {
      mode = 2;
    }
  } else if (strcmp(argv[1], "decrypt") == 0) {
    if (strcmp(argv[2], "ecb") == 0) {
      mode = 3;
    } else if (strcmp(argv[2], "cbc") == 0) {
      mode = 4;
    }
  }
  char *inFile = argv[3];
  char *outFile = argv[4];
  if (mode == 1) {
    printf("Start encrypting in ECB mode...\n");
    encryptECB(inFile, outFile);
    return 0;
  }
  if (mode == 2) {
    printf("Start encrypting in CBC mode...\n");
    encryptCBC(inFile, outFile);
    return 0;
  }
  if (mode == 3) {
    printf("Start decrypting in ECB mode...\n");
    decryptECB(inFile, outFile);
    return 0;
  }
  if (mode == 4) {
    printf("Start decrypting in CBC mode...\n");
    decryptCBC(inFile, outFile);
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     11b2 <main+0x52>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     11b2 <main+0x52>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     11b2 <main+0x52>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x20(%rax)
jne    11d6 <main+0x76>
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a4 <main+0x244>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    124d <main+0xed>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe77(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    121e <main+0xbe>
movl   $0x1,-0x14(%rbp)
jmp    1248 <main+0xe8>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe51(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1243 <main+0xe3>
movl   $0x2,-0x14(%rbp)
jmp    1248 <main+0xe8>
jmp    12c9 <main+0x169>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe26(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12c4 <main+0x164>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe00(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1295 <main+0x135>
movl   $0x3,-0x14(%rbp)
jmp    12bf <main+0x15f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdda(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12ba <main+0x15a>
movl   $0x4,-0x14(%rbp)
jmp    12bf <main+0x15f>
jmp    12c4 <main+0x164>
jmp    12c9 <main+0x169>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1310 <main+0x1b0>
lea    0xd98(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <encryptECB@plt>
movl   $0x0,-0x4(%rbp)
jmp    13a4 <main+0x244>
cmpl   $0x2,-0x14(%rbp)
jne    133f <main+0x1df>
lea    0xd8a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <encryptCBC@plt>
movl   $0x0,-0x4(%rbp)
jmp    13a4 <main+0x244>
cmpl   $0x3,-0x14(%rbp)
jne    136e <main+0x20e>
lea    0xd7c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <decryptECB@plt>
movl   $0x0,-0x4(%rbp)
jmp    13a4 <main+0x244>
cmpl   $0x4,-0x14(%rbp)
jne    139d <main+0x23d>
lea    0xd6e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <decryptCBC@plt>
movl   $0x0,-0x4(%rbp)
jmp    13a4 <main+0x244>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     120c <main+0xac>
mov    %rsi,%rbx
cmpq   $0x0,0x10(%rsi)
je     120c <main+0xac>
cmpq   $0x0,0x18(%rbx)
je     120c <main+0xac>
cmpq   $0x0,0x20(%rbx)
je     120c <main+0xac>
lea    0xe68(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1231 <main+0xd1>
mov    0x8(%rbx),%rdi
lea    0xe5f(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1277 <main+0x117>
mov    0x10(%rbx),%rdi
lea    0xe3e(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     129a <main+0x13a>
mov    0x10(%rbx),%rdi
lea    0xe29(%rip),%rsi
call   1060 <strcmp@plt>
mov    0x18(%rbx),%r14
mov    0x20(%rbx),%rbx
lea    0xe21(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <decryptCBC@plt>
jmp    1296 <main+0x136>
lea    0xe85(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x10(%rbx),%rdi
lea    0xdcc(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1277 <main+0x117>
mov    0x10(%rbx),%rdi
lea    0xdbb(%rip),%rsi
call   1060 <strcmp@plt>
mov    0x18(%rbx),%r14
mov    0x20(%rbx),%rbx
lea    0xdf3(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <encryptCBC@plt>
jmp    1296 <main+0x136>
mov    0x18(%rbx),%r14
mov    0x20(%rbx),%rbx
lea    0xdf2(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <encryptECB@plt>
xor    %eax,%eax
jmp    1229 <main+0xc9>
mov    0x18(%rbx),%r14
mov    0x20(%rbx),%rbx
lea    0xd8f(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <decryptECB@plt>
jmp    1296 <main+0x136>

LLVM IR (-O0):
@.str = [50 x i8] c"Upss, something is wrong, check your parameters!\0A\00"
@.str.1 = [64 x i8] c"Correct format: encrypt/decrypt ecb/cbc inFileName outFileName\0A\00"
@.str.2 = [8 x i8] c"encrypt\00"
@.str.3 = [4 x i8] c"ecb\00"
@.str.4 = [4 x i8] c"cbc\00"
@.str.5 = [8 x i8] c"decrypt\00"
@.str.6 = [33 x i8] c"Start encrypting in ECB mode...\0A\00"
@.str.7 = [33 x i8] c"Start encrypting in CBC mode...\0A\00"
@.str.8 = [33 x i8] c"Start decrypting in ECB mode...\0A\00"
@.str.9 = [33 x i8] c"Start decrypting in CBC mode...\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = icmp eq i8* %11, null
br i1 %12, label %28, label %13
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %28, label %18
18: ; preds = %13
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 3
%21 = load i8*, i8** %20
%22 = icmp eq i8* %21, null
br i1 %22, label %28, label %23
23: ; preds = %18
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 4
%26 = load i8*, i8** %25
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %31
28: ; preds = %23, %18, %13, %2
%29 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %115
31: ; preds = %23
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %53
37: ; preds = %31
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %37
store i32 1, i32* %6
br label %52
44: ; preds = %37
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 2
%47 = load i8*, i8** %46
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %44
store i32 2, i32* %6
br label %51
51: ; preds = %50, %44
br label %52
52: ; preds = %51, %43
br label %76
53: ; preds = %31
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 1
%56 = load i8*, i8** %55
%57 = call i64 @strcmp(i8* %56, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %75
59: ; preds = %53
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 2
%62 = load i8*, i8** %61
%63 = call i64 @strcmp(i8* %62, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %59
store i32 3, i32* %6
br label %74
66: ; preds = %59
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 2
%69 = load i8*, i8** %68
%70 = call i64 @strcmp(i8* %69, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %73
72: ; preds = %66
store i32 4, i32* %6
br label %73
73: ; preds = %72, %66
br label %74
74: ; preds = %73, %65
br label %75
75: ; preds = %74, %53
br label %76
76: ; preds = %75, %52
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 3
%79 = load i8*, i8** %78
store i8* %79, i8** %7
%80 = load i8**, i8*** %5
%81 = getelementptr inbounds i8*, i8** %80, i64 4
%82 = load i8*, i8** %81
store i8* %82, i8** %8
%83 = load i32, i32* %6
%84 = icmp eq i32 %83, 1
br i1 %84, label %85, label %90
85: ; preds = %76
%86 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%87 = load i8*, i8** %7
%88 = load i8*, i8** %8
%89 = call i32 @encryptECB(i8* %87, i8* %88)
store i32 0, i32* %3
br label %115
90: ; preds = %76
%91 = load i32, i32* %6
%92 = icmp eq i32 %91, 2
br i1 %92, label %93, label %98
93: ; preds = %90
%94 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
%95 = load i8*, i8** %7
%96 = load i8*, i8** %8
%97 = call i32 @encryptCBC(i8* %95, i8* %96)
store i32 0, i32* %3
br label %115
98: ; preds = %90
%99 = load i32, i32* %6
%100 = icmp eq i32 %99, 3
br i1 %100, label %101, label %106
101: ; preds = %98
%102 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
%103 = load i8*, i8** %7
%104 = load i8*, i8** %8
%105 = call i32 @decryptECB(i8* %103, i8* %104)
store i32 0, i32* %3
br label %115
106: ; preds = %98
%107 = load i32, i32* %6
%108 = icmp eq i32 %107, 4
br i1 %108, label %109, label %114
109: ; preds = %106
%110 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
%111 = load i8*, i8** %7
%112 = load i8*, i8** %8
%113 = call i32 @decryptCBC(i8* %111, i8* %112)
store i32 0, i32* %3
br label %115
114: ; preds = %106
store i32 0, i32* %3
br label %115
115: ; preds = %114, %109, %101, %93, %85, %28
%116 = load i32, i32* %3
ret i32 %116
}

LLVM IR (-O2):
@.str.2 = [8 x i8] c"encrypt\00"
@.str.3 = [4 x i8] c"ecb\00"
@.str.4 = [4 x i8] c"cbc\00"
@.str.5 = [8 x i8] c"decrypt\00"
@str = [32 x i8] c"Start decrypting in CBC mode...\00"
@str.10 = [32 x i8] c"Start decrypting in ECB mode...\00"
@str.11 = [32 x i8] c"Start encrypting in CBC mode...\00"
@str.12 = [32 x i8] c"Start encrypting in ECB mode...\00"
@str.13 = [49 x i8] c"Upss, something is wrong, check your parameters!\00"
@str.14 = [63 x i8] c"Correct format: encrypt/decrypt ecb/cbc inFileName outFileName\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %18, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %18, label %10
10: ; preds = %6
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = icmp eq i8* %12, null
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = getelementptr inbounds i8*, i8** %1, i64 4
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %14, %10, %6, %2
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.13, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str.14, i64 0, i64 0))
br label %60
21: ; preds = %14
%22 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i8*, i8** %7
%26 = tail call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %36, label %41
28: ; preds = %21
%29 = load i8*, i8** %3
%30 = tail call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i8*, i8** %7
%34 = tail call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %48, label %53
36: ; preds = %28, %24
%37 = load i8*, i8** %11
%38 = load i8*, i8** %15
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.12, i64 0, i64 0))
%40 = tail call i32 @encryptECB(i8* %37, i8* %38)
br label %60
41: ; preds = %24
%42 = load i8*, i8** %7
%43 = tail call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%44 = load i8*, i8** %11
%45 = load i8*, i8** %15
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.11, i64 0, i64 0))
%47 = tail call i32 @encryptCBC(i8* %44, i8* %45)
br label %60
48: ; preds = %32
%49 = load i8*, i8** %11
%50 = load i8*, i8** %15
%51 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.10, i64 0, i64 0))
%52 = tail call i32 @decryptECB(i8* %49, i8* %50)
br label %60
53: ; preds = %32
%54 = load i8*, i8** %7
%55 = tail call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%56 = load i8*, i8** %11
%57 = load i8*, i8** %15
%58 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%59 = tail call i32 @decryptCBC(i8* %56, i8* %57)
br label %60
60: ; preds = %36, %41, %48, %53, %18
%61 = phi i32 [ 1, %18 ], [ 0, %53 ], [ 0, %48 ], [ 0, %41 ], [ 0, %36 ]
ret i32 %61
}