#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*/ tag;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int gettag();
int /*<<< orphan*/ lua_pushusertag(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ lua_settag(int /*<<< orphan*/);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
void closefile(FILE *f) {
  if (f != stdin && f != stdout) {
    int tag = gettag();
    { fclose(f); };
    lua_pushusertag(f, tag);
    lua_settag(((tag)-1));
  }
}


x86 assembly (clang, -O0):
<closefile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%rax
je     119e <closefile+0x5e>
mov    -0x8(%rbp),%rax
mov    0x2e6d(%rip),%rcx
cmp    (%rcx),%rax
je     119e <closefile+0x5e>
mov    $0x0,%al
call   1050 <gettag@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <lua_pushusertag@plt>
mov    -0xc(%rbp),%edi
sub    $0x1,%edi
call   1060 <lua_settag@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<closefile>:
push   %rbp
push   %rbx
push   %rax
mov    0x2e9e(%rip),%rax
cmp    %rdi,(%rax)
je     1189 <closefile+0x49>
mov    %rdi,%rbx
mov    0x2e7f(%rip),%rax
cmp    %rdi,(%rax)
je     1189 <closefile+0x49>
xor    %eax,%eax
call   1050 <gettag@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <lua_pushusertag@plt>
add    $0xffffffff,%ebp
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <lua_settag@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32* null
@stdout = global i32* null
define void @closefile(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = load i32*, i32** @stdin
%6 = icmp ne i32* %4, %5
br i1 %6, label %7, label %21
7: ; preds = %1
%8 = load i32*, i32** %2
%9 = load i32*, i32** @stdout
%10 = icmp ne i32* %8, %9
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = call i32 (...) @gettag()
store i32 %12, i32* %3
%13 = load i32*, i32** %2
%14 = call i32 @fclose(i32* %13)
%15 = load i32*, i32** %2
%16 = load i32, i32* %3
%17 = call i32 @lua_pushusertag(i32* %15, i32 %16)
%18 = load i32, i32* %3
%19 = sub nsw i32 %18, 1
%20 = call i32 @lua_settag(i32 %19)
br label %21
21: ; preds = %11, %7, %1
ret void
}

LLVM IR (-O2):
@stdin = global i32* null
@stdout = global i32* null
define void @closefile(i32* %0) {
%2 = load i32*, i32** @stdin
%3 = icmp eq i32* %2, %0
%4 = load i32*, i32** @stdout
%5 = icmp eq i32* %4, %0
%6 = select i1 %3, i1 true, i1 %5
br i1 %6, label %13, label %7
7: ; preds = %1
%8 = tail call i32 (...) @gettag()
%9 = tail call i32 @fclose(i32* %0)
%10 = tail call i32 @lua_pushusertag(i32* %0, i32 %8)
%11 = add nsw i32 %8, -1
%12 = tail call i32 @lua_settag(i32 %11)
br label %13
13: ; preds = %7, %1
ret void
}