#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void Fclose(FILE *F) {
  if (F == NULL) {
    fprintf(stderr, "Error (Fclose): NULL file pointer.\n");
    exit(EXIT_FAILURE);
  }
  if (ferror(F)) {
    fprintf(stderr, "Error (Fclose): unable to close the stream due to an "
                    "unknown error.\n");
    exit(EXIT_FAILURE);
  }
  if (fclose(F) != 0) {
    fprintf(stderr, "Error (Fclose): unable to close the file stream.\n");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<Fclose>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    117a <Fclose+0x3a>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     11b0 <Fclose+0x70>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     11e6 <Fclose+0xa6>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Fclose>:
push   %rbx
test   %rdi,%rdi
je     1162 <Fclose+0x22>
mov    %rdi,%rbx
call   1030 <ferror@plt>
test   %rax,%rax
jne    1174 <Fclose+0x34>
mov    %rbx,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
jne    1186 <Fclose+0x46>
pop    %rbx
ret
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
jmp    1196 <Fclose+0x56>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
jmp    1196 <Fclose+0x56>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xed3(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"Error (Fclose): NULL file pointer.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [69 x i8] c"Error (Fclose): unable to close the stream due to an unknown error.\0A\00"
@.str.2 = [50 x i8] c"Error (Fclose): unable to close the file stream.\0A\00"
define void @Fclose(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = call i32 @exit(i32 %8)
unreachable
10: ; preds = %1
%11 = load i32*, i32** %2
%12 = call i64 @ferror(i32* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %10
%20 = load i32*, i32** %2
%21 = call i64 @fclose(i32* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %19
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"Error (Fclose): NULL file pointer.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [69 x i8] c"Error (Fclose): unable to close the stream due to an unknown error.\0A\00"
@.str.2 = [50 x i8] c"Error (Fclose): unable to close the file stream.\0A\00"
define void @Fclose(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %1
%9 = tail call i64 @ferror(i32* %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %8
%17 = tail call i64 @fclose(i32* %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
24: ; preds = %16
ret void
}