#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*/ b1;
typedef int /*<<< orphan*/ b0;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int memcmp(char *, char *, size_t const);
int compare(FILE *f0, FILE *f1) {
  int result = 0;
  while (0 == result) {
    char b0[65536];
    char b1[65536];
    const size_t r0 = fread(b0, 1, sizeof(b0), f0);
    const size_t r1 = fread(b1, 1, sizeof(b1), f1);
    result = (int)r0 - (int)r1;
    if (0 == r0 || 0 == r1) {
      break;
    }
    if (0 == result) {
      result = memcmp(b0, b1, r0);
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20030,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
jne    11ea <compare+0xca>
lea    -0x10020(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10000,%edx
call   1030 <fread@plt>
mov    %rax,-0x20028(%rbp)
lea    -0x20020(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10000,%edx
call   1030 <fread@plt>
mov    %rax,-0x20030(%rbp)
mov    -0x20028(%rbp),%rax
mov    -0x20030(%rbp),%rcx
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x20028(%rbp),%rax
je     11b8 <compare+0x98>
xor    %eax,%eax
cmp    -0x20030(%rbp),%rax
jne    11bd <compare+0x9d>
jmp    11ea <compare+0xca>
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
jne    11e5 <compare+0xc5>
lea    -0x10020(%rbp),%rdi
lea    -0x20020(%rbp),%rsi
mov    -0x20028(%rbp),%rdx
call   1040 <memcmp@plt>
mov    %eax,-0x14(%rbp)
jmp    113a <compare+0x1a>
mov    -0x14(%rbp),%eax
add    $0x20030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20000,%rsp
mov    %rsi,%r14
mov    %rdi,%r13
lea    0x10000(%rsp),%r15
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x10000,%edx
mov    %r13,%rcx
call   1030 <fread@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x10000,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
mov    %rax,%rcx
mov    %ebx,%eax
sub    %ecx,%eax
test   %rbx,%rbx
je     11a4 <compare+0x84>
test   %rcx,%rcx
je     11a4 <compare+0x84>
test   %eax,%eax
jne    11a4 <compare+0x84>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <memcmp@plt>
test   %eax,%eax
je     1150 <compare+0x30>
add    $0x20000,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @compare(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [65536 x i8]
%7 = alloca [65536 x i8]
%8 = alloca i64
%9 = alloca i64
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %10
10: ; preds = %39, %2
%11 = load i32, i32* %5
%12 = icmp eq i32 0, %11
br i1 %12, label %13, label %40
13: ; preds = %10
%14 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%15 = load i32*, i32** %3
%16 = call i64 @fread(i8* %14, i32 1, i32 65536, i32* %15)
store i64 %16, i64* %8
%17 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
%18 = load i32*, i32** %4
%19 = call i64 @fread(i8* %17, i32 1, i32 65536, i32* %18)
store i64 %19, i64* %9
%20 = load i64, i64* %8
%21 = trunc i64 %20 to i32
%22 = load i64, i64* %9
%23 = trunc i64 %22 to i32
%24 = sub nsw i32 %21, %23
store i32 %24, i32* %5
%25 = load i64, i64* %8
%26 = icmp eq i64 0, %25
br i1 %26, label %30, label %27
27: ; preds = %13
%28 = load i64, i64* %9
%29 = icmp eq i64 0, %28
br i1 %29, label %30, label %31
30: ; preds = %27, %13
br label %40
31: ; preds = %27
%32 = load i32, i32* %5
%33 = icmp eq i32 0, %32
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%36 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
%37 = load i64, i64* %8
%38 = call i32 @memcmp(i8* %35, i8* %36, i64 %37)
store i32 %38, i32* %5
br label %39
39: ; preds = %34, %31
br label %10
40: ; preds = %30, %10
%41 = load i32, i32* %5
ret i32 %41
}

LLVM IR (-O2):
define i32 @compare(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [65536 x i8]
%4 = alloca [65536 x i8]
%5 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [65536 x i8], [65536 x i8]* %4, i64 0, i64 0
br label %7
7: ; preds = %2, %20
%8 = call i64 @fread(i8* %5, i32 1, i32 65536, i32* %0)
%9 = call i64 @fread(i8* %6, i32 1, i32 65536, i32* %1)
%10 = trunc i64 %8 to i32
%11 = trunc i64 %9 to i32
%12 = sub nsw i32 %10, %11
%13 = icmp eq i64 %8, 0
%14 = icmp eq i64 %9, 0
%15 = or i1 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %7
br label %23
17: ; preds = %7
%18 = icmp eq i32 %12, 0
br i1 %18, label %20, label %19
19: ; preds = %17
br label %23
20: ; preds = %17
%21 = call i32 @memcmp(i8* %5, i8* %6, i64 %8)
%22 = icmp eq i32 %21, 0
br i1 %22, label %7, label %23
23: ; preds = %20, %19, %16
%24 = phi i32 [ %12, %16 ], [ %12, %19 ], [ %21, %20 ]
ret i32 %24
}