#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 */

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int read(int, unsigned char *, int);
int main(int argc, char *argv[]) {
  int fp1 = 0;
  int fp2 = 0;
  int ret1 = 0;
  int ret2 = 0;
  int i = 0;
  unsigned char buf1[50];
  unsigned char buf2[50];
  long long address = 0LL;
  if (argc != 3) {
    printf("\nUsage: fcomp file_name1 file_name2\n\n");
    return 1;
  }
  fp1 = open(argv[1], O_RDONLY);
  if (fp1 <= 0) {
    printf("\nUnable to open file1 \"%s\"\n", argv[1]);
    return 2;
  }
  fp2 = open(argv[2], O_RDONLY);
  if (fp2 <= 0) {
    printf("\nUnable to open file2 \"%s\"\n", argv[2]);
    return 3;
  }
  printf("\nfcomp\n\n");
  printf("Address           F1 F2\n");
  ret1 = read(fp1, buf1, 1);
  ret2 = read(fp2, buf2, 1);
  while (ret1 == 1 && ret2 == 1) {
    if (buf1[0] != buf2[0]) {
      printf("\n");
      printf("%016llx  ", address);
      printf("%02x ", buf1[0]);
      printf("%02x", buf2[0]);
    }
    ret1 = read(fp1, buf1, 1);
    ret2 = read(fp2, buf2, 1);
    address++;
  }
  if ((ret1 != 1 && ret2 == 1) || (ret1 == 1 && ret2 != 1)) {
    printf("\n\nFiles are different sizes!!!!\n\n");
  }
  printf("\n\n");
  close(fp1);
  close(fp2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0xa8(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11ab <main+0x6b>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13a1 <main+0x261>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e2e(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     11f0 <main+0xb0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    13a1 <main+0x261>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jg     1235 <main+0xf5>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    13a1 <main+0x261>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
mov    %eax,-0x20(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x1c(%rbp)
mov    %al,-0xa9(%rbp)
jne    129b <main+0x15b>
cmpl   $0x1,-0x20(%rbp)
sete   %al
mov    %al,-0xa9(%rbp)
mov    -0xa9(%rbp),%al
test   $0x1,%al
jne    12ae <main+0x16e>
jmp    134d <main+0x20d>
movzbl -0x60(%rbp),%eax
movzbl -0xa0(%rbp),%ecx
cmp    %ecx,%eax
je     130b <main+0x1cb>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xa8(%rbp),%rsi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzbl -0x60(%rbp),%esi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzbl -0xa0(%rbp),%esi
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
mov    %eax,-0x20(%rbp)
mov    -0xa8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xa8(%rbp)
jmp    127c <main+0x13c>
cmpl   $0x1,-0x1c(%rbp)
je     1361 <main+0x221>
cmpl   $0x1,-0x20(%rbp)
je     1375 <main+0x235>
cmpl   $0x1,-0x1c(%rbp)
jne    1383 <main+0x243>
cmpl   $0x1,-0x20(%rbp)
je     1383 <main+0x243>
lea    0xd19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    -0x18(%rbp),%edi
call   1040 <close@plt>
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
cmp    $0x3,%edi
jne    12db <main+0x17b>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
mov    0x2e63(%rip),%rbx
mov    (%rbx),%esi
call   1080 <open@plt>
test   %eax,%eax
jle    12ee <main+0x18e>
mov    %eax,%r15d
mov    0x10(%rbp),%rdi
mov    (%rbx),%esi
call   1080 <open@plt>
test   %eax,%eax
jle    1307 <main+0x1a7>
mov    %eax,%r14d
lea    0xe99(%rip),%rdi
call   1040 <puts@plt>
lea    0xe95(%rip),%rdi
call   1040 <puts@plt>
lea    0x40(%rsp),%rsi
mov    %r15d,%edi
mov    $0x1,%edx
call   1070 <read@plt>
mov    %eax,%r12d
mov    %rsp,%rsi
mov    %r14d,%edi
mov    $0x1,%edx
call   1070 <read@plt>
cmp    $0x1,%eax
sete   %dl
cmp    $0x1,%r12d
sete   %cl
jne    129a <main+0x13a>
cmp    $0x1,%eax
jne    129a <main+0x13a>
xor    %r13d,%r13d
nopl   0x0(%rax)
movzbl 0x40(%rsp),%ebx
movzbl (%rsp),%ebp
cmp    %bpl,%bl
je     1259 <main+0xf9>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe09(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe02(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdf8(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15d,%edi
lea    0x40(%rsp),%rsi
mov    $0x1,%edx
call   1070 <read@plt>
mov    %eax,%r12d
mov    %r14d,%edi
mov    %rsp,%rsi
mov    $0x1,%edx
call   1070 <read@plt>
cmp    $0x1,%eax
sete   %dl
cmp    $0x1,%r12d
sete   %cl
jne    129a <main+0x13a>
add    $0x1,%r13
cmp    $0x1,%eax
je     1210 <main+0xb0>
cmp    $0x1,%r12d
setne  %bl
cmp    $0x1,%eax
setne  %al
test   %dl,%bl
jne    12af <main+0x14f>
and    %al,%cl
je     12bb <main+0x15b>
lea    0xdb7(%rip),%rdi
call   1040 <puts@plt>
lea    0xdca(%rip),%rdi
call   1040 <puts@plt>
mov    %r15d,%edi
call   1060 <close@plt>
mov    %r14d,%edi
call   1060 <close@plt>
xor    %eax,%eax
jmp    131e <main+0x1be>
lea    0xdac(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    131e <main+0x1be>
mov    0x8(%rbp),%rsi
lea    0xd07(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2,%eax
jmp    131e <main+0x1be>
mov    0x10(%rbp),%rsi
lea    0xd0a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x3,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"\0AUsage: fcomp file_name1 file_name2\0A\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [28 x i8] c"\0AUnable to open file1 \22%s\22\0A\00"
@.str.2 = [28 x i8] c"\0AUnable to open file2 \22%s\22\0A\00"
@.str.3 = [9 x i8] c"\0Afcomp\0A\0A\00"
@.str.4 = [25 x i8] c"Address F1 F2\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [10 x i8] c"%016llx \00"
@.str.7 = [6 x i8] c"%02x \00"
@.str.8 = [5 x i8] c"%02x\00"
@.str.9 = [34 x i8] c"\0A\0AFiles are different sizes!!!!\0A\0A\00"
@.str.10 = [3 x i8] c"\0A\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 [50 x i8]
%12 = alloca [50 x i8]
%13 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i64 0, i64* %13
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 3
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %110
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = load i32, i32* @O_RDONLY
%23 = call i32 @open(i8* %21, i32 %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = icmp sle i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %18
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %29)
store i32 2, i32* %3
br label %110
31: ; preds = %18
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = load i32, i32* @O_RDONLY
%36 = call i32 @open(i8* %34, i32 %35)
store i32 %36, i32* %7
%37 = load i32, i32* %7
%38 = icmp sle i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %31
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %42)
store i32 3, i32* %3
br label %110
44: ; preds = %31
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%47 = load i32, i32* %6
%48 = getelementptr inbounds [50 x i8], [50 x i8]* %11, i64 0, i64 0
%49 = call i32 @read(i32 %47, i8* %48, i32 1)
store i32 %49, i32* %8
%50 = load i32, i32* %7
%51 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
%52 = call i32 @read(i32 %50, i8* %51, i32 1)
store i32 %52, i32* %9
br label %53
53: ; preds = %81, %44
%54 = load i32, i32* %8
%55 = icmp eq i32 %54, 1
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = load i32, i32* %9
%58 = icmp eq i32 %57, 1
br label %59
59: ; preds = %56, %53
%60 = phi i1 [ false, %53 ], [ %58, %56 ]
br i1 %60, label %61, label %90
61: ; preds = %59
%62 = getelementptr inbounds [50 x i8], [50 x i8]* %11, i64 0, i64 0
%63 = load i8, i8* %62
%64 = zext i8 %63 to i32
%65 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
%66 = load i8, i8* %65
%67 = zext i8 %66 to i32
%68 = icmp ne i32 %64, %67
br i1 %68, label %69, label %81
69: ; preds = %61
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%71 = load i64, i64* %13
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i64 %71)
%73 = getelementptr inbounds [50 x i8], [50 x i8]* %11, i64 0, i64 0
%74 = load i8, i8* %73
%75 = zext i8 %74 to i32
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %75)
%77 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %79)
br label %81
81: ; preds = %69, %61
%82 = load i32, i32* %6
%83 = getelementptr inbounds [50 x i8], [50 x i8]* %11, i64 0, i64 0
%84 = call i32 @read(i32 %82, i8* %83, i32 1)
store i32 %84, i32* %8
%85 = load i32, i32* %7
%86 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
%87 = call i32 @read(i32 %85, i8* %86, i32 1)
store i32 %87, i32* %9
%88 = load i64, i64* %13
%89 = add nsw i64 %88, 1
store i64 %89, i64* %13
br label %53
90: ; preds = %59
%91 = load i32, i32* %8
%92 = icmp ne i32 %91, 1
br i1 %92, label %93, label %96
93: ; preds = %90
%94 = load i32, i32* %9
%95 = icmp eq i32 %94, 1
br i1 %95, label %102, label %96
96: ; preds = %93, %90
%97 = load i32, i32* %8
%98 = icmp eq i32 %97, 1
br i1 %98, label %99, label %104
99: ; preds = %96
%100 = load i32, i32* %9
%101 = icmp ne i32 %100, 1
br i1 %101, label %102, label %104
102: ; preds = %99, %93
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
br label %104
104: ; preds = %102, %99, %96
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%106 = load i32, i32* %6
%107 = call i32 @close(i32 %106)
%108 = load i32, i32* %7
%109 = call i32 @close(i32 %108)
br label %110
110: ; preds = %104, %39, %26, %16
%111 = load i32, i32* %3
ret i32 %111
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str.1 = [28 x i8] c"\0AUnable to open file1 \22%s\22\0A\00"
@.str.2 = [28 x i8] c"\0AUnable to open file2 \22%s\22\0A\00"
@.str.6 = [10 x i8] c"%016llx \00"
@.str.7 = [6 x i8] c"%02x \00"
@.str.8 = [5 x i8] c"%02x\00"
@str = [8 x i8] c"\0Afcomp\0A\00"
@str.11 = [24 x i8] c"Address F1 F2\00"
@str.12 = [2 x i8] c"\0A\00"
@str.13 = [33 x i8] c"\0A\0AFiles are different sizes!!!!\0A\00"
@str.14 = [37 x i8] c"\0AUsage: fcomp file_name1 file_name2\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 3
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.14, i64 0, i64 0))
br label %71
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = load i32, i32* @O_RDONLY
%14 = tail call i32 @open(i8* %12, i32 %13)
%15 = icmp slt i32 %14, 1
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load i8*, i8** %11
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %71
19: ; preds = %10
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = load i32, i32* @O_RDONLY
%23 = tail call i32 @open(i8* %21, i32 %22)
%24 = icmp slt i32 %23, 1
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = load i8*, i8** %20
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %71
28: ; preds = %19
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.11, i64 0, i64 0))
%31 = call i32 @read(i32 %14, i8* %5, i32 1)
%32 = call i32 @read(i32 %23, i8* %6, i32 1)
%33 = icmp eq i32 %31, 1
%34 = icmp eq i32 %32, 1
%35 = and i1 %33, %34
br i1 %35, label %36, label %55
36: ; preds = %28, %48
%37 = phi i64 [ %51, %48 ], [ 0, %28 ]
%38 = load i8, i8* %5
%39 = load i8, i8* %6
%40 = icmp eq i8 %38, %39
br i1 %40, label %48, label %41
41: ; preds = %36
%42 = tail call i32 @putchar(i32 10)
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i64 %37)
%44 = zext i8 %38 to i32
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %44)
%46 = zext i8 %39 to i32
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %41, %36
%49 = call i32 @read(i32 %14, i8* %5, i32 1)
%50 = call i32 @read(i32 %23, i8* %6, i32 1)
%51 = add nuw nsw i64 %37, 1
%52 = icmp eq i32 %49, 1
%53 = icmp eq i32 %50, 1
%54 = and i1 %52, %53
br i1 %54, label %36, label %55
55: ; preds = %48, %28
%56 = phi i32 [ %31, %28 ], [ %49, %48 ]
%57 = phi i32 [ %32, %28 ], [ %50, %48 ]
%58 = phi i1 [ %33, %28 ], [ %52, %48 ]
%59 = phi i1 [ %34, %28 ], [ %53, %48 ]
%60 = icmp ne i32 %56, 1
%61 = and i1 %60, %59
%62 = icmp ne i32 %57, 1
%63 = and i1 %58, %62
%64 = or i1 %61, %63
br i1 %64, label %65, label %67
65: ; preds = %55
%66 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.13, i64 0, i64 0))
br label %67
67: ; preds = %55, %65
%68 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.12, i64 0, i64 0))
%69 = tail call i32 @close(i32 %14)
%70 = tail call i32 @close(i32 %23)
br label %71
71: ; preds = %67, %25, %16, %8
%72 = phi i32 [ 1, %8 ], [ 2, %16 ], [ 3, %25 ], [ 0, %67 ]
ret i32 %72
}