#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*/ _IONBF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fread(int **, int, int, int /*<<< orphan*/ *);
int fwrite(int **, int, int, int /*<<< orphan*/ *);
int *keygen();
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  setvbuf(stdout, NULL, _IONBF, 0);
  FILE *inputFile, *outputFile;
  int in, out;
  int *buf[64];
  int *key;
  key = keygen();
  if (argc != 3) {
    fprintf(stderr, "Voyage encryption tool\n");
    exit(1);
  }
  if ((inputFile = fopen(argv[1], "rb")) == NULL) {
    fprintf(stderr, "Input file open error\n");
    exit(1);
  } else {
    fprintf(stdout, "=> Input file opened...");
  }
  if ((outputFile = fopen(argv[2], "wb")) == NULL) {
    fprintf(stderr, "Output file open error\n");
    exit(1);
  } else {
    fprintf(stdout, "Output file opened\n");
  }
  while (feof(inputFile) == 0) {
    if ((in = fread(buf, 1, 64, inputFile)) != 100) {
      if (ferror(inputFile) != 0) {
        fprintf(stderr, "File read error\n");
        exit(1);
      }
    }
    if ((out = fwrite(buf, 1, in, outputFile)) != in) {
      fprintf(stderr, "File write error\n");
      exit(1);
    }
  }
  fclose(inputFile);
  fclose(outputFile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    0x2e1f(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1090 <setvbuf@plt>
mov    $0x0,%al
call   1060 <keygen@plt>
mov    %rax,-0x238(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     120d <main+0x6d>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
lea    0xe02(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdfc(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    124e <main+0xae>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
lea    0xddc(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
lea    0xdd4(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdd8(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    12a4 <main+0x104>
mov    0x2d4c(%rip),%rax
mov    (%rax),%edi
lea    0xdb8(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
lea    0xdb1(%rip),%rsi
call   1070 <fprintf@plt>
jmp    12be <main+0x11e>
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
jne    1376 <main+0x1d6>
lea    -0x230(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x40,%edx
call   1040 <fread@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x64,%eax
je     132e <main+0x18e>
mov    -0x18(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     1329 <main+0x189>
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
lea    0xd5f(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    132e <main+0x18e>
lea    -0x230(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   10c0 <fwrite@plt>
mov    %eax,-0x28(%rbp)
cmp    -0x24(%rbp),%eax
je     1371 <main+0x1d1>
mov    0x2c7f(%rip),%rax
mov    (%rax),%edi
lea    0xd28(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    12be <main+0x11e>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
mov    0x2e17(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2e25(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1090 <setvbuf@plt>
xor    %eax,%eax
call   1060 <keygen@plt>
cmp    $0x3,%ebx
jne    12dd <main+0x13d>
mov    0x8(%r14),%rdi
lea    0xe2f(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12ef <main+0x14f>
mov    %rax,%rbx
mov    0x0(%rbp),%edi
lea    0xe2e(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x10(%r14),%rdi
lea    0xe36(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1301 <main+0x161>
mov    %rax,%r14
mov    0x0(%rbp),%edi
lea    0xe36(%rip),%rsi
call   1070 <fprintf@plt>
mov    %rsp,%r15
jmp    1256 <main+0xb6>
nopl   0x0(%rax)
mov    %r15,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r14,%rcx
call   10c0 <fwrite@plt>
cmp    %ebp,%eax
jne    12be <main+0x11e>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    129e <main+0xfe>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x40,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %eax,%ebp
cmp    $0x64,%eax
je     1240 <main+0xa0>
mov    %rbx,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
je     1240 <main+0xa0>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
lea    0xddd(%rip),%rsi
jmp    12ce <main+0x12e>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
lea    0xdbc(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
lea    0xd13(%rip),%rsi
jmp    12ce <main+0x12e>
mov    0x2ce2(%rip),%rax
mov    (%rax),%edi
lea    0xd1c(%rip),%rsi
jmp    12ce <main+0x12e>
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
lea    0xd3c(%rip),%rsi
jmp    12ce <main+0x12e>

LLVM IR (-O0):
@stdout = global i32 0
@_IONBF = global i32 0
@stderr = global i32 0
@.str = [24 x i8] c"Voyage encryption tool\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [23 x i8] c"Input file open error\0A\00"
@.str.3 = [24 x i8] c"=> Input file opened...\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [24 x i8] c"Output file open error\0A\00"
@.str.6 = [20 x i8] c"Output file opened\0A\00"
@.str.7 = [17 x i8] c"File read error\0A\00"
@.str.8 = [18 x i8] c"File write error\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca [64 x i32*]
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* @stdout
%13 = load i32, i32* @_IONBF
%14 = call i32 @setvbuf(i32 %12, i32* null, i32 %13, i32 0)
%15 = call i32* (...) @keygen()
store i32* %15, i32** %11
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 3
br i1 %17, label %18, label %22
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %6
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %32
28: ; preds = %22
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %22
%33 = load i32, i32* @stdout
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %35
35: ; preds = %32
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %39, i32** %7
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %45
41: ; preds = %35
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %35
%46 = load i32, i32* @stdout
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %48
48: ; preds = %45
br label %49
49: ; preds = %78, %48
%50 = load i32*, i32** %6
%51 = call i64 @feof(i32* %50)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %79
53: ; preds = %49
%54 = getelementptr inbounds [64 x i32*], [64 x i32*]* %10, i64 0, i64 0
%55 = load i32*, i32** %6
%56 = call i32 @fread(i32** %54, i32 1, i32 64, i32* %55)
store i32 %56, i32* %8
%57 = icmp ne i32 %56, 100
br i1 %57, label %58, label %67
58: ; preds = %53
%59 = load i32*, i32** %6
%60 = call i64 @ferror(i32* %59)
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %66
62: ; preds = %58
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %58
br label %67
67: ; preds = %66, %53
%68 = getelementptr inbounds [64 x i32*], [64 x i32*]* %10, i64 0, i64 0
%69 = load i32, i32* %8
%70 = load i32*, i32** %7
%71 = call i32 @fwrite(i32** %68, i32 1, i32 %69, i32* %70)
store i32 %71, i32* %9
%72 = load i32, i32* %8
%73 = icmp ne i32 %71, %72
br i1 %73, label %74, label %78
74: ; preds = %67
%75 = load i32, i32* @stderr
%76 = call i32 @fprintf(i32 %75, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %67
br label %49
79: ; preds = %49
%80 = load i32*, i32** %6
%81 = call i32 @fclose(i32* %80)
%82 = load i32*, i32** %7
%83 = call i32 @fclose(i32* %82)
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@_IONBF = global i32 0
@stderr = global i32 0
@.str = [24 x i8] c"Voyage encryption tool\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [23 x i8] c"Input file open error\0A\00"
@.str.3 = [24 x i8] c"=> Input file opened...\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [24 x i8] c"Output file open error\0A\00"
@.str.6 = [20 x i8] c"Output file opened\0A\00"
@.str.7 = [17 x i8] c"File read error\0A\00"
@.str.8 = [18 x i8] c"File write error\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [64 x i32*]
%4 = load i32, i32* @stdout
%5 = load i32, i32* @_IONBF
%6 = tail call i32 @setvbuf(i32 %4, i32* null, i32 %5, i32 0)
%7 = bitcast [64 x i32*]* %3 to i8*
%8 = tail call i32* (...) @keygen()
%9 = icmp eq i32 %0, 3
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %14
%24 = load i32, i32* @stdout
%25 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = tail call i32* @fopen(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %34
30: ; preds = %23
%31 = load i32, i32* @stderr
%32 = tail call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%33 = tail call i32 @exit(i32 1)
unreachable
34: ; preds = %23
%35 = load i32, i32* @stdout
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%37 = getelementptr inbounds [64 x i32*], [64 x i32*]* %3, i64 0, i64 0
br label %38
38: ; preds = %51, %34
%39 = tail call i64 @feof(i32* %17)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %58
41: ; preds = %38
%42 = call i32 @fread(i32** %37, i32 1, i32 64, i32* %17)
%43 = icmp eq i32 %42, 100
br i1 %43, label %51, label %44
44: ; preds = %41
%45 = tail call i64 @ferror(i32* %17)
%46 = icmp eq i64 %45, 0
br i1 %46, label %51, label %47
47: ; preds = %44
%48 = load i32, i32* @stderr
%49 = tail call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%50 = tail call i32 @exit(i32 1)
unreachable
51: ; preds = %44, %41
%52 = call i32 @fwrite(i32** %37, i32 1, i32 %42, i32* %28)
%53 = icmp eq i32 %52, %42
br i1 %53, label %38, label %54
54: ; preds = %51
%55 = load i32, i32* @stderr
%56 = tail call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%57 = tail call i32 @exit(i32 1)
unreachable
58: ; preds = %38
%59 = tail call i32 @fclose(i32* %17)
%60 = tail call i32 @fclose(i32* %28)
ret i32 0
}