#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*/ fail(char *, char *);
int fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
void xfclose(FILE *f) {
  if (f != stdout && f != stdin && f != stderr) {
    int r = fclose(f);
    if (r)
      fail("fclose error \"%s\"", "");
  }
}


x86 assembly (clang, -O0):
<xfclose>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2e99(%rip),%rcx
cmp    (%rcx),%rax
je     1196 <xfclose+0x76>
mov    -0x8(%rbp),%rax
mov    0x2e9d(%rip),%rcx
cmp    (%rcx),%rax
je     1196 <xfclose+0x76>
mov    -0x8(%rbp),%rax
mov    0x2e79(%rip),%rcx
cmp    (%rcx),%rax
je     1196 <xfclose+0x76>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1191 <xfclose+0x71>
lea    0xe7b(%rip),%rdi
lea    0xe85(%rip),%rsi
call   1030 <fail@plt>
jmp    1196 <xfclose+0x76>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xfclose>:
push   %rax
mov    0x2ea8(%rip),%rax
cmp    %rdi,(%rax)
je     1162 <xfclose+0x42>
mov    0x2eb4(%rip),%rax
cmp    %rdi,(%rax)
je     1162 <xfclose+0x42>
mov    0x2e98(%rip),%rax
cmp    %rdi,(%rax)
je     1162 <xfclose+0x42>
call   1040 <fclose@plt>
test   %eax,%eax
je     1162 <xfclose+0x42>
lea    0xeab(%rip),%rdi
lea    0xeb5(%rip),%rsi
pop    %rax
jmp    1030 <fail@plt>
pop    %rax
ret

LLVM IR (-O0):
@stdout = global i32* null
@stdin = global i32* null
@stderr = global i32* null
@.str = [18 x i8] c"fclose error \22%s\22\00"
@.str.1 = [1 x i8] zeroinitializer
define void @xfclose(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = load i32*, i32** @stdout
%6 = icmp ne i32* %4, %5
br i1 %6, label %7, label %23
7: ; preds = %1
%8 = load i32*, i32** %2
%9 = load i32*, i32** @stdin
%10 = icmp ne i32* %8, %9
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = load i32*, i32** %2
%13 = load i32*, i32** @stderr
%14 = icmp ne i32* %12, %13
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i32*, i32** %2
%17 = call i32 @fclose(i32* %16)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 @fail(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %15
br label %23
23: ; preds = %22, %11, %7, %1
ret void
}

LLVM IR (-O2):
@stdout = global i32* null
@stdin = global i32* null
@stderr = global i32* null
@.str = [18 x i8] c"fclose error \22%s\22\00"
@.str.1 = [1 x i8] zeroinitializer
define void @xfclose(i32* nocapture %0) {
%2 = load i32*, i32** @stdout
%3 = icmp eq i32* %2, %0
%4 = load i32*, i32** @stdin
%5 = icmp eq i32* %4, %0
%6 = select i1 %3, i1 true, i1 %5
%7 = load i32*, i32** @stderr
%8 = icmp eq i32* %7, %0
%9 = select i1 %6, i1 true, i1 %8
br i1 %9, label %15, label %10
10: ; preds = %1
%11 = tail call i32 @fclose(i32* %0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @fail(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %10, %13, %1
ret void
}