#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 */
scalar_t__ EOF;
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int fileCloser(FILE **file) {
  if (*file == NULL) {
    printf("Error: entry isn't a file or the file hasn't been opened yet.\n");
    return -1;
  }
  if (fclose(*file) == EOF) {
    printf("Error: cannot close file.\n");
    return -2;
  }
  return 1;
}


x86 assembly (clang, -O0):
<fileCloser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1152 <fileCloser+0x32>
lea    0xebf(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    118d <fileCloser+0x6d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <fclose@plt>
mov    0x2e83(%rip),%rcx
cmp    (%rcx),%rax
jne    1186 <fileCloser+0x66>
lea    0xeca(%rip),%rdi
call   1040 <printf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    118d <fileCloser+0x6d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fileCloser>:
push   %rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     114d <fileCloser+0x2d>
call   1040 <fclose@plt>
mov    0x2eb3(%rip),%rcx
mov    $0x1,%ebx
cmp    (%rcx),%rax
jne    115e <fileCloser+0x3e>
mov    $0xfffffffe,%ebx
lea    0xeb5(%rip),%rdi
jmp    1159 <fileCloser+0x39>
mov    $0xffffffff,%ebx
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [63 x i8] c"Error: entry isn't a file or the file hasn't been opened yet.\0A\00"
@EOF = global i64 0
@.str.1 = [27 x i8] c"Error: cannot close file.\0A\00"
define i32 @fileCloser(i32** %0) {
%2 = alloca i32
%3 = alloca i32**
store i32** %0, i32*** %3
%4 = load i32**, i32*** %3
%5 = load i32*, i32** %4
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %18
9: ; preds = %1
%10 = load i32**, i32*** %3
%11 = load i32*, i32** %10
%12 = call i64 @fclose(i32* %11)
%13 = load i64, i64* @EOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 -2, i32* %2
br label %18
17: ; preds = %9
store i32 1, i32* %2
br label %18
18: ; preds = %17, %15, %7
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@EOF = global i64 0
@str = [26 x i8] c"Error: cannot close file.\00"
@str.2 = [62 x i8] c"Error: entry isn't a file or the file hasn't been opened yet.\00"
define i32 @fileCloser(i32** nocapture %0) {
%2 = load i32*, i32** %0
%3 = icmp eq i32* %2, null
br i1 %3, label %8, label %4
4: ; preds = %1
%5 = tail call i64 @fclose(i32* %2)
%6 = load i64, i64* @EOF
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %12
8: ; preds = %4, %1
%9 = phi i8* [ getelementptr inbounds ([62 x i8], [62 x i8]* @str.2, i64 0, i64 0), %1 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0), %4 ]
%10 = phi i32 [ -1, %1 ], [ -2, %4 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %9)
br label %12
12: ; preds = %8, %4
%13 = phi i32 [ 1, %4 ], [ %10, %8 ]
ret i32 %13
}