#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*/ EXIT_FAILURE;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int open(char *, int /*<<< orphan*/);
int read(int, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    fprintf(stderr, "Usage: %s source target\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  FILE *inputfile, *outputfile;
  if ((inputfile = fopen(argv[1], "rb")) == NULL) {
    fprintf(stderr, "Failed to open file \"%s\"\n", argv[1]);
    exit(EXIT_FAILURE);
  }
  if ((outputfile = fopen(argv[2], "rb")) != NULL) {
    fprintf(stderr, "File \"%s\" existed\n", argv[2]);
    exit(EXIT_FAILURE);
  } else {
    fclose(outputfile);
    outputfile = fopen(argv[2], "wb");
  }
  fclose(outputfile);
  fclose(inputfile);
  int in, out;
  in = open(argv[1], O_RDONLY);
  out = open(argv[2], O_WRONLY);
  char c[1024 * 1024];
  int nread;
  while ((nread = read(in, c, 1024 * 1024)) > 0) {
    for (int i = 0; i < 1024 * 1024; i++)
      c[i] = ~c[i];
    write(out, c, nread);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100040,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11bd <main+0x4d>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe56(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    120a <main+0x9a>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe25(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe00(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1257 <main+0xe7>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdf2(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdda(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d4f(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2d0e(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x100030(%rbp),%rsi
mov    $0x100000,%edx
call   1050 <read@plt>
mov    %eax,-0x100034(%rbp)
cmp    $0x0,%eax
jle    1349 <main+0x1d9>
movl   $0x0,-0x100038(%rbp)
cmpl   $0x100000,-0x100038(%rbp)
jge    132f <main+0x1bf>
movslq -0x100038(%rbp),%rax
movsbl -0x100030(%rbp,%rax,1),%eax
ff
xor    $0xffffffff,%eax
mov    %al,%cl
movslq -0x100038(%rbp),%rax
mov    %cl,-0x100030(%rbp,%rax,1)
mov    -0x100038(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x100038(%rbp)
jmp    12e9 <main+0x179>
mov    -0x28(%rbp),%edi
lea    -0x100030(%rbp),%rsi
mov    -0x100034(%rbp),%edx
call   1030 <write@plt>
jmp    12bc <main+0x14c>
mov    -0x4(%rbp),%eax
add    $0x100040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x100008,%rsp
mov    %rsi,%r14
cmp    $0x3,%edi
jne    12bf <main+0x14f>
mov    0x8(%r14),%rdi
lea    0xe85(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12d4 <main+0x164>
mov    %rax,%rbx
mov    0x10(%r14),%rdi
lea    0xe69(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
jne    12ea <main+0x17a>
xor    %edi,%edi
call   1040 <fclose@plt>
mov    0x10(%r14),%rdi
lea    0xe79(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x8(%r14),%rdi
mov    0x2df8(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,%r15d
mov    0x10(%r14),%rdi
mov    0x2dbb(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,%ebp
mov    %rsp,%rsi
mov    %r15d,%edi
mov    $0x100000,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    12af <main+0x13f>
pcmpeqd %xmm2,%xmm2
mov    %rsp,%rbx
nopl   (%rax)
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movdqa (%rsp,%rcx,1),%xmm0
pxor   %xmm2,%xmm0
movdqa 0x10(%rsp,%rcx,1),%xmm1
pxor   %xmm2,%xmm1
movdqa %xmm0,(%rsp,%rcx,1)
movdqa %xmm1,0x10(%rsp,%rcx,1)
movdqa 0x20(%rsp,%rcx,1),%xmm0
pxor   %xmm2,%xmm0
movdqa 0x30(%rsp,%rcx,1),%xmm1
pxor   %xmm2,%xmm1
movdqa %xmm0,0x20(%rsp,%rcx,1)
movdqa %xmm1,0x30(%rsp,%rcx,1)
add    $0x40,%rcx
cmp    $0x100000,%rcx
jne    1240 <main+0xd0>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x100000,%edx
call   1050 <read@plt>
pcmpeqd %xmm2,%xmm2
test   %eax,%eax
jg     1230 <main+0xc0>
xor    %eax,%eax
add    $0x100008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xd2e(%rip),%rsi
jmp    12fe <main+0x18e>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xd34(%rip),%rsi
jmp    12fe <main+0x18e>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
mov    0x10(%r14),%rdx
lea    0xd38(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"Usage: %s source target\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [26 x i8] c"Failed to open file \22%s\22\0A\00"
@.str.3 = [19 x i8] c"File \22%s\22 existed\0A\00"
@.str.4 = [3 x i8] c"wb\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
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 [1048576 x i8]
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %23
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %6
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %37
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %23
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %41, i32** %7
%42 = icmp ne i32* %41, null
br i1 %42, label %43, label %51
43: ; preds = %37
%44 = load i32, i32* @stderr
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 2
%47 = load i8*, i8** %46
%48 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %47)
%49 = load i32, i32* @EXIT_FAILURE
%50 = call i32 @exit(i32 %49)
unreachable
51: ; preds = %37
%52 = load i32*, i32** %7
%53 = call i32 @fclose(i32* %52)
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 2
%56 = load i8*, i8** %55
%57 = call i32* @fopen(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %57, i32** %7
br label %58
58: ; preds = %51
%59 = load i32*, i32** %7
%60 = call i32 @fclose(i32* %59)
%61 = load i32*, i32** %6
%62 = call i32 @fclose(i32* %61)
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 1
%65 = load i8*, i8** %64
%66 = load i32, i32* @O_RDONLY
%67 = call i32 @open(i8* %65, i32 %66)
store i32 %67, i32* %8
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 2
%70 = load i8*, i8** %69
%71 = load i32, i32* @O_WRONLY
%72 = call i32 @open(i8* %70, i32 %71)
store i32 %72, i32* %9
br label %73
73: ; preds = %96, %58
%74 = load i32, i32* %8
%75 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %10, i64 0, i64 0
%76 = call i32 @read(i32 %74, i8* %75, i32 1048576)
store i32 %76, i32* %11
%77 = icmp sgt i32 %76, 0
br i1 %77, label %78, label %101
78: ; preds = %73
store i32 0, i32* %12
br label %79
79: ; preds = %93, %78
%80 = load i32, i32* %12
%81 = icmp slt i32 %80, 1048576
br i1 %81, label %82, label %96
82: ; preds = %79
%83 = load i32, i32* %12
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %10, i64 0, i64 %84
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = xor i32 %87, -1
%89 = trunc i32 %88 to i8
%90 = load i32, i32* %12
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %10, i64 0, i64 %91
store i8 %89, i8* %92
br label %93
93: ; preds = %82
%94 = load i32, i32* %12
%95 = add nsw i32 %94, 1
store i32 %95, i32* %12
br label %79
96: ; preds = %79
%97 = load i32, i32* %9
%98 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %10, i64 0, i64 0
%99 = load i32, i32* %11
%100 = call i32 @write(i32 %97, i8* %98, i32 %99)
br label %73
101: ; preds = %73
%102 = load i32, i32* %3
ret i32 %102
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Usage: %s source target\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [26 x i8] c"Failed to open file \22%s\22\0A\00"
@.str.3 = [19 x i8] c"File \22%s\22 existed\0A\00"
@.str.4 = [3 x i8] c"wb\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1048576 x i8]
%4 = icmp eq i32 %0, 3
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %22
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %12
%19 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %11
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = tail call i32* @fopen(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %33, label %27
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %23
%30 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
%32 = tail call i32 @exit(i32 %31)
unreachable
33: ; preds = %22
%34 = tail call i32 @fclose(i32* null)
%35 = load i8*, i8** %23
%36 = tail call i32* @fopen(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%37 = tail call i32 @fclose(i32* %36)
%38 = tail call i32 @fclose(i32* %14)
%39 = load i8*, i8** %12
%40 = load i32, i32* @O_RDONLY
%41 = tail call i32 @open(i8* %39, i32 %40)
%42 = load i8*, i8** %23
%43 = load i32, i32* @O_WRONLY
%44 = tail call i32 @open(i8* %42, i32 %43)
%45 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 0
%46 = call i32 @read(i32 %41, i8* %45, i32 1048576)
%47 = icmp sgt i32 %46, 0
br i1 %47, label %48, label %79
48: ; preds = %33, %75
%49 = phi i32 [ %77, %75 ], [ %46, %33 ]
br label %50
50: ; preds = %50, %48
%51 = phi i64 [ 0, %48 ], [ %73, %50 ]
%52 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 %51
%53 = bitcast i8* %52 to <16 x i8>*
%54 = load <16 x i8>, <16 x i8>* %53
%55 = getelementptr inbounds i8, i8* %52, i64 16
%56 = bitcast i8* %55 to <16 x i8>*
%57 = load <16 x i8>, <16 x i8>* %56
%58 = xor <16 x i8> %54, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
%59 = xor <16 x i8> %57, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
%60 = bitcast i8* %52 to <16 x i8>*
store <16 x i8> %58, <16 x i8>* %60
%61 = bitcast i8* %55 to <16 x i8>*
store <16 x i8> %59, <16 x i8>* %61
%62 = or i64 %51, 32
%63 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %3, i64 0, i64 %62
%64 = bitcast i8* %63 to <16 x i8>*
%65 = load <16 x i8>, <16 x i8>* %64
%66 = getelementptr inbounds i8, i8* %63, i64 16
%67 = bitcast i8* %66 to <16 x i8>*
%68 = load <16 x i8>, <16 x i8>* %67
%69 = xor <16 x i8> %65, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
%70 = xor <16 x i8> %68, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
%71 = bitcast i8* %63 to <16 x i8>*
store <16 x i8> %69, <16 x i8>* %71
%72 = bitcast i8* %66 to <16 x i8>*
store <16 x i8> %70, <16 x i8>* %72
%73 = add nuw nsw i64 %51, 64
%74 = icmp eq i64 %73, 1048576
br i1 %74, label %75, label %50
75: ; preds = %50
%76 = call i32 @write(i32 %44, i8* %45, i32 %49)
%77 = call i32 @read(i32 %41, i8* %45, i32 1048576)
%78 = icmp sgt i32 %77, 0
br i1 %78, label %48, label %79
79: ; preds = %75, %33
ret i32 0
}