#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 stb_fcmp_core(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int stb_fcmp(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 1;
    }
    return f != NULL;
  }
  return stb_fcmp_core(f, g);
}


x86 assembly (clang, -O0):
<stb_fcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     117e <stb_fcmp+0x4e>
cmpq   $0x0,-0x28(%rbp)
jne    11c7 <stb_fcmp+0x97>
cmpq   $0x0,-0x20(%rbp)
je     1192 <stb_fcmp+0x62>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
cmpq   $0x0,-0x28(%rbp)
je     11b2 <stb_fcmp+0x82>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d7 <stb_fcmp+0xa7>
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11d7 <stb_fcmp+0xa7>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <stb_fcmp_core@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stb_fcmp>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
lea    0xec1(%rip),%r15
mov    %r15,%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
test   %rbx,%rbx
je     1172 <stb_fcmp+0x42>
test   %r14,%r14
je     1172 <stb_fcmp+0x42>
mov    %rbx,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <stb_fcmp_core@plt>
test   %rbx,%rbx
je     117f <stb_fcmp+0x4f>
mov    %rbx,%rdi
call   1030 <fclose@plt>
test   %r14,%r14
je     1193 <stb_fcmp+0x63>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
jmp    119b <stb_fcmp+0x6b>
xor    %eax,%eax
test   %rbx,%rbx
setne  %al
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
define i32 @stb_fcmp(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 %33
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)
store i32 1, i32* %3
br label %37
29: ; preds = %23
%30 = load i32*, i32** %6
%31 = icmp ne i32* %30, null
%32 = zext i1 %31 to i32
store i32 %32, i32* %3
br label %37
33: ; preds = %14
%34 = load i32*, i32** %6
%35 = load i32*, i32** %7
%36 = call i32 @stb_fcmp_core(i32* %34, i32* %35)
store i32 %36, i32* %3
br label %37
37: ; preds = %33, %29, %26
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
define i32 @stb_fcmp(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 %17
8: ; preds = %2
%9 = icmp ne i32* %3, null
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i32 @fclose(i32* %3)
br label %12
12: ; preds = %10, %8
br i1 %6, label %15, label %13
13: ; preds = %12
%14 = tail call i32 @fclose(i32* %4)
br label %19
15: ; preds = %12
%16 = zext i1 %9 to i32
br label %19
17: ; preds = %2
%18 = tail call i32 @stb_fcmp_core(i32* %3, i32* %4)
br label %19
19: ; preds = %17, %15, %13
%20 = phi i32 [ 1, %13 ], [ %16, %15 ], [ %18, %17 ]
ret i32 %20
}