#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(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  char *filename1;
  char *filename2;
  char *filename3;
  FILE *fp1;
  FILE *fp2;
  FILE *fp3;
  int n1;
  int n2;
  unsigned char c1;
  unsigned char c2;
  unsigned char c3;
  if (argc != 4)
    usage(argv[0]);
  filename1 = argv[1];
  filename2 = argv[2];
  filename3 = argv[3];
  fp1 = fopen(filename1, "rb");
  if (fp1 == NULL) {
    fprintf(stderr, "Couldn't open output file \"%s\" for read.\n", filename1);
    exit(1);
  }
  fp2 = fopen(filename2, "rb");
  if (fp2 == NULL) {
    fprintf(stderr, "Couldn't open output file \"%s\" for read.\n", filename2);
    fclose(fp1);
    exit(1);
  }
  fp3 = fopen(filename3, "wb");
  if (fp3 == NULL) {
    fprintf(stderr, "Couldn't open output file \"%s\" for write.\n", filename3);
    fclose(fp1);
    fclose(fp2);
    exit(1);
  }
  n1 = fread(&c1, 1, 1, fp1);
  n2 = fread(&c2, 1, 1, fp2);
  while ((n1 == 1) && (n2 == 1)) {
    c3 = c1 ^ c2;
    (void)fwrite(&c3, 1, 1, fp3);
    n1 = fread(&c1, 1, 1, fp1);
    n2 = fread(&c2, 1, 1, fp2);
  }
  fclose(fp1);
  fclose(fp2);
  fclose(fp3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     119c <main+0x2c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1202 <main+0x92>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe10(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x20(%rbp),%rdi
lea    0xdf3(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    124d <main+0xdd>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xdce(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x28(%rbp),%rdi
lea    0xdd5(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    12a1 <main+0x131>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xdb0(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x30(%rbp),%rcx
lea    -0x49(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%rcx
lea    -0x4a(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    %eax,-0x48(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x44(%rbp)
mov    %al,-0x4c(%rbp)
jne    12e8 <main+0x178>
cmpl   $0x1,-0x48(%rbp)
sete   %al
mov    %al,-0x4c(%rbp)
mov    -0x4c(%rbp),%al
test   $0x1,%al
jne    12f8 <main+0x188>
jmp    134c <main+0x1dc>
movzbl -0x49(%rbp),%eax
movzbl -0x4a(%rbp),%ecx
xor    %ecx,%eax
mov    %al,-0x4b(%rbp)
mov    -0x40(%rbp),%rcx
lea    -0x4b(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1090 <fwrite@plt>
mov    -0x30(%rbp),%rcx
lea    -0x49(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%rcx
lea    -0x4a(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    %eax,-0x48(%rbp)
jmp    12cf <main+0x15f>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x4,%edi
je     118b <main+0x1b>
mov    (%rbx),%rdi
call   1070 <usage@plt>
mov    0x8(%rbx),%r15
mov    0x10(%rbx),%r13
mov    0x18(%rbx),%r12
lea    0xe62(%rip),%rsi
mov    %r15,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     12a3 <main+0x133>
mov    %rax,%r14
lea    0xe47(%rip),%rsi
mov    %r13,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     12c5 <main+0x155>
mov    %rax,%r15
lea    0xe59(%rip),%rsi
mov    %r12,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     12e2 <main+0x172>
mov    %rax,%rbx
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
mov    %eax,%ebp
lea    0x6(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmp    $0x1,%ebp
jne    127a <main+0x10a>
cmp    $0x1,%eax
jne    127a <main+0x10a>
lea    0x7(%rsp),%r12
lea    0x6(%rsp),%r13
nopl   0x0(%rax)
movzbl 0x6(%rsp),%eax
xor    0x7(%rsp),%al
movsbl %al,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
mov    %eax,%ebp
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmp    $0x1,%ebp
jne    127a <main+0x10a>
cmp    $0x1,%eax
je     1230 <main+0xc0>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
lea    0xd50(%rip),%rsi
mov    %r15,%rdx
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
lea    0xd2e(%rip),%rsi
mov    %r13,%rdx
call   1060 <fprintf@plt>
mov    %r14,%rdi
jmp    1305 <main+0x195>
mov    0x2cf7(%rip),%rax
mov    (%rax),%edi
lea    0xd3e(%rip),%rsi
mov    %r12,%rdx
call   1060 <fprintf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [42 x i8] c"Couldn't open output file \22%s\22 for read.\0A\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [43 x i8] c"Couldn't open output file \22%s\22 for write.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca i8
%5 = icmp eq i32 %0, 4
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @usage(i8* %7)
br label %9
9: ; preds = %6, %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %22
18: ; preds = %9
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %9
%23 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%28 = tail call i32 @fclose(i32* %16)
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %22
%31 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* @stderr
%35 = tail call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%36 = tail call i32 @fclose(i32* %16)
%37 = tail call i32 @fclose(i32* %23)
%38 = tail call i32 @exit(i32 1)
unreachable
39: ; preds = %30
%40 = call i32 @fread(i8* %3, i32 1, i32 1, i32* %16)
%41 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %23)
%42 = icmp eq i32 %40, 1
%43 = icmp eq i32 %41, 1
%44 = and i1 %42, %43
br i1 %44, label %45, label %56
45: ; preds = %39, %45
%46 = load i8, i8* %3
%47 = load i8, i8* %4
%48 = xor i8 %47, %46
%49 = sext i8 %48 to i32
%50 = tail call i32 @fputc(i32 %49, i32* %31)
%51 = call i32 @fread(i8* %3, i32 1, i32 1, i32* %16)
%52 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %23)
%53 = icmp eq i32 %51, 1
%54 = icmp eq i32 %52, 1
%55 = and i1 %53, %54
br i1 %55, label %45, label %56
56: ; preds = %45, %39
%57 = tail call i32 @fclose(i32* %16)
%58 = tail call i32 @fclose(i32* %23)
%59 = tail call i32 @fclose(i32* %31)
ret i32 0
}