#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 *);
int /*<<< orphan*/ 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;
  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));
  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));
  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    $0x40,%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    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x28(%rbp),%rdi
mov    0x2db7(%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    0x2d84(%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    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12c9 <compare_files+0x149>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    12e2 <compare_files+0x162>
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    $0x40,%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
store i8* %0, i8** %4
store i8* %1, i8** %5
%11 = load i8*, i8** %4
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %6
%13 = load i8*, i8** %5
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %7
%15 = load i32*, i32** %6
%16 = load i32, i32* @SEEK_END
%17 = call i32 @fseek(i32* %15, i64 0, i32 %16)
%18 = load i32*, i32** %6
%19 = call i64 @ftell(i32* %18)
store i64 %19, i64* %10
%20 = load i32*, i32** %6
%21 = load i32, i32* @SEEK_SET
%22 = call i32 @fseek(i32* %20, i64 0, i32 %21)
%23 = load i64, i64* %10
%24 = add nsw i64 %23, 1
%25 = call i64 @calloc(i64 %24, i32 1)
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %8
%27 = load i8*, i8** %8
%28 = load i64, i64* %10
%29 = load i32*, i32** %6
%30 = call i32 @fread(i8* %27, i32 1, i64 %28, i32* %29)
%31 = load i32*, i32** %6
%32 = call i32 @fclose(i32* %31)
%33 = load i32*, i32** %7
%34 = load i32, i32* @SEEK_END
%35 = call i32 @fseek(i32* %33, i64 0, i32 %34)
%36 = load i32*, i32** %7
%37 = call i64 @ftell(i32* %36)
store i64 %37, i64* %10
%38 = load i32*, i32** %7
%39 = load i32, i32* @SEEK_SET
%40 = call i32 @fseek(i32* %38, i64 0, i32 %39)
%41 = load i64, i64* %10
%42 = add nsw i64 %41, 1
%43 = call i64 @calloc(i64 %42, i32 1)
%44 = inttoptr i64 %43 to i8*
store i8* %44, i8** %9
%45 = load i8*, i8** %9
%46 = load i64, i64* %10
%47 = load i32*, i32** %7
%48 = call i32 @fread(i8* %45, i32 1, i64 %46, i32* %47)
%49 = load i32*, i32** %7
%50 = call i32 @fclose(i32* %49)
%51 = load i8*, i8** %8
%52 = load i8*, i8** %9
%53 = call i64 @strcmp(i8* %51, i8* %52)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %60
55: ; preds = %2
%56 = load i8*, i8** %8
%57 = call i32 @free(i8* %56)
%58 = load i8*, i8** %9
%59 = call i32 @free(i8* %58)
store i32 1, i32* %3
br label %65
60: ; preds = %2
%61 = load i8*, i8** %8
%62 = call i32 @free(i8* %61)
%63 = load i8*, i8** %9
%64 = call i32 @free(i8* %63)
store i32 0, i32* %3
br label %65
65: ; preds = %60, %55
%66 = load i32, i32* %3
ret i32 %66
}

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 i32 @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 i32 @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
}