#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*/ *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int memcmp(char *, char *, int);
int stb_fcmp_core(FILE *f, FILE *g) {
  char buf1[1024], buf2[1024];
  int n1, n2, 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,-0x81c(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %eax,-0x814(%rbp)
lea    -0x810(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %eax,-0x818(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x830(%rbp)
lea    -0x810(%rbp),%rax
mov    %rax,-0x828(%rbp)
mov    -0x814(%rbp),%eax
cmp    -0x818(%rbp),%eax
jge    11cc <stb_fcmp_core+0x9c>
mov    -0x814(%rbp),%eax
mov    %eax,-0x834(%rbp)
jmp    11d8 <stb_fcmp_core+0xa8>
mov    -0x818(%rbp),%eax
mov    %eax,-0x834(%rbp)
mov    -0x828(%rbp),%rsi
mov    -0x830(%rbp),%rdi
mov    -0x834(%rbp),%edx
call   1050 <memcmp@plt>
mov    %eax,-0x81c(%rbp)
cmpl   $0x0,-0x81c(%rbp)
je     1209 <stb_fcmp_core+0xd9>
jmp    1258 <stb_fcmp_core+0x128>
mov    -0x814(%rbp),%eax
cmp    -0x818(%rbp),%eax
je     1241 <stb_fcmp_core+0x111>
mov    -0x814(%rbp),%edx
mov    -0x818(%rbp),%esi
mov    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    %esi,%edx
cmovl  %ecx,%eax
mov    %eax,-0x81c(%rbp)
jmp    1258 <stb_fcmp_core+0x128>
cmpl   $0x0,-0x814(%rbp)
jne    1253 <stb_fcmp_core+0x123>
jmp    1258 <stb_fcmp_core+0x128>
jmp    114d <stb_fcmp_core+0x1d>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x81c(%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    %eax,%ebp
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    0x8(%rsp),%rcx
call   1030 <fread@plt>
mov    %eax,%r14d
cmp    %eax,%ebp
mov    %eax,%edx
cmovl  %ebp,%edx
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <memcmp@plt>
test   %eax,%eax
jne    11b4 <stb_fcmp_core+0x84>
cmp    %r14d,%ebp
jne    11b8 <stb_fcmp_core+0x88>
test   %ebp,%ebp
jne    1160 <stb_fcmp_core+0x30>
xor    %ebx,%ebx
jmp    11c4 <stb_fcmp_core+0x94>
mov    %eax,%ebx
jmp    11c4 <stb_fcmp_core+0x94>
setge  %al
movzbl %al,%eax
lea    (%rax,%rax,1),%ebx
add    $0xffffffff,%ebx
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1040 <fclose@plt>
mov    %ebx,%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 i32
%8 = alloca i32
%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 i32 @fread(i8* %11, i32 1, i32 1024, i32* %12)
store i32 %13, i32* %7
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%15 = load i32*, i32** %4
%16 = call i32 @fread(i8* %14, i32 1, i32 1024, i32* %15)
store i32 %16, i32* %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 i32, i32* %7
%20 = load i32, i32* %8
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %10
%23 = load i32, i32* %7
br label %26
24: ; preds = %10
%25 = load i32, i32* %8
br label %26
26: ; preds = %24, %22
%27 = phi i32 [ %23, %22 ], [ %25, %24 ]
%28 = call i32 @memcmp(i8* %17, i8* %18, i32 %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 i32, i32* %7
%34 = load i32, i32* %8
%35 = icmp ne i32 %33, %34
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = icmp slt i32 %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 i32, i32* %7
%44 = icmp eq i32 %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 i32 @fread(i8* %5, i32 1, i32 1024, i32* %0)
%9 = call i32 @fread(i8* %6, i32 1, i32 1024, i32* %1)
%10 = icmp slt i32 %8, %9
%11 = select i1 %10, i32 %8, i32 %9
%12 = call i32 @memcmp(i8* %5, i8* %6, i32 %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %7
%15 = icmp eq i32 %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 i32 %8, 0
br i1 %19, label %20, label %7
20: ; preds = %18, %7, %16
%21 = phi i32 [ %17, %16 ], [ 0, %18 ], [ %12, %7 ]
%22 = call i32 @fclose(i32* %0)
%23 = call i32 @fclose(i32* %1)
ret i32 %21
}