#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*/ *getfile(char *);
int /*<<< orphan*/ gettag(int);
int /*<<< orphan*/ lua_getglobal(char *);
int /*<<< orphan*/ lua_pushobject(int /*<<< orphan*/);
int /*<<< orphan*/ lua_settag(int /*<<< orphan*/);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
void closefile(char *name) {
  FILE *f = getfile(name);
  if (f == stdin || f == stdout)
    return;
  if ((-1) == -1)
    fclose(f);
  lua_pushobject(lua_getglobal(name));
  lua_settag(gettag(2));
}


x86 assembly (clang, -O0):
<closefile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <getfile@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2e64(%rip),%rcx
cmp    (%rcx),%rax
je     11a1 <closefile+0x41>
mov    -0x10(%rbp),%rax
mov    0x2e40(%rip),%rcx
cmp    (%rcx),%rax
jne    11a6 <closefile+0x46>
jmp    11d0 <closefile+0x70>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x8(%rbp),%rdi
call   1040 <lua_getglobal@plt>
mov    %eax,%edi
call   1080 <lua_pushobject@plt>
mov    $0x2,%edi
call   1050 <gettag@plt>
mov    %eax,%edi
call   1060 <lua_settag@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<closefile>:
push   %rbx
mov    %rdi,%rbx
call   1070 <getfile@plt>
mov    0x2e78(%rip),%rcx
cmp    (%rcx),%rax
je     11aa <closefile+0x4a>
mov    0x2e5c(%rip),%rcx
cmp    (%rcx),%rax
je     11aa <closefile+0x4a>
mov    %rax,%rdi
call   1030 <fclose@plt>
mov    %rbx,%rdi
call   1040 <lua_getglobal@plt>
mov    %eax,%edi
call   1080 <lua_pushobject@plt>
mov    $0x2,%edi
call   1050 <gettag@plt>
mov    %eax,%edi
pop    %rbx
jmp    1060 <lua_settag@plt>
pop    %rbx
ret

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

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