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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int memcmp(char *, char *, size_t);
int stb_fcmp_core(FILE *f, FILE *g) {
  char buf1[1024], buf2[1024];
  size_t n1, n2;
  int res = 0;
  while (1) {
    n1 = fread(buf1, 1, sizeof(buf1), f);
    n2 = fread(buf2, 1, sizeof(buf2), g);
    res = memcmp(buf1, buf2, ((n1) < (n2) ? (n1) : (n2)));
    if (res)
      break;
    if (n1 != n2) {
      res = n1 < n2 ? -1 : 1;
      break;
    }
    if (n1 == 0)
      break;
  }
  fclose(f);
  fclose(g);
  return res;
}


x86 assembly (clang, -O0):
<stb_fcmp_core>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x824(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %rax,-0x818(%rbp)
lea    -0x810(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %rax,-0x820(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x838(%rbp)
lea    -0x810(%rbp),%rax
mov    %rax,-0x830(%rbp)
mov    -0x818(%rbp),%rax
cmp    -0x820(%rbp),%rax
jae    11d2 <stb_fcmp_core+0xa2>
mov    -0x818(%rbp),%rax
mov    %rax,-0x840(%rbp)
jmp    11e0 <stb_fcmp_core+0xb0>
mov    -0x820(%rbp),%rax
mov    %rax,-0x840(%rbp)
mov    -0x830(%rbp),%rsi
mov    -0x838(%rbp),%rdi
mov    -0x840(%rbp),%rdx
call   1050 <memcmp@plt>
mov    %eax,-0x824(%rbp)
cmpl   $0x0,-0x824(%rbp)
je     1212 <stb_fcmp_core+0xe2>
jmp    1267 <stb_fcmp_core+0x137>
mov    -0x818(%rbp),%rax
cmp    -0x820(%rbp),%rax
je     124f <stb_fcmp_core+0x11f>
mov    -0x818(%rbp),%rdx
mov    -0x820(%rbp),%rsi
mov    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    %rsi,%rdx
cmovb  %ecx,%eax
mov    %eax,-0x824(%rbp)
jmp    1267 <stb_fcmp_core+0x137>
cmpq   $0x0,-0x818(%rbp)
jne    1262 <stb_fcmp_core+0x132>
jmp    1267 <stb_fcmp_core+0x137>
jmp    114d <stb_fcmp_core+0x1d>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x824(%rbp),%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stb_fcmp_core>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
mov    %rsi,0x8(%rsp)
mov    %rdi,%r15
lea    0x410(%rsp),%r12
lea    0x10(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    0x8(%rsp),%rcx
call   1030 <fread@plt>
mov    %rax,%r14
cmp    %rax,%rbx
mov    %rax,%rdx
cmovb  %rbx,%rdx
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <memcmp@plt>
test   %eax,%eax
jne    11b9 <stb_fcmp_core+0x89>
cmp    %r14,%rbx
jne    11bd <stb_fcmp_core+0x8d>
test   %rbx,%rbx
jne    1160 <stb_fcmp_core+0x30>
xor    %ebp,%ebp
jmp    11c9 <stb_fcmp_core+0x99>
mov    %eax,%ebp
jmp    11c9 <stb_fcmp_core+0x99>
setae  %al
movzbl %al,%eax
lea    (%rax,%rax,1),%ebp
add    $0xffffffff,%ebp
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1040 <fclose@plt>
mov    %ebp,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @stb_fcmp_core(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %9
br label %10
10: ; preds = %2, %46
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = load i32*, i32** %3
%13 = call i64 @fread(i8* %11, i32 1, i32 1024, i32* %12)
store i64 %13, i64* %7
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%15 = load i32*, i32** %4
%16 = call i64 @fread(i8* %14, i32 1, i32 1024, i32* %15)
store i64 %16, i64* %8
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%19 = load i64, i64* %7
%20 = load i64, i64* %8
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %10
%23 = load i64, i64* %7
br label %26
24: ; preds = %10
%25 = load i64, i64* %8
br label %26
26: ; preds = %24, %22
%27 = phi i64 [ %23, %22 ], [ %25, %24 ]
%28 = call i32 @memcmp(i8* %17, i8* %18, i64 %27)
store i32 %28, i32* %9
%29 = load i32, i32* %9
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %26
br label %47
32: ; preds = %26
%33 = load i64, i64* %7
%34 = load i64, i64* %8
%35 = icmp ne i64 %33, %34
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = load i64, i64* %7
%38 = load i64, i64* %8
%39 = icmp ult i64 %37, %38
%40 = zext i1 %39 to i64
%41 = select i1 %39, i32 -1, i32 1
store i32 %41, i32* %9
br label %47
42: ; preds = %32
%43 = load i64, i64* %7
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %42
br label %47
46: ; preds = %42
br label %10
47: ; preds = %45, %36, %31
%48 = load i32*, i32** %3
%49 = call i32 @fclose(i32* %48)
%50 = load i32*, i32** %4
%51 = call i32 @fclose(i32* %50)
%52 = load i32, i32* %9
ret i32 %52
}

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