#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ stb_fcmp_core(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ stb_filelen(int /*<<< orphan*/ *);
int stb_feq(char *s1, char *s2) {
  FILE *f = fopen(s1, "rb");
  FILE *g = fopen(s2, "rb");
  if (f == NULL || g == NULL) {
    if (f)
      fclose(f);
    if (g)
      fclose(g);
    return f == g;
  }
  if (stb_filelen(f) != stb_filelen(g)) {
    fclose(f);
    fclose(g);
    return 0;
  }
  return !stb_fcmp_core(f, g);
}


x86 assembly (clang, -O0):
<stb_feq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     118e <stb_feq+0x4e>
cmpq   $0x0,-0x28(%rbp)
jne    11ce <stb_feq+0x8e>
cmpq   $0x0,-0x20(%rbp)
je     11a2 <stb_feq+0x62>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
cmpq   $0x0,-0x28(%rbp)
je     11b6 <stb_feq+0x76>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    122f <stb_feq+0xef>
mov    -0x20(%rbp),%rdi
call   1040 <stb_filelen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <stb_filelen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     1212 <stb_feq+0xd2>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    122f <stb_feq+0xef>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <stb_fcmp_core@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stb_feq>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
lea    0xeb1(%rip),%r14
mov    %r14,%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
test   %r15,%r15
je     1199 <stb_feq+0x59>
test   %r14,%r14
je     1199 <stb_feq+0x59>
mov    %r15,%rdi
call   1040 <stb_filelen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <stb_filelen@plt>
mov    %r15,%rdi
cmp    %rax,%rbx
jne    11bb <stb_feq+0x7b>
mov    %r14,%rsi
call   1050 <stb_fcmp_core@plt>
test   %eax,%eax
jmp    11b6 <stb_feq+0x76>
test   %r15,%r15
je     11a6 <stb_feq+0x66>
mov    %r15,%rdi
call   1030 <fclose@plt>
test   %r14,%r14
je     11b3 <stb_feq+0x73>
mov    %r14,%rdi
call   1030 <fclose@plt>
cmp    %r14,%r15
sete   %al
jmp    11ca <stb_feq+0x8a>
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
movzbl %al,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
define i32 @stb_feq(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %3, null
%6 = icmp eq i32* %4, null
%7 = or i1 %5, %6
br i1 %7, label %8, label %16
8: ; preds = %2
br i1 %5, label %11, label %9
9: ; preds = %8
%10 = tail call i32 @fclose(i32* %3)
br label %11
11: ; preds = %9, %8
br i1 %6, label %14, label %12
12: ; preds = %11
%13 = tail call i32 @fclose(i32* %4)
br label %14
14: ; preds = %12, %11
%15 = icmp eq i32* %3, %4
br label %26
16: ; preds = %2
%17 = tail call i64 @stb_filelen(i32* %3)
%18 = tail call i64 @stb_filelen(i32* %4)
%19 = icmp eq i64 %17, %18
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = tail call i32 @fclose(i32* %3)
%22 = tail call i32 @fclose(i32* %4)
br label %26
23: ; preds = %16
%24 = tail call i32 @stb_fcmp_core(i32* %3, i32* %4)
%25 = icmp eq i32 %24, 0
br label %26
26: ; preds = %23, %20, %14
%27 = phi i1 [ %15, %14 ], [ false, %20 ], [ %25, %23 ]
%28 = zext i1 %27 to i32
ret i32 %28
}