#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  FILE *in, *in2;
  FILE *out;
  int i = 0, j = 0, val, val2;
  if (argc != 4) {
    printf("Usage: fxor inputfile1 inputfile2 outfile\n");
    return -1;
  }
  if ((in = fopen(argv[1], "rb")) == NULL) {
    printf("Cant't open file name %s\n", argv[1]);
    return -1;
  }
  if ((in2 = fopen(argv[2], "rb")) == NULL) {
    printf("Cant't open file name %s\n", argv[2]);
    return -1;
  }
  if ((out = fopen(argv[3], "wb")) == NULL) {
    printf("Cant't open file name %s\n", argv[3]);
    fclose(in);
    return -1;
  }
  while ((val = fgetc(in)) != EOF) {
    val2 = fgetc(in2);
    fputc(val ^ val2, out);
  }
  fclose(out);
  fclose(in);
  fclose(in2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1198 <main+0x48>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12cf <main+0x17f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe84(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11dc <main+0x8c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12cf <main+0x17f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe40(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1220 <main+0xd0>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12cf <main+0x17f>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe19(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    126d <main+0x11d>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12cf <main+0x17f>
jmp    1272 <main+0x122>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x34(%rbp)
mov    0x2d63(%rip),%rcx
cmp    (%rcx),%eax
je     12ad <main+0x15d>
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%edi
xor    -0x38(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1060 <fputc@plt>
jmp    1272 <main+0x122>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x4,%edi
jne    1230 <main+0xd0>
mov    %rsi,%r12
mov    0x8(%rsi),%rdi
lea    0xe81(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     123e <main+0xde>
mov    %rax,%r14
mov    0x10(%r12),%rdi
lea    0xe64(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1245 <main+0xe5>
mov    %rax,%r15
mov    0x18(%r12),%rdi
lea    0xe64(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     125a <main+0xfa>
mov    %rax,%rbx
mov    %r14,%rdi
call   1060 <fgetc@plt>
mov    0x2e0f(%rip),%r12
cmp    (%r12),%eax
je     1214 <main+0xb4>
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1060 <fgetc@plt>
xor    %eax,%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <fputc@plt>
mov    %r14,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebp
cmp    (%r12),%eax
jne    11f0 <main+0x90>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    127a <main+0x11a>
lea    0xde9(%rip),%rdi
call   1030 <puts@plt>
jmp    1275 <main+0x115>
mov    0x8(%r12),%rsi
jmp    124a <main+0xea>
mov    0x10(%r12),%rsi
lea    0xdb2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1275 <main+0x115>
mov    0x18(%r12),%rsi
lea    0xd9d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Usage: fxor inputfile1 inputfile2 outfile\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [26 x i8] c"Cant't open file name %s\0A\00"
@.str.3 = [3 x i8] c"wb\00"
@EOF = 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 i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
store i32 0, i32* %10
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 4
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %73
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 = icmp eq i32* %21, null
br i1 %22, label %23, label %28
23: ; preds = %17
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %26)
store i32 -1, i32* %3
br label %73
28: ; preds = %17
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %32, i32** %7
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %39
34: ; preds = %28
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %37)
store i32 -1, i32* %3
br label %73
39: ; preds = %28
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 3
%42 = load i8*, i8** %41
%43 = call i32* @fopen(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %43, i32** %8
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %52
45: ; preds = %39
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 3
%48 = load i8*, i8** %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %48)
%50 = load i32*, i32** %6
%51 = call i32 @fclose(i32* %50)
store i32 -1, i32* %3
br label %73
52: ; preds = %39
br label %53
53: ; preds = %58, %52
%54 = load i32*, i32** %6
%55 = call i32 @fgetc(i32* %54)
store i32 %55, i32* %11
%56 = load i32, i32* @EOF
%57 = icmp ne i32 %55, %56
br i1 %57, label %58, label %66
58: ; preds = %53
%59 = load i32*, i32** %7
%60 = call i32 @fgetc(i32* %59)
store i32 %60, i32* %12
%61 = load i32, i32* %11
%62 = load i32, i32* %12
%63 = xor i32 %61, %62
%64 = load i32*, i32** %8
%65 = call i32 @fputc(i32 %63, i32* %64)
br label %53
66: ; preds = %53
%67 = load i32*, i32** %8
%68 = call i32 @fclose(i32* %67)
%69 = load i32*, i32** %6
%70 = call i32 @fclose(i32* %69)
%71 = load i32*, i32** %7
%72 = call i32 @fclose(i32* %71)
store i32 0, i32* %3
br label %73
73: ; preds = %66, %45, %34, %23, %15
%74 = load i32, i32* %3
ret i32 %74
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [26 x i8] c"Cant't open file name %s\0A\00"
@.str.3 = [3 x i8] c"wb\00"
@EOF = global i32 0
@str = [42 x i8] c"Usage: fxor inputfile1 inputfile2 outfile\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
br label %47
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i8*, i8** %7
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %47
14: ; preds = %6
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%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 %22
19: ; preds = %14
%20 = load i8*, i8** %15
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %47
22: ; preds = %14
%23 = getelementptr inbounds i8*, i8** %1, i64 3
%24 = load i8*, i8** %23
%25 = tail call i32* @fopen(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %31, label %27
27: ; preds = %22
%28 = tail call i32 @fgetc(i32* %9)
%29 = load i32, i32* @EOF
%30 = icmp eq i32 %28, %29
br i1 %30, label %43, label %35
31: ; preds = %22
%32 = load i8*, i8** %23
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = tail call i32 @fclose(i32* %9)
br label %47
35: ; preds = %27, %35
%36 = phi i32 [ %40, %35 ], [ %28, %27 ]
%37 = tail call i32 @fgetc(i32* %17)
%38 = xor i32 %37, %36
%39 = tail call i32 @fputc(i32 %38, i32* %25)
%40 = tail call i32 @fgetc(i32* %9)
%41 = load i32, i32* @EOF
%42 = icmp eq i32 %40, %41
br i1 %42, label %43, label %35
43: ; preds = %35, %27
%44 = tail call i32 @fclose(i32* %25)
%45 = tail call i32 @fclose(i32* %9)
%46 = tail call i32 @fclose(i32* %17)
br label %47
47: ; preds = %43, %31, %19, %11, %4
%48 = phi i32 [ -1, %4 ], [ -1, %11 ], [ -1, %19 ], [ -1, %31 ], [ 0, %43 ]
ret i32 %48
}