#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ encryptDecrypt(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  char dir[255];
  if (argc < 2)
    strcpy(dir, "/mnt/usbDrive");
  else {
    strcpy(dir, argv[1]);
  }
  char filenameIn[255];
  strcat(filenameIn, dir);
  strcat(filenameIn, "/toCrypt");
  char filenameOut[255];
  strcat(filenameOut, dir);
  strcat(filenameOut, "/encrypted.xor");
  FILE *fileIn = fopen(filenameIn, "r");
  printf("toCrypt opened\n");
  FILE *fileEncrypted = fopen(filenameOut, "w");
  printf("encripted.xor created\n");
  if (fileIn != NULL) {
    char line[128];
    char encrypted[strlen(line)];
    char decrypted[strlen(line)];
    while (fgets(line, sizeof line, fileIn) != NULL) {
      encryptDecrypt(line, encrypted);
      printf("encrypting file...\n");
      fprintf(fileEncrypted, "%s", decrypted);
    }
    fclose(fileIn);
    fclose(fileEncrypted);
  } else {
    perror(filenameIn);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11db <main+0x3b>
lea    -0x110(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11ef <main+0x4f>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x210(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   10c0 <strcat@plt>
lea    -0x210(%rbp),%rdi
lea    0xdfe(%rip),%rsi
call   10c0 <strcat@plt>
lea    -0x310(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   10c0 <strcat@plt>
lea    -0x310(%rbp),%rdi
lea    0xde1(%rip),%rsi
call   10c0 <strcat@plt>
lea    -0x210(%rbp),%rdi
lea    0xddb(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x318(%rbp)
lea    0xdca(%rip),%rdi
call   1070 <printf@plt>
lea    -0x310(%rbp),%rdi
lea    0xdc7(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x320(%rbp)
lea    0xdb6(%rip),%rdi
call   1070 <printf@plt>
cmpq   $0x0,-0x318(%rbp)
je     138d <main+0x1ed>
lea    -0x3a0(%rbp),%rdi
mov    %rdi,-0x3d0(%rbp)
call   1060 <strlen@plt>
mov    -0x3d0(%rbp),%rdi
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x3a8(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x3c8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x3b0(%rbp)
call   1060 <strlen@plt>
mov    %eax,%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x3c0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x3b8(%rbp)
lea    -0x3a0(%rbp),%rdi
mov    -0x318(%rbp),%rdx
mov    $0x80,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1366 <main+0x1c6>
mov    -0x3c8(%rbp),%rsi
lea    -0x3a0(%rbp),%rdi
call   1040 <encryptDecrypt@plt>
lea    0xd0d(%rip),%rdi
call   1070 <printf@plt>
mov    -0x3c0(%rbp),%rdx
mov    -0x320(%rbp),%rdi
lea    0xd07(%rip),%rsi
call   1090 <fprintf@plt>
jmp    1306 <main+0x166>
mov    -0x318(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x320(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x3a8(%rbp),%rax
mov    %rax,%rsp
jmp    1399 <main+0x1f9>
lea    -0x210(%rbp),%rdi
call   10b0 <perror@plt>
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x388,%rsp
cmp    $0x2,%edi
jge    11c2 <main+0x22>
lea    0xe40(%rip),%rsi
jmp    11c6 <main+0x26>
mov    0x8(%rsi),%rsi
lea    -0x3b0(%rbp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    -0x1b0(%rbp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   10c0 <strcat@plt>
lea    0xe20(%rip),%rsi
mov    %r14,%rdi
call   10c0 <strcat@plt>
lea    -0x2b0(%rbp),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
call   10c0 <strcat@plt>
lea    0xe08(%rip),%rsi
mov    %r12,%rdi
call   10c0 <strcat@plt>
lea    0xe06(%rip),%rsi
mov    %r14,%rdi
call   10a0 <fopen@plt>
mov    %rax,%rbx
lea    0xdf8(%rip),%rdi
call   1040 <puts@plt>
lea    0xdea(%rip),%rsi
mov    %r12,%rdi
call   10a0 <fopen@plt>
mov    %rax,%r15
lea    0xde9(%rip),%rdi
call   1040 <puts@plt>
test   %rbx,%rbx
je     131c <main+0x17c>
lea    -0xb0(%rbp),%r14
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %rsp,-0x30(%rbp)
mov    %eax,%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %eax,%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %r14,%rdi
mov    $0x80,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
mov    %rbx,%r14
je     12f7 <main+0x157>
lea    -0xb0(%rbp),%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <encryptDecrypt@plt>
lea    0xd7b(%rip),%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1080 <fputs@plt>
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
jne    12c0 <main+0x120>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    -0x30(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    -0x1b0(%rbp),%rdi
call   10b0 <perror@plt>
jmp    130b <main+0x16b>

LLVM IR (-O0):
@.str = [14 x i8] c"/mnt/usbDrive\00"
@.str.1 = [9 x i8] c"/toCrypt\00"
@.str.2 = [15 x i8] c"/encrypted.xor\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [16 x i8] c"toCrypt opened\0A\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [23 x i8] c"encripted.xor created\0A\00"
@.str.7 = [20 x i8] c"encrypting file...\0A\00"
@.str.8 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [255 x i8]
%7 = alloca [255 x i8]
%8 = alloca [255 x i8]
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca [128 x i8]
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %26
20: ; preds = %2
%21 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strcpy(i8* %21, i8* %24)
br label %26
26: ; preds = %20, %17
%27 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%28 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%29 = call i32 @strcat(i8* %27, i8* %28)
%30 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%31 = call i32 @strcat(i8* %30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%32 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%33 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%34 = call i32 @strcat(i8* %32, i8* %33)
%35 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%36 = call i32 @strcat(i8* %35, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%37 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%38 = call i32* @fopen(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %38, i32** %9
%39 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%40 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%41 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %41, i32** %10
%42 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%43 = load i32*, i32** %9
%44 = icmp ne i32* %43, null
br i1 %44, label %45, label %72
45: ; preds = %26
%46 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%47 = call i32 @strlen(i8* %46)
%48 = zext i32 %47 to i64
%49 = call i8* @llvm.stacksave()
store i8* %49, i8** %12
%50 = alloca i8, i64 %48
store i64 %48, i64* %13
%51 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%52 = call i32 @strlen(i8* %51)
%53 = zext i32 %52 to i64
%54 = alloca i8, i64 %53
store i64 %53, i64* %14
br label %55
55: ; preds = %60, %45
%56 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%57 = load i32*, i32** %9
%58 = call i32* @fgets(i8* %56, i32 128, i32* %57)
%59 = icmp ne i32* %58, null
br i1 %59, label %60, label %66
60: ; preds = %55
%61 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%62 = call i32 @encryptDecrypt(i8* %61, i8* %50)
%63 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%64 = load i32*, i32** %10
%65 = call i32 @fprintf(i32* %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %54)
br label %55
66: ; preds = %55
%67 = load i32*, i32** %9
%68 = call i32 @fclose(i32* %67)
%69 = load i32*, i32** %10
%70 = call i32 @fclose(i32* %69)
%71 = load i8*, i8** %12
br label %75
72: ; preds = %26
%73 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%74 = call i32 @perror(i8* %73)
br label %75
75: ; preds = %72, %66
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"/mnt/usbDrive\00"
@.str.1 = [9 x i8] c"/toCrypt\00"
@.str.2 = [15 x i8] c"/encrypted.xor\00"
@.str.3 = [2 x i8] c"r\00"
@.str.5 = [2 x i8] c"w\00"
@str = [15 x i8] c"toCrypt opened\00"
@str.9 = [22 x i8] c"encripted.xor created\00"
@str.10 = [19 x i8] c"encrypting file...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = alloca [255 x i8]
%6 = alloca [128 x i8]
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%8 = icmp slt i32 %0, 2
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
br label %12
12: ; preds = %2, %9
%13 = phi i8* [ %11, %9 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %2 ]
%14 = call i32 @strcpy(i8* %7, i8* %13)
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%16 = call i32 @strcat(i8* %15, i8* %7)
%17 = call i32 @strcat(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%19 = call i32 @strcat(i8* %18, i8* %7)
%20 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%23 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
%25 = icmp eq i32* %21, null
br i1 %25, label %46, label %26
26: ; preds = %12
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
%29 = zext i32 %28 to i64
%30 = call i8* @llvm.stacksave()
%31 = alloca i8, i64 %29
%32 = call i32 @strlen(i8* %27)
%33 = zext i32 %32 to i64
%34 = alloca i8, i64 %33
%35 = call i32* @fgets(i8* %27, i32 128, i32* %21)
%36 = icmp eq i32* %35, null
br i1 %36, label %43, label %37
37: ; preds = %26, %37
%38 = call i32 @encryptDecrypt(i8* %27, i8* %31)
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.10, i64 0, i64 0))
%40 = call i32 @fputs(i8* %34, i32* %23)
%41 = call i32* @fgets(i8* %27, i32 128, i32* %21)
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %37
43: ; preds = %37, %26
%44 = call i32 @fclose(i32* %21)
%45 = call i32 @fclose(i32* %23)
br label %48
46: ; preds = %12
%47 = call i32 @perror(i8* %15)
br label %48
48: ; preds = %46, %43
ret i32 0
}