#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*/ key;
typedef int clock_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int CLOCKS_PER_SEC;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
scalar_t__ calloc(unsigned long, int);
int clock();
int /*<<< orphan*/ decrypt(unsigned char *, unsigned char *, unsigned long);
int /*<<< orphan*/ encrypt(unsigned char *, unsigned char *, unsigned long);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
unsigned long fread(unsigned char *, int, unsigned long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
unsigned long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char *, int, unsigned long,
                          int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  FILE *file;
  unsigned char *buf;
  unsigned long numbytes;
  char *fname;
  clock_t start, enc_time, dec_time;
  int mili_sec, i;
  int padding;
  unsigned char key[32];
  ++argv, --argc;
  if (argc > 0)
    fname = argv[0];
  else
    fname = "input.txt";
  file = fopen(fname, "r");
  if (file == NULL) {
    printf("File %s doesn't exist\n", fname);
    exit(1);
  }
  printf("Opened file %s\n", fname);
  fseek(file, 0L, SEEK_END);
  numbytes = ftell(file);
  printf("Size is %lu\n", numbytes);
  fseek(file, 0L, SEEK_SET);
  buf = (unsigned char *)calloc(numbytes, sizeof(unsigned char));
  if (buf == NULL)
    exit(1);
  if (fread(buf, 1, numbytes, file) != numbytes) {
    printf("Unable to read all bytes from file %s\n", fname);
    exit(EXIT_FAILURE);
  }
  fclose(file);
  padding = numbytes % 16;
  numbytes += padding;
  printf("Padding file with %d bytes for a new size of %lu\n", padding,
         numbytes);
  for (i = 0; i < sizeof(key); i++)
    key[i] = i;
  printf("Starting encryption timer\n");
  start = clock();
  encrypt(key, buf, numbytes);
  enc_time = clock() - start;
  printf("Stopping encryption timer\n");
  printf("Writing %lu bytes of encrypted data to cipher.txt\n", numbytes);
  file = fopen("cipher.txt", "w");
  fwrite(buf, 1, numbytes, file);
  fclose(file);
  printf("Starting decryption timer\n");
  start = clock();
  decrypt(key, buf, numbytes);
  dec_time = clock() - start;
  printf("Stopping decryption timer\n");
  mili_sec = enc_time * 1000 / CLOCKS_PER_SEC;
  printf("Elapsed encryption time is %d minute(s), %d second(s), and %d "
         "millisecond(s).\n",
         (mili_sec / 1000) / 60, mili_sec / 1000, mili_sec % 1000);
  mili_sec = dec_time * 1000 / CLOCKS_PER_SEC;
  printf("Elapsed decryption time is %d minute(s), %d second(s), and %d "
         "millisecond(s).\n",
         (mili_sec / 1000) / 60, mili_sec / 1000, mili_sec % 1000);
  printf("Writing %lu bytes of decrypted plaintext to output.txt\n",
         numbytes - padding);
  file = fopen("output.txt", "w");
  fwrite(buf, 1, numbytes - padding, file);
  fclose(file);
  free(buf);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1218 <main+0x48>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1223 <main+0x53>
lea    0xde1(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    125e <main+0x8e>
mov    -0x30(%rbp),%rsi
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x30(%rbp),%rsi
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    0x2d6d(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10c0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <ftell@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    0x2d20(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10c0 <fseek@plt>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12e2 <main+0x112>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fread@plt>
cmp    -0x28(%rbp),%rax
je     1322 <main+0x152>
mov    -0x30(%rbp),%rsi
lea    0xd33(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2cad(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x28(%rbp),%rax
and    $0xf,%rax
mov    %eax,-0x48(%rbp)
movslq -0x48(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x48(%rbp),%esi
mov    -0x28(%rbp),%rdx
lea    0xd17(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x44(%rbp)
movslq -0x44(%rbp),%rax
cmp    $0x20,%rax
jae    1387 <main+0x1b7>
mov    -0x44(%rbp),%eax
mov    %al,%cl
movslq -0x44(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    135e <main+0x18e>
lea    0xd0b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   1060 <clock@plt>
mov    %eax,-0x34(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1090 <encrypt@plt>
mov    $0x0,%al
call   1060 <clock@plt>
sub    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
lea    0xcf0(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xcf9(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd1e(%rip),%rdi
lea    0xd22(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10f0 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fclose@plt>
lea    0xcf5(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   1060 <clock@plt>
mov    %eax,-0x34(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <decrypt@plt>
mov    $0x0,%al
call   1060 <clock@plt>
sub    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
lea    0xcda(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
imul   $0x3e8,-0x38(%rbp),%eax
mov    0x2b7b(%rip),%rcx
cltd
idivl  (%rcx)
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x40(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x78(%rbp)
mov    -0x40(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x78(%rbp),%edx
lea    0xca0(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
imul   $0x3e8,-0x3c(%rbp),%eax
mov    0x2b26(%rip),%rcx
cltd
idivl  (%rcx)
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x40(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x74(%rbp)
mov    -0x40(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x74(%rbp),%edx
lea    0xc9a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x28(%rbp),%rsi
movslq -0x48(%rbp),%rax
sub    %rax,%rsi
lea    0xcd0(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xcfa(%rip),%rdi
lea    0xbe5(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
movslq -0x48(%rbp),%rax
sub    %rax,%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10f0 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    0x2a59(%rip),%rax
mov    (%rax),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x2,%edi
jl     11f9 <main+0x19>
mov    0x8(%rsi),%r15
jmp    1200 <main+0x20>
lea    0xe20(%rip),%r15
lea    0x1037(%rip),%rsi
mov    %r15,%rdi
call   10e0 <fopen@plt>
test   %rax,%rax
je     149a <main+0x2ba>
mov    %rax,%rbx
lea    0xe1f(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x2db5(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    %rbx,%rdi
call   10c0 <ftell@plt>
mov    %rax,%r12
lea    0xe00(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    %r12,%rdi
mov    $0x1,%esi
call   10b0 <calloc@plt>
test   %rax,%rax
je     14ab <main+0x2cb>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
mov    %rbx,%rcx
call   1060 <fread@plt>
cmp    %r12,%rax
jne    14b5 <main+0x2d5>
mov    %rbx,%rdi
call   1080 <fclose@plt>
mov    %r12d,%esi
and    $0xf,%esi
mov    %r12,%rbx
add    %rsi,%rbx
lea    0xdc7(%rip),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
movaps 0xd31(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xd36(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xef2(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1070 <clock@plt>
mov    %eax,%ebp
mov    %rsp,%r13
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   10a0 <encrypt@plt>
xor    %eax,%eax
call   1070 <clock@plt>
mov    %eax,%r15d
sub    %ebp,%r15d
lea    0xed9(%rip),%rdi
call   1050 <puts@plt>
lea    0xd92(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xdb4(%rip),%rdi
lea    0xdb8(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,%rbp
mov    %r14,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1100 <fwrite@plt>
mov    %rbp,%rdi
call   1080 <fclose@plt>
lea    0xea5(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1070 <clock@plt>
mov    %eax,%ebp
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <decrypt@plt>
xor    %eax,%eax
call   1070 <clock@plt>
mov    %eax,%ebx
sub    %ebp,%ebx
lea    0xe91(%rip),%rdi
call   1050 <puts@plt>
imul   $0x3e8,%r15d,%eax
mov    0x2c38(%rip),%rbp
cltd
idivl  0x0(%rbp)
movslq %eax,%rcx
imul   $0x45e7b273,%rcx,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x2e,%rsi
add    %eax,%esi
imul   $0x10624dd3,%rcx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x26,%rdx
add    %eax,%edx
imul   $0x3e8,%edx,%eax
sub    %eax,%ecx
lea    0xd11(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
imul   $0x3e8,%ebx,%eax
cltd
idivl  0x0(%rbp)
movslq %eax,%rcx
imul   $0x45e7b273,%rcx,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x2e,%rsi
add    %eax,%esi
imul   $0x10624dd3,%rcx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x26,%rdx
add    %eax,%edx
imul   $0x3e8,%edx,%eax
sub    %eax,%ecx
lea    0xd15(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd56(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd7d(%rip),%rdi
lea    0xc9e(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
mov    %rax,%rcx
call   1100 <fwrite@plt>
mov    %rbx,%rdi
call   1080 <fclose@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    0x2b37(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb89(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0xba2(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x2afb(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [23 x i8] c"File %s doesn't exist\0A\00"
@.str.3 = [16 x i8] c"Opened file %s\0A\00"
@SEEK_END = global i32 0
@.str.4 = [13 x i8] c"Size is %lu\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [39 x i8] c"Unable to read all bytes from file %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [50 x i8] c"Padding file with %d bytes for a new size of %lu\0A\00"
@.str.7 = [27 x i8] c"Starting encryption timer\0A\00"
@.str.8 = [27 x i8] c"Stopping encryption timer\0A\00"
@.str.9 = [51 x i8] c"Writing %lu bytes of encrypted data to cipher.txt\0A\00"
@.str.10 = [11 x i8] c"cipher.txt\00"
@.str.11 = [2 x i8] c"w\00"
@.str.12 = [27 x i8] c"Starting decryption timer\0A\00"
@.str.13 = [27 x i8] c"Stopping decryption timer\0A\00"
@CLOCKS_PER_SEC = global i32 0
@.str.14 = [79 x i8] c"Elapsed encryption time is %d minute(s), %d second(s), and %d millisecond(s).\0A\00"
@.str.15 = [79 x i8] c"Elapsed decryption time is %d minute(s), %d second(s), and %d millisecond(s).\0A\00"
@.str.16 = [56 x i8] c"Writing %lu bytes of decrypted plaintext to output.txt\0A\00"
@.str.17 = [11 x i8] c"output.txt\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [32 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i32 1
store i8** %18, i8*** %5
%19 = load i32, i32* %4
%20 = add nsw i32 %19, -1
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
store i8* %26, i8** %9
br label %28
27: ; preds = %2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %9
br label %28
28: ; preds = %27, %23
%29 = load i8*, i8** %9
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %30, i32** %6
%31 = load i32*, i32** %6
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = load i8*, i8** %9
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %28
%38 = load i8*, i8** %9
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %38)
%40 = load i32*, i32** %6
%41 = load i32, i32* @SEEK_END
%42 = call i32 @fseek(i32* %40, i64 0, i32 %41)
%43 = load i32*, i32** %6
%44 = call i64 @ftell(i32* %43)
store i64 %44, i64* %8
%45 = load i64, i64* %8
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i64 %45)
%47 = load i32*, i32** %6
%48 = load i32, i32* @SEEK_SET
%49 = call i32 @fseek(i32* %47, i64 0, i32 %48)
%50 = load i64, i64* %8
%51 = call i64 @calloc(i64 %50, i32 1)
%52 = inttoptr i64 %51 to i8*
store i8* %52, i8** %7
%53 = load i8*, i8** %7
%54 = icmp eq i8* %53, null
br i1 %54, label %55, label %57
55: ; preds = %37
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %37
%58 = load i8*, i8** %7
%59 = load i64, i64* %8
%60 = load i32*, i32** %6
%61 = call i64 @fread(i8* %58, i32 1, i64 %59, i32* %60)
%62 = load i64, i64* %8
%63 = icmp ne i64 %61, %62
br i1 %63, label %64, label %69
64: ; preds = %57
%65 = load i8*, i8** %9
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* %65)
%67 = load i32, i32* @EXIT_FAILURE
%68 = call i32 @exit(i32 %67)
unreachable
69: ; preds = %57
%70 = load i32*, i32** %6
%71 = call i32 @fclose(i32* %70)
%72 = load i64, i64* %8
%73 = urem i64 %72, 16
%74 = trunc i64 %73 to i32
store i32 %74, i32* %15
%75 = load i32, i32* %15
%76 = sext i32 %75 to i64
%77 = load i64, i64* %8
%78 = add i64 %77, %76
store i64 %78, i64* %8
%79 = load i32, i32* %15
%80 = load i64, i64* %8
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i32 %79, i64 %80)
store i32 0, i32* %14
br label %82
82: ; preds = %92, %69
%83 = load i32, i32* %14
%84 = sext i32 %83 to i64
%85 = icmp ult i64 %84, 32
br i1 %85, label %86, label %95
86: ; preds = %82
%87 = load i32, i32* %14
%88 = trunc i32 %87 to i8
%89 = load i32, i32* %14
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [32 x i8], [32 x i8]* %16, i64 0, i64 %90
store i8 %88, i8* %91
br label %92
92: ; preds = %86
%93 = load i32, i32* %14
%94 = add nsw i32 %93, 1
store i32 %94, i32* %14
br label %82
95: ; preds = %82
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%97 = call i32 (...) @clock()
store i32 %97, i32* %10
%98 = getelementptr inbounds [32 x i8], [32 x i8]* %16, i64 0, i64 0
%99 = load i8*, i8** %7
%100 = load i64, i64* %8
%101 = call i32 @encrypt(i8* %98, i8* %99, i64 %100)
%102 = call i32 (...) @clock()
%103 = load i32, i32* %10
%104 = sub nsw i32 %102, %103
store i32 %104, i32* %11
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
%106 = load i64, i64* %8
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0), i64 %106)
%108 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
store i32* %108, i32** %6
%109 = load i8*, i8** %7
%110 = load i64, i64* %8
%111 = load i32*, i32** %6
%112 = call i32 @fwrite(i8* %109, i32 1, i64 %110, i32* %111)
%113 = load i32*, i32** %6
%114 = call i32 @fclose(i32* %113)
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0))
%116 = call i32 (...) @clock()
store i32 %116, i32* %10
%117 = getelementptr inbounds [32 x i8], [32 x i8]* %16, i64 0, i64 0
%118 = load i8*, i8** %7
%119 = load i64, i64* %8
%120 = call i32 @decrypt(i8* %117, i8* %118, i64 %119)
%121 = call i32 (...) @clock()
%122 = load i32, i32* %10
%123 = sub nsw i32 %121, %122
store i32 %123, i32* %12
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0))
%125 = load i32, i32* %11
%126 = mul nsw i32 %125, 1000
%127 = load i32, i32* @CLOCKS_PER_SEC
%128 = sdiv i32 %126, %127
store i32 %128, i32* %13
%129 = load i32, i32* %13
%130 = sdiv i32 %129, 1000
%131 = sdiv i32 %130, 60
%132 = load i32, i32* %13
%133 = sdiv i32 %132, 1000
%134 = load i32, i32* %13
%135 = srem i32 %134, 1000
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.14, i64 0, i64 0), i32 %131, i32 %133, i32 %135)
%137 = load i32, i32* %12
%138 = mul nsw i32 %137, 1000
%139 = load i32, i32* @CLOCKS_PER_SEC
%140 = sdiv i32 %138, %139
store i32 %140, i32* %13
%141 = load i32, i32* %13
%142 = sdiv i32 %141, 1000
%143 = sdiv i32 %142, 60
%144 = load i32, i32* %13
%145 = sdiv i32 %144, 1000
%146 = load i32, i32* %13
%147 = srem i32 %146, 1000
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.15, i64 0, i64 0), i32 %143, i32 %145, i32 %147)
%149 = load i64, i64* %8
%150 = load i32, i32* %15
%151 = sext i32 %150 to i64
%152 = sub i64 %149, %151
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.16, i64 0, i64 0), i64 %152)
%154 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
store i32* %154, i32** %6
%155 = load i8*, i8** %7
%156 = load i64, i64* %8
%157 = load i32, i32* %15
%158 = sext i32 %157 to i64
%159 = sub i64 %156, %158
%160 = load i32*, i32** %6
%161 = call i32 @fwrite(i8* %155, i32 1, i64 %159, i32* %160)
%162 = load i32*, i32** %6
%163 = call i32 @fclose(i32* %162)
%164 = load i8*, i8** %7
%165 = call i32 @free(i8* %164)
%166 = load i32, i32* @EXIT_SUCCESS
ret i32 %166
}

LLVM IR (-O2):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [23 x i8] c"File %s doesn't exist\0A\00"
@.str.3 = [16 x i8] c"Opened file %s\0A\00"
@SEEK_END = global i32 0
@.str.4 = [13 x i8] c"Size is %lu\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [39 x i8] c"Unable to read all bytes from file %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [50 x i8] c"Padding file with %d bytes for a new size of %lu\0A\00"
@.str.9 = [51 x i8] c"Writing %lu bytes of encrypted data to cipher.txt\0A\00"
@.str.10 = [11 x i8] c"cipher.txt\00"
@.str.11 = [2 x i8] c"w\00"
@CLOCKS_PER_SEC = global i32 0
@.str.14 = [79 x i8] c"Elapsed encryption time is %d minute(s), %d second(s), and %d millisecond(s).\0A\00"
@.str.15 = [79 x i8] c"Elapsed decryption time is %d minute(s), %d second(s), and %d millisecond(s).\0A\00"
@.str.16 = [56 x i8] c"Writing %lu bytes of decrypted plaintext to output.txt\0A\00"
@.str.17 = [11 x i8] c"output.txt\00"
@EXIT_SUCCESS = global i32 0
@str = [26 x i8] c"Starting encryption timer\00"
@str.18 = [26 x i8] c"Stopping encryption timer\00"
@str.19 = [26 x i8] c"Starting decryption timer\00"
@str.20 = [26 x i8] c"Stopping decryption timer\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
br label %9
9: ; preds = %2, %6
%10 = phi i8* [ %8, %6 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %2 ]
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %9
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%18 = load i32, i32* @SEEK_END
%19 = tail call i32 @fseek(i32* %11, i64 0, i32 %18)
%20 = tail call i64 @ftell(i32* %11)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i64 %20)
%22 = load i32, i32* @SEEK_SET
%23 = tail call i32 @fseek(i32* %11, i64 0, i32 %22)
%24 = tail call i64 @calloc(i64 %20, i32 1)
%25 = inttoptr i64 %24 to i8*
%26 = icmp eq i64 %24, 0
br i1 %26, label %27, label %29
27: ; preds = %16
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %16
%30 = tail call i64 @fread(i8* %25, i32 1, i64 %20, i32* %11)
%31 = icmp eq i64 %30, %20
br i1 %31, label %36, label %32
32: ; preds = %29
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* %10)
%34 = load i32, i32* @EXIT_FAILURE
%35 = tail call i32 @exit(i32 %34)
unreachable
36: ; preds = %29
%37 = tail call i32 @fclose(i32* %11)
%38 = trunc i64 %20 to i32
%39 = and i32 %38, 15
%40 = zext i32 %39 to i64
%41 = add i64 %20, %40
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i32 %39, i64 %41)
%43 = bitcast [32 x i8]* %3 to <16 x i8>*
store <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, <16 x i8>* %43
%44 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 16
%45 = bitcast i8* %44 to <16 x i8>*
store <16 x i8> <i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23, i8 24, i8 25, i8 26, i8 27, i8 28, i8 29, i8 30, i8 31>, <16 x i8>* %45
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%47 = tail call i32 (...) @clock()
%48 = call i32 @encrypt(i8* %4, i8* %25, i64 %41)
%49 = call i32 (...) @clock()
%50 = sub nsw i32 %49, %47
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.18, i64 0, i64 0))
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0), i64 %41)
%53 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%54 = call i32 @fwrite(i8* %25, i32 1, i64 %41, i32* %53)
%55 = call i32 @fclose(i32* %53)
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.19, i64 0, i64 0))
%57 = call i32 (...) @clock()
%58 = call i32 @decrypt(i8* %4, i8* %25, i64 %41)
%59 = call i32 (...) @clock()
%60 = sub nsw i32 %59, %57
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.20, i64 0, i64 0))
%62 = mul nsw i32 %50, 1000
%63 = load i32, i32* @CLOCKS_PER_SEC
%64 = sdiv i32 %62, %63
%65 = sdiv i32 %64, 1000
%66 = sdiv i32 %64, 60000
%67 = srem i32 %64, 1000
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @.str.14, i64 0, i64 0), i32 %66, i32 %65, i32 %67)
%69 = mul nsw i32 %60, 1000
%70 = load i32, i32* @CLOCKS_PER_SEC
%71 = sdiv i32 %69, %70
%72 = sdiv i32 %71, 1000
%73 = sdiv i32 %71, 60000
%74 = srem i32 %71, 1000
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @.str.15, i64 0, i64 0), i32 %73, i32 %72, i32 %74)
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.16, i64 0, i64 0), i64 %20)
%77 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%78 = call i32 @fwrite(i8* %25, i32 1, i64 %20, i32* %77)
%79 = call i32 @fclose(i32* %77)
%80 = call i32 @free(i8* %25)
%81 = load i32, i32* @EXIT_SUCCESS
ret i32 %81
}