#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*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
scalar_t__ calloc(long, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
int compare_files(char expected_output_filename[],
                  char actual_output_filename[]) {
  FILE *expected_output_fh;
  FILE *actual_output_fh;
  char *expected_buffer;
  char *actual_buffer;
  long numbytes;
  size_t fsize_expected;
  size_t fsize_actual;
  expected_output_fh = fopen(expected_output_filename, "r");
  actual_output_fh = fopen(actual_output_filename, "r");
  fseek(expected_output_fh, 0L, SEEK_END);
  numbytes = ftell(expected_output_fh);
  fseek(expected_output_fh, 0L, SEEK_SET);
  expected_buffer = (char *)calloc(numbytes + 1, sizeof(char));
  fsize_expected =
      fread(expected_buffer, sizeof(char), numbytes, expected_output_fh);
  fclose(expected_output_fh);
  fseek(actual_output_fh, 0L, SEEK_END);
  numbytes = ftell(actual_output_fh);
  fseek(actual_output_fh, 0L, SEEK_SET);
  actual_buffer = (char *)calloc(numbytes + 1, sizeof(char));
  fsize_actual = fread(actual_buffer, sizeof(char), numbytes, actual_output_fh);
  fclose(actual_output_fh);
  if (strcmp(expected_buffer, actual_buffer) == 0) {
    free(expected_buffer);
    free(actual_buffer);
    return 1;
  }
  free(expected_buffer);
  free(actual_buffer);
  return 0;
}


x86 assembly (clang, -O0):
<compare_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2e25(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1090 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2df2(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1090 <fseek@plt>
mov    -0x40(%rbp),%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x28(%rbp),%rdi
mov    0x2db3(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1090 <fseek@plt>
mov    -0x28(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2d80(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1090 <fseek@plt>
mov    -0x40(%rbp),%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12d1 <compare_files+0x151>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ea <compare_files+0x16a>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_files>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
lea    0xe6b(%rip),%r15
mov    %r15,%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <fopen@plt>
mov    %rax,%r15
mov    0x2e33(%rip),%r13
mov    0x0(%r13),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1080 <ftell@plt>
mov    %rax,%r12
mov    0x2e03(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
lea    0x1(%r12),%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x0(%r13),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r15,%rdi
call   1080 <ftell@plt>
mov    %rax,%r12
mov    0x0(%rbp),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
lea    0x1(%r12),%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
mov    %r15,%rcx
call   1040 <fread@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i32 @compare_files(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
%13 = load i8*, i8** %4
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %6
%15 = load i8*, i8** %5
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %7
%17 = load i32*, i32** %6
%18 = load i32, i32* @SEEK_END
%19 = call i32 @fseek(i32* %17, i64 0, i32 %18)
%20 = load i32*, i32** %6
%21 = call i64 @ftell(i32* %20)
store i64 %21, i64* %10
%22 = load i32*, i32** %6
%23 = load i32, i32* @SEEK_SET
%24 = call i32 @fseek(i32* %22, i64 0, i32 %23)
%25 = load i64, i64* %10
%26 = add nsw i64 %25, 1
%27 = call i64 @calloc(i64 %26, i32 1)
%28 = inttoptr i64 %27 to i8*
store i8* %28, i8** %8
%29 = load i8*, i8** %8
%30 = load i64, i64* %10
%31 = load i32*, i32** %6
%32 = call i64 @fread(i8* %29, i32 1, i64 %30, i32* %31)
store i64 %32, i64* %11
%33 = load i32*, i32** %6
%34 = call i32 @fclose(i32* %33)
%35 = load i32*, i32** %7
%36 = load i32, i32* @SEEK_END
%37 = call i32 @fseek(i32* %35, i64 0, i32 %36)
%38 = load i32*, i32** %7
%39 = call i64 @ftell(i32* %38)
store i64 %39, i64* %10
%40 = load i32*, i32** %7
%41 = load i32, i32* @SEEK_SET
%42 = call i32 @fseek(i32* %40, i64 0, i32 %41)
%43 = load i64, i64* %10
%44 = add nsw i64 %43, 1
%45 = call i64 @calloc(i64 %44, i32 1)
%46 = inttoptr i64 %45 to i8*
store i8* %46, i8** %9
%47 = load i8*, i8** %9
%48 = load i64, i64* %10
%49 = load i32*, i32** %7
%50 = call i64 @fread(i8* %47, i32 1, i64 %48, i32* %49)
store i64 %50, i64* %12
%51 = load i32*, i32** %7
%52 = call i32 @fclose(i32* %51)
%53 = load i8*, i8** %8
%54 = load i8*, i8** %9
%55 = call i64 @strcmp(i8* %53, i8* %54)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %2
%58 = load i8*, i8** %8
%59 = call i32 @free(i8* %58)
%60 = load i8*, i8** %9
%61 = call i32 @free(i8* %60)
store i32 1, i32* %3
br label %67
62: ; preds = %2
%63 = load i8*, i8** %8
%64 = call i32 @free(i8* %63)
%65 = load i8*, i8** %9
%66 = call i32 @free(i8* %65)
store i32 0, i32* %3
br label %67
67: ; preds = %62, %57
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i32 @compare_files(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @SEEK_END
%6 = tail call i32 @fseek(i32* %3, i64 0, i32 %5)
%7 = tail call i64 @ftell(i32* %3)
%8 = load i32, i32* @SEEK_SET
%9 = tail call i32 @fseek(i32* %3, i64 0, i32 %8)
%10 = add nsw i64 %7, 1
%11 = tail call i64 @calloc(i64 %10, i32 1)
%12 = inttoptr i64 %11 to i8*
%13 = tail call i64 @fread(i8* %12, i32 1, i64 %7, i32* %3)
%14 = tail call i32 @fclose(i32* %3)
%15 = load i32, i32* @SEEK_END
%16 = tail call i32 @fseek(i32* %4, i64 0, i32 %15)
%17 = tail call i64 @ftell(i32* %4)
%18 = load i32, i32* @SEEK_SET
%19 = tail call i32 @fseek(i32* %4, i64 0, i32 %18)
%20 = add nsw i64 %17, 1
%21 = tail call i64 @calloc(i64 %20, i32 1)
%22 = inttoptr i64 %21 to i8*
%23 = tail call i64 @fread(i8* %22, i32 1, i64 %17, i32* %4)
%24 = tail call i32 @fclose(i32* %4)
%25 = tail call i64 @strcmp(i8* %12, i8* %22)
%26 = icmp eq i64 %25, 0
%27 = tail call i32 @free(i8* %12)
%28 = tail call i32 @free(i8* %22)
%29 = zext i1 %26 to i32
ret i32 %29
}