#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ decrypt_logo(unsigned char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *fp = NULL;
  unsigned char logo[(12 * 2048)];
  if (argc < 3) {
    fprintf(stderr, "usage: %s <input file> <output file>\n", argv[0]);
    return EXIT_FAILURE;
  }
  fp = fopen(argv[1], "rb");
  if (fp == NULL) {
    fprintf(stderr, "Error: could not open input file '%s'\n", argv[1]);
    return EXIT_FAILURE;
  }
  if (fread(logo, (12 * 2048), 1, fp) != 1) {
    fprintf(stderr, "Error: could not read logo from input file\n");
    fclose(fp);
    return EXIT_FAILURE;
  }
  fclose(fp);
  fp = fopen(argv[2], "wb");
  if (fp == NULL) {
    fprintf(stderr, "Error: could not open output file '%s'\n", argv[2]);
    return EXIT_FAILURE;
  }
  decrypt_logo(logo);
  fwrite(logo, (12 * 2048), 1, fp);
  fclose(fp);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11ba <main+0x5a>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe5e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f8 <main+0x198>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    120d <main+0xad>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe34(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2dd5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f8 <main+0x198>
lea    -0x6020(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x6000,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1261 <main+0x101>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2d81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f8 <main+0x198>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe03(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12bd <main+0x15d>
mov    0x2d4c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdda(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d25(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f8 <main+0x198>
lea    -0x6020(%rbp),%rdi
call   1060 <decrypt_logo@plt>
lea    -0x6020(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x6000,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2cdd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x6020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x6008,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     118a <main+0x2a>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe7b(%rip),%rsi
jmp    1258 <main+0xf8>
mov    0x8(%rbx),%rdi
lea    0xe91(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     120d <main+0xad>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x6000,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1223 <main+0xc3>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    0x10(%rbx),%rdi
lea    0xead(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1244 <main+0xe4>
mov    %rax,%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <decrypt_logo@plt>
mov    %rbx,%rdi
mov    $0x6000,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    0x2dc5(%rip),%rax
jmp    1266 <main+0x106>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe08(%rip),%rsi
jmp    1258 <main+0xf8>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
lea    0xe1d(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
jmp    125f <main+0xff>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xe27(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2d72(%rip),%rax
mov    (%rax),%eax
add    $0x6008,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"usage: %s <input file> <output file>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [39 x i8] c"Error: could not open input file '%s'\0A\00"
@.str.3 = [44 x i8] c"Error: could not read logo from input file\0A\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [40 x i8] c"Error: could not open output file '%s'\0A\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 [24576 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
store i32 %16, i32* %3
br label %67
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %6
%22 = load i32*, i32** %6
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %31
24: ; preds = %17
%25 = load i32, i32* @stderr
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
store i32 %30, i32* %3
br label %67
31: ; preds = %17
%32 = getelementptr inbounds [24576 x i8], [24576 x i8]* %7, i64 0, i64 0
%33 = load i32*, i32** %6
%34 = call i32 @fread(i8* %32, i32 24576, i32 1, i32* %33)
%35 = icmp ne i32 %34, 1
br i1 %35, label %36, label %42
36: ; preds = %31
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%39 = load i32*, i32** %6
%40 = call i32 @fclose(i32* %39)
%41 = load i32, i32* @EXIT_FAILURE
store i32 %41, i32* %3
br label %67
42: ; preds = %31
%43 = load i32*, i32** %6
%44 = call i32 @fclose(i32* %43)
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 2
%47 = load i8*, i8** %46
%48 = call i32* @fopen(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %48, i32** %6
%49 = load i32*, i32** %6
%50 = icmp eq i32* %49, null
br i1 %50, label %51, label %58
51: ; preds = %42
%52 = load i32, i32* @stderr
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 2
%55 = load i8*, i8** %54
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i8* %55)
%57 = load i32, i32* @EXIT_FAILURE
store i32 %57, i32* %3
br label %67
58: ; preds = %42
%59 = getelementptr inbounds [24576 x i8], [24576 x i8]* %7, i64 0, i64 0
%60 = call i32 @decrypt_logo(i8* %59)
%61 = getelementptr inbounds [24576 x i8], [24576 x i8]* %7, i64 0, i64 0
%62 = load i32*, i32** %6
%63 = call i32 @fwrite(i8* %61, i32 24576, i32 1, i32* %62)
%64 = load i32*, i32** %6
%65 = call i32 @fclose(i32* %64)
%66 = load i32, i32* @EXIT_SUCCESS
store i32 %66, i32* %3
br label %67
67: ; preds = %58, %51, %36, %24, %10
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"usage: %s <input file> <output file>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [39 x i8] c"Error: could not open input file '%s'\0A\00"
@.str.3 = [44 x i8] c"Error: could not read logo from input file\0A\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [40 x i8] c"Error: could not open output file '%s'\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [24576 x i8]
%4 = getelementptr inbounds [24576 x i8], [24576 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %40
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %11
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %40
19: ; preds = %10
%20 = call i32 @fread(i8* %4, i32 24576, i32 1, i32* %13)
%21 = icmp eq i32 %20, 1
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%25 = tail call i32 @fclose(i32* %13)
br label %40
26: ; preds = %19
%27 = tail call i32 @fclose(i32* %13)
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = tail call i32* @fopen(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %36
32: ; preds = %26
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %28
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i8* %34)
br label %40
36: ; preds = %26
%37 = call i32 @decrypt_logo(i8* %4)
%38 = call i32 @fwrite(i8* %4, i32 24576, i32 1, i32* %30)
%39 = call i32 @fclose(i32* %30)
br label %40
40: ; preds = %36, %32, %22, %15, %6
%41 = phi i32* [ @EXIT_FAILURE, %6 ], [ @EXIT_FAILURE, %15 ], [ @EXIT_FAILURE, %22 ], [ @EXIT_FAILURE, %32 ], [ @EXIT_SUCCESS, %36 ]
%42 = load i32, i32* %41
ret i32 %42
}