#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  FILE *fileOne;
  FILE *fileTwo;
  int testOne;
  int testTwo;
  if (argc != 3)
    printf("\nIncorrect Number of Parameters Entered.\nCorrect Usage: "
           "fileCompare.exe fileNameOne.txt fileNameTwo.txt\n");
  else {
    fileOne = fopen(argv[1], "r");
    if (fileOne == NULL) {
      printf("Cannot open fileOne for reading \n");
      exit(1);
    }
    fileTwo = fopen(argv[2], "r");
    if (fileTwo == NULL) {
      printf("Cannot open fileTwo for reading \n");
      exit(1);
    } else {
      testOne = getc(fileOne);
      testTwo = getc(fileTwo);
      while ((testOne != EOF) && (testTwo != EOF) && (testOne == testTwo)) {
        testOne = getc(fileOne);
        testTwo = getc(fileTwo);
      }
      if (testOne == testTwo)
        printf("\nFiles are identical\n");
      else if (testOne != testTwo)
        printf("\nFiles are not identical\n");
    }
    fclose(fileOne);
    fclose(fileTwo);
  }
  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)
cmpl   $0x3,-0x8(%rbp)
je     1181 <main+0x31>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
jmp    12c3 <main+0x173>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xed9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ba <main+0x6a>
lea    0xec0(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xea0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11f3 <main+0xa3>
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%ecx
xor    %eax,%eax
mov    0x2dd1(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x29(%rbp)
je     1245 <main+0xf5>
mov    -0x28(%rbp),%ecx
xor    %eax,%eax
mov    0x2dba(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x29(%rbp)
je     1245 <main+0xf5>
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1255 <main+0x105>
jmp    1272 <main+0x122>
mov    -0x18(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x28(%rbp)
jmp    120b <main+0xbb>
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jne    128f <main+0x13f>
lea    0xe2a(%rip),%rdi
call   1040 <printf@plt>
jmp    12ac <main+0x15c>
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
je     12a7 <main+0x157>
lea    0xe23(%rip),%rdi
call   1040 <printf@plt>
jmp    12ac <main+0x15c>
jmp    12b1 <main+0x161>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    120f <main+0xbf>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe92(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1228 <main+0xd8>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe76(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1231 <main+0xe1>
mov    %rax,%rbx
mov    %r14,%rdi
call   1070 <getc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1070 <getc@plt>
cmp    %eax,%ebp
sete   %cl
jne    11e4 <main+0x94>
mov    0x2e2d(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    (%r15),%edx
cmp    %edx,%ebp
je     11e4 <main+0x94>
cmp    %edx,%eax
je     11e4 <main+0x94>
mov    %r14,%rdi
call   1070 <getc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1070 <getc@plt>
cmp    %eax,%ebp
sete   %cl
je     11c0 <main+0x70>
lea    0xe30(%rip),%rax
lea    0xe10(%rip),%rdi
test   %cl,%cl
cmovne %rax,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    121b <main+0xcb>
lea    0xe5c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe22(%rip),%rdi
jmp    1238 <main+0xe8>
lea    0xdf8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [105 x i8] c"\0AIncorrect Number of Parameters Entered.\0ACorrect Usage: fileCompare.exe fileNameOne.txt fileNameTwo.txt\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [34 x i8] c"Cannot open fileOne for reading \0A\00"
@.str.3 = [34 x i8] c"Cannot open fileTwo for reading \0A\00"
@EOF = global i32 0
@.str.4 = [22 x i8] c"\0AFiles are identical\0A\00"
@.str.5 = [26 x i8] c"\0AFiles are not identical\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([105 x i8], [105 x i8]* @.str, i64 0, i64 0))
br label %77
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %6
%19 = load i32*, i32** %6
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %14
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %7
%29 = load i32*, i32** %7
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %34
31: ; preds = %24
%32 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %24
%35 = load i32*, i32** %6
%36 = call i32 @getc(i32* %35)
store i32 %36, i32* %8
%37 = load i32*, i32** %7
%38 = call i32 @getc(i32* %37)
store i32 %38, i32* %9
br label %39
39: ; preds = %53, %34
%40 = load i32, i32* %8
%41 = load i32, i32* @EOF
%42 = icmp ne i32 %40, %41
br i1 %42, label %43, label %51
43: ; preds = %39
%44 = load i32, i32* %9
%45 = load i32, i32* @EOF
%46 = icmp ne i32 %44, %45
br i1 %46, label %47, label %51
47: ; preds = %43
%48 = load i32, i32* %8
%49 = load i32, i32* %9
%50 = icmp eq i32 %48, %49
br label %51
51: ; preds = %47, %43, %39
%52 = phi i1 [ false, %43 ], [ false, %39 ], [ %50, %47 ]
br i1 %52, label %53, label %58
53: ; preds = %51
%54 = load i32*, i32** %6
%55 = call i32 @getc(i32* %54)
store i32 %55, i32* %8
%56 = load i32*, i32** %7
%57 = call i32 @getc(i32* %56)
store i32 %57, i32* %9
br label %39
58: ; preds = %51
%59 = load i32, i32* %8
%60 = load i32, i32* %9
%61 = icmp eq i32 %59, %60
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %71
64: ; preds = %58
%65 = load i32, i32* %8
%66 = load i32, i32* %9
%67 = icmp ne i32 %65, %66
br i1 %67, label %68, label %70
68: ; preds = %64
%69 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %70
70: ; preds = %68, %64
br label %71
71: ; preds = %70, %62
br label %72
72: ; preds = %71
%73 = load i32*, i32** %6
%74 = call i32 @fclose(i32* %73)
%75 = load i32*, i32** %7
%76 = call i32 @fclose(i32* %75)
br label %77
77: ; preds = %72, %12
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@EOF = global i32 0
@str = [25 x i8] c"\0AFiles are not identical\00"
@str.6 = [21 x i8] c"\0AFiles are identical\00"
@str.7 = [33 x i8] c"Cannot open fileTwo for reading \00"
@str.8 = [33 x i8] c"Cannot open fileOne for reading \00"
@str.9 = [104 x i8] c"\0AIncorrect Number of Parameters Entered.\0ACorrect Usage: fileCompare.exe fileNameOne.txt fileNameTwo.txt\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([104 x i8], [104 x i8]* @str.9, i64 0, i64 0))
br label %46
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 ([2 x i8], [2 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 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.8, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
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 ([2 x i8], [2 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 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.7, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %14
%23 = tail call i32 @getc(i32* %9)
%24 = tail call i32 @getc(i32* %17)
%25 = load i32, i32* @EOF
%26 = icmp ne i32 %23, %25
%27 = icmp ne i32 %24, %25
%28 = and i1 %26, %27
%29 = icmp eq i32 %23, %24
%30 = and i1 %29, %28
br i1 %30, label %31, label %40
31: ; preds = %22, %31
%32 = tail call i32 @getc(i32* %9)
%33 = tail call i32 @getc(i32* %17)
%34 = load i32, i32* @EOF
%35 = icmp ne i32 %32, %34
%36 = icmp ne i32 %33, %34
%37 = and i1 %35, %36
%38 = icmp eq i32 %32, %33
%39 = and i1 %38, %37
br i1 %39, label %31, label %40
40: ; preds = %31, %22
%41 = phi i1 [ %29, %22 ], [ %38, %31 ]
%42 = select i1 %41, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0)
%43 = tail call i32 @puts(i8* dereferenceable(1) %42)
%44 = tail call i32 @fclose(i32* %9)
%45 = tail call i32 @fclose(i32* %17)
br label %46
46: ; preds = %40, %4
ret i32 0
}