#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  FILE *eins, *zwei;
  int a, b, i = 0, flag = 0;
  if (argv[1] == NULL || argv[2] == NULL) {
    printf("Usage: %s file1 file2\n  %s compares two files.\n", argv[0],
           argv[0]);
    return 0;
  }
  eins = fopen(argv[1], "r");
  zwei = fopen(argv[2], "r");
  if (eins == NULL) {
    printf("File %s not found or unreadable.\n", argv[1]);
    return 0;
  }
  if (zwei == NULL) {
    printf("File %s not found or unreadable.\n", argv[2]);
    fclose(eins);
    return 0;
  }
  while (!feof(eins)) {
    a = fgetc(eins);
    b = fgetc(zwei);
    if (flag == 0 && (a == -1 || b == -1) && (a != -1 || b != -1)) {
      printf("One file ended. Printing the rest of the other.\n");
      flag = 1;
    }
    if (a != b)
      printf("0x%06x: 0x%02x -> 0x%02x\n", i, a, b);
    i++;
  }
  fclose(eins);
  fclose(zwei);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1192 <main+0x42>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
jne    11ba <main+0x6a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1319 <main+0x1c9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe67(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe4f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1217 <main+0xc7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1319 <main+0x1c9>
cmpq   $0x0,-0x20(%rbp)
jne    124d <main+0xfd>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    1319 <main+0x1c9>
jmp    1252 <main+0x102>
mov    -0x18(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1270 <main+0x120>
jmp    1300 <main+0x1b0>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x30(%rbp)
jne    12cf <main+0x17f>
cmpl   $0xffffffff,-0x24(%rbp)
je     12a6 <main+0x156>
cmpl   $0xffffffff,-0x28(%rbp)
jne    12cf <main+0x17f>
cmpl   $0xffffffff,-0x24(%rbp)
jne    12ba <main+0x16a>
cmpl   $0xffffffff,-0x28(%rbp)
je     12cf <main+0x17f>
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x30(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
je     12f2 <main+0x1a2>
mov    -0x2c(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1252 <main+0x102>
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    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     11c5 <main+0x65>
cmpq   $0x0,0x10(%r14)
je     11c5 <main+0x65>
lea    0xea8(%rip),%rbx
mov    %rbx,%rsi
call   1080 <fopen@plt>
mov    %rax,%rbp
mov    0x10(%r14),%rdi
mov    %rbx,%rsi
call   1080 <fopen@plt>
test   %rbp,%rbp
je     11db <main+0x7b>
mov    %rax,%rbx
test   %rax,%rax
je     11ef <main+0x8f>
mov    %rbp,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     121a <main+0xba>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
jmp    1204 <main+0xa4>
mov    (%r14),%rdx
lea    0xe31(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1209 <main+0xa9>
mov    0x8(%r14),%rsi
lea    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1209 <main+0xa9>
mov    0x10(%r14),%rsi
lea    0xe38(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r12d,%r12d
xor    %r14d,%r14d
mov    %rbx,0x10(%rsp)
mov    %rbp,0x8(%rsp)
jmp    124e <main+0xee>
nopl   0x0(%rax)
add    $0x1,%r14d
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   1070 <feof@plt>
test   %eax,%eax
mov    0x10(%rsp),%rbx
jne    11b8 <main+0x58>
mov    %rbp,%rdi
call   1060 <fgetc@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    %eax,%r15d
test   %r12d,%r12d
jne    1295 <main+0x135>
cmp    $0xffffffff,%r13d
setne  %al
cmp    $0xffffffff,%r15d
setne  %cl
xor    %r12d,%r12d
test   %cl,%al
jne    129b <main+0x13b>
mov    %r15d,%eax
and    %r13d,%eax
cmp    $0xffffffff,%eax
je     129b <main+0x13b>
lea    0xdde(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r12d
cmp    %r15d,%r13d
je     1230 <main+0xd0>
lea    0xdad(%rip),%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1230 <main+0xd0>

LLVM IR (-O0):
@.str = [48 x i8] c"Usage: %s file1 file2\0A %s compares two files.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [34 x i8] c"File %s not found or unreadable.\0A\00"
@.str.3 = [49 x i8] c"One file ended. Printing the rest of the other.\0A\00"
@.str.4 = [26 x i8] c"0x%06x: 0x%02x -> 0x%02x\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 i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
store i32 0, i32* %11
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = icmp eq i8* %14, null
br i1 %15, label %21, label %16
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %29
21: ; preds = %16, %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %24, i8* %27)
store i32 0, i32* %3
br label %99
29: ; preds = %16
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %33, i32** %6
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %37, i32** %7
%38 = load i32*, i32** %6
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %45
40: ; preds = %29
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %43)
store i32 0, i32* %3
br label %99
45: ; preds = %29
%46 = load i32*, i32** %7
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %55
48: ; preds = %45
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %51)
%53 = load i32*, i32** %6
%54 = call i32 @fclose(i32* %53)
store i32 0, i32* %3
br label %99
55: ; preds = %45
br label %56
56: ; preds = %91, %55
%57 = load i32*, i32** %6
%58 = call i32 @feof(i32* %57)
%59 = icmp ne i32 %58, 0
%60 = xor i1 %59, true
br i1 %60, label %61, label %94
61: ; preds = %56
%62 = load i32*, i32** %6
%63 = call i32 @fgetc(i32* %62)
store i32 %63, i32* %8
%64 = load i32*, i32** %7
%65 = call i32 @fgetc(i32* %64)
store i32 %65, i32* %9
%66 = load i32, i32* %11
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %82
68: ; preds = %61
%69 = load i32, i32* %8
%70 = icmp eq i32 %69, -1
br i1 %70, label %74, label %71
71: ; preds = %68
%72 = load i32, i32* %9
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %82
74: ; preds = %71, %68
%75 = load i32, i32* %8
%76 = icmp ne i32 %75, -1
br i1 %76, label %80, label %77
77: ; preds = %74
%78 = load i32, i32* %9
%79 = icmp ne i32 %78, -1
br i1 %79, label %80, label %82
80: ; preds = %77, %74
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %11
br label %82
82: ; preds = %80, %77, %71, %61
%83 = load i32, i32* %8
%84 = load i32, i32* %9
%85 = icmp ne i32 %83, %84
br i1 %85, label %86, label %91
86: ; preds = %82
%87 = load i32, i32* %10
%88 = load i32, i32* %8
%89 = load i32, i32* %9
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %87, i32 %88, i32 %89)
br label %91
91: ; preds = %86, %82
%92 = load i32, i32* %10
%93 = add nsw i32 %92, 1
store i32 %93, i32* %10
br label %56
94: ; preds = %56
%95 = load i32*, i32** %6
%96 = call i32 @fclose(i32* %95)
%97 = load i32*, i32** %7
%98 = call i32 @fclose(i32* %97)
store i32 0, i32* %3
br label %99
99: ; preds = %94, %48, %40, %21
%100 = load i32, i32* %3
ret i32 %100
}

LLVM IR (-O2):
@.str = [48 x i8] c"Usage: %s file1 file2\0A %s compares two files.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [34 x i8] c"File %s not found or unreadable.\0A\00"
@.str.4 = [26 x i8] c"0x%06x: 0x%02x -> 0x%02x\0A\00"
@str = [48 x i8] c"One file ended. Printing the rest of the other.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %6, %2
%11 = load i8*, i8** %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %11)
br label %57
13: ; preds = %6
%14 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = load i8*, i8** %7
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %14, null
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %57
21: ; preds = %13
%22 = icmp eq i32* %16, null
br i1 %22, label %26, label %23
23: ; preds = %21
%24 = tail call i32 @feof(i32* %14)
%25 = icmp eq i32 %24, 0
br i1 %25, label %30, label %54
26: ; preds = %21
%27 = load i8*, i8** %7
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = tail call i32 @fclose(i32* %14)
br label %57
30: ; preds = %23, %50
%31 = phi i32 [ %46, %50 ], [ 0, %23 ]
%32 = phi i32 [ %51, %50 ], [ 0, %23 ]
%33 = tail call i32 @fgetc(i32* %14)
%34 = tail call i32 @fgetc(i32* %16)
%35 = icmp eq i32 %31, 0
br i1 %35, label %36, label %45
36: ; preds = %30
%37 = icmp ne i32 %33, -1
%38 = icmp ne i32 %34, -1
%39 = and i1 %37, %38
%40 = and i32 %34, %33
%41 = icmp eq i32 %40, -1
%42 = or i1 %39, %41
br i1 %42, label %45, label %43
43: ; preds = %36
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
br label %45
45: ; preds = %36, %43, %30
%46 = phi i32 [ 1, %43 ], [ 0, %36 ], [ 1, %30 ]
%47 = icmp eq i32 %33, %34
br i1 %47, label %50, label %48
48: ; preds = %45
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %32, i32 %33, i32 %34)
br label %50
50: ; preds = %48, %45
%51 = add nuw nsw i32 %32, 1
%52 = tail call i32 @feof(i32* %14)
%53 = icmp eq i32 %52, 0
br i1 %53, label %30, label %54
54: ; preds = %50, %23
%55 = tail call i32 @fclose(i32* %14)
%56 = tail call i32 @fclose(i32* %16)
br label %57
57: ; preds = %54, %26, %18, %10
ret i32 0
}