#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int diffFiles(char *inPath, char *inPath2) {
  char c, c2;
  FILE *in = fopen(inPath, "rb");
  FILE *in2 = fopen(inPath2, "rb");
  while (((c = fgetc(in)) != EOF) && ((c2 = fgetc(in2)) != EOF) && (c == c2))
    ;
  if (c != EOF && c2 != EOF) {
    printf("No match, something went wrong...\n");
  } else {
    printf("Perfect match!\n");
  }
  fclose(in);
  fclose(in2);
}


x86 assembly (clang, -O0):
<diffFiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%ecx
mov    0x2e5a(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x31(%rbp)
je     11d4 <diffFiles+0x94>
mov    -0x30(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x1a(%rbp)
movsbl %al,%ecx
mov    0x2e34(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x31(%rbp)
je     11d4 <diffFiles+0x94>
movsbl -0x19(%rbp),%eax
movsbl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11e4 <diffFiles+0xa4>
jmp    11e9 <diffFiles+0xa9>
jmp    1178 <diffFiles+0x38>
movsbl -0x19(%rbp),%eax
mov    0x2df4(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1226 <diffFiles+0xe6>
movsbl -0x1a(%rbp),%eax
mov    0x2dde(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1226 <diffFiles+0xe6>
lea    0xde7(%rip),%rdi
call   1040 <printf@plt>
jmp    1232 <diffFiles+0xf2>
lea    0xdf9(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<diffFiles>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
lea    0xeae(%rip),%r14
mov    %r14,%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    0x2e6e(%rip),%r12
cmp    (%r12),%al
je     11c8 <diffFiles+0x88>
mov    %eax,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <fgetc@plt>
movzbl (%r12),%ecx
cmp    %al,%bl
jne    11b7 <diffFiles+0x77>
cmp    %cl,%al
je     11b7 <diffFiles+0x77>
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebx
cmp    (%r12),%al
jne    1190 <diffFiles+0x50>
jmp    11c8 <diffFiles+0x88>
cmp    %cl,%bl
je     11c8 <diffFiles+0x88>
cmp    %cl,%al
je     11c8 <diffFiles+0x88>
lea    0xe4c(%rip),%rdi
jmp    11cf <diffFiles+0x8f>
lea    0xe34(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@EOF = global i8 0
@.str.1 = [35 x i8] c"No match, something went wrong...\0A\00"
@.str.2 = [16 x i8] c"Perfect match!\0A\00"
define i32 @diffFiles(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32*
%9 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = load i8*, i8** %4
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %8
%12 = load i8*, i8** %5
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %9
br label %14
14: ; preds = %36, %2
%15 = load i32*, i32** %8
%16 = call signext i8 @fgetc(i32* %15)
store i8 %16, i8* %6
%17 = sext i8 %16 to i32
%18 = load i8, i8* @EOF
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %17, %19
br i1 %20, label %21, label %34
21: ; preds = %14
%22 = load i32*, i32** %9
%23 = call signext i8 @fgetc(i32* %22)
store i8 %23, i8* %7
%24 = sext i8 %23 to i32
%25 = load i8, i8* @EOF
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %24, %26
br i1 %27, label %28, label %34
28: ; preds = %21
%29 = load i8, i8* %6
%30 = sext i8 %29 to i32
%31 = load i8, i8* %7
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %30, %32
br label %34
34: ; preds = %28, %21, %14
%35 = phi i1 [ false, %21 ], [ false, %14 ], [ %33, %28 ]
br i1 %35, label %36, label %37
36: ; preds = %34
br label %14
37: ; preds = %34
%38 = load i8, i8* %6
%39 = sext i8 %38 to i32
%40 = load i8, i8* @EOF
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %39, %41
br i1 %42, label %43, label %51
43: ; preds = %37
%44 = load i8, i8* %7
%45 = sext i8 %44 to i32
%46 = load i8, i8* @EOF
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %45, %47
br i1 %48, label %49, label %51
49: ; preds = %43
%50 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %53
51: ; preds = %43, %37
%52 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %53
53: ; preds = %51, %49
%54 = load i32*, i32** %8
%55 = call i32 @fclose(i32* %54)
%56 = load i32*, i32** %9
%57 = call i32 @fclose(i32* %56)
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@EOF = global i8 0
@str = [15 x i8] c"Perfect match!\00"
@str.3 = [34 x i8] c"No match, something went wrong...\00"
define i32 @diffFiles(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = tail call signext i8 @fgetc(i32* %3)
%6 = load i8, i8* @EOF
%7 = icmp eq i8 %5, %6
br i1 %7, label %23, label %12
8: ; preds = %12
%9 = tail call signext i8 @fgetc(i32* %3)
%10 = load i8, i8* @EOF
%11 = icmp eq i8 %9, %10
br i1 %11, label %23, label %12
12: ; preds = %2, %8
%13 = phi i8 [ %9, %8 ], [ %5, %2 ]
%14 = tail call signext i8 @fgetc(i32* %4)
%15 = load i8, i8* @EOF
%16 = icmp ne i8 %14, %15
%17 = icmp eq i8 %13, %14
%18 = and i1 %17, %16
br i1 %18, label %8, label %19
19: ; preds = %12
%20 = icmp eq i8 %13, %15
%21 = icmp eq i8 %14, %15
%22 = or i1 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %8, %2, %19
br label %24
24: ; preds = %19, %23
%25 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0), %23 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @str.3, i64 0, i64 0), %19 ]
%26 = tail call i32 @puts(i8* dereferenceable(1) %25)
%27 = tail call i32 @fclose(i32* %3)
%28 = tail call i32 @fclose(i32* %4)
ret i32 undef
}