#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*/ *stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
void close_file(void *file) {
  if (*(FILE **)file == NULL)
    return;
  if (!((*(FILE **)file == stdout) || (*(FILE **)file == stdin) ||
        (*(FILE **)file == stderr))) {
    fclose(*(FILE **)file);
  }
  *(FILE **)file = NULL;
}


x86 assembly (clang, -O0):
<close_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    112f <close_file+0x1f>
jmp    118b <close_file+0x7b>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x2e93(%rip),%rcx
cmp    (%rcx),%rax
je     1180 <close_file+0x70>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%rax
je     1180 <close_file+0x70>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x2e6d(%rip),%rcx
cmp    (%rcx),%rax
je     1180 <close_file+0x70>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <fclose@plt>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<close_file>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     114c <close_file+0x3c>
mov    0x2ead(%rip),%rax
cmp    (%rax),%rdi
je     1145 <close_file+0x35>
mov    0x2eb9(%rip),%rax
cmp    (%rax),%rdi
je     1145 <close_file+0x35>
mov    0x2e9d(%rip),%rax
cmp    (%rax),%rdi
je     1145 <close_file+0x35>
call   1030 <fclose@plt>
movq   $0x0,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
@stdout = global i32* null
@stdin = global i32* null
@stderr = global i32* null
define void @close_file(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = bitcast i8* %3 to i32**
%5 = load i32*, i32** %4
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %8
7: ; preds = %1
br label %34
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = bitcast i8* %9 to i32**
%11 = load i32*, i32** %10
%12 = load i32*, i32** @stdout
%13 = icmp eq i32* %11, %12
br i1 %13, label %31, label %14
14: ; preds = %8
%15 = load i8*, i8** %2
%16 = bitcast i8* %15 to i32**
%17 = load i32*, i32** %16
%18 = load i32*, i32** @stdin
%19 = icmp eq i32* %17, %18
br i1 %19, label %31, label %20
20: ; preds = %14
%21 = load i8*, i8** %2
%22 = bitcast i8* %21 to i32**
%23 = load i32*, i32** %22
%24 = load i32*, i32** @stderr
%25 = icmp eq i32* %23, %24
br i1 %25, label %31, label %26
26: ; preds = %20
%27 = load i8*, i8** %2
%28 = bitcast i8* %27 to i32**
%29 = load i32*, i32** %28
%30 = call i32 @fclose(i32* %29)
br label %31
31: ; preds = %26, %20, %14, %8
%32 = load i8*, i8** %2
%33 = bitcast i8* %32 to i32**
store i32* null, i32** %33
br label %34
34: ; preds = %31, %7
ret void
}

LLVM IR (-O2):
@stdout = global i32* null
@stdin = global i32* null
@stderr = global i32* null
define void @close_file(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32**
%3 = load i32*, i32** %2
%4 = icmp eq i32* %3, null
br i1 %4, label %17, label %5
5: ; preds = %1
%6 = load i32*, i32** @stdout
%7 = icmp eq i32* %3, %6
%8 = load i32*, i32** @stdin
%9 = icmp eq i32* %3, %8
%10 = select i1 %7, i1 true, i1 %9
%11 = load i32*, i32** @stderr
%12 = icmp eq i32* %3, %11
%13 = select i1 %10, i1 true, i1 %12
br i1 %13, label %16, label %14
14: ; preds = %5
%15 = tail call i32 @fclose(i32* %3)
br label %16
16: ; preds = %14, %5
store i32* null, i32** %2
br label %17
17: ; preds = %1, %16
ret void
}