#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*/ errno;
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ svz_file_del(int /*<<< orphan*/);
int /*<<< orphan*/ svz_log(int, char *, int /*<<< orphan*/);
int svz_fclose(FILE *f) {
  svz_file_del(fileno(f));
  if (fclose(f) < 0) {
    svz_log(1, "fclose: %s\n", strerror(errno));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<svz_fclose>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fileno@plt>
mov    %eax,%edi
call   1040 <svz_file_del@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
cmp    $0x0,%rax
jge    11ac <svz_fclose+0x5c>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %eax,%edx
mov    $0x1,%edi
lea    0xe65(%rip),%rsi
call   1070 <svz_log@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b3 <svz_fclose+0x63>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<svz_fclose>:
push   %rbx
mov    %rdi,%rbx
call   1050 <fileno@plt>
mov    %eax,%edi
call   1040 <svz_file_del@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
js     1174 <svz_fclose+0x24>
pop    %rbx
ret
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe77(%rip),%rsi
mov    $0x1,%edi
mov    %eax,%edx
call   1070 <svz_log@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"fclose: %s\0A\00"
@errno = global i32 0
define i32 @svz_fclose(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
store i32* %0, i32** %3
%4 = load i32*, i32** %3
%5 = call i32 @fileno(i32* %4)
%6 = call i32 @svz_file_del(i32 %5)
%7 = load i32*, i32** %3
%8 = call i64 @fclose(i32* %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* @errno
%12 = call i32 @strerror(i32 %11)
%13 = call i32 @svz_log(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %12)
store i32 -1, i32* %2
br label %15
14: ; preds = %1
store i32 0, i32* %2
br label %15
15: ; preds = %14, %10
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
@.str = [12 x i8] c"fclose: %s\0A\00"
@errno = global i32 0
define i32 @svz_fclose(i32* nocapture %0) {
%2 = tail call i32 @fileno(i32* %0)
%3 = tail call i32 @svz_file_del(i32 %2)
%4 = tail call i64 @fclose(i32* %0)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* @errno
%8 = tail call i32 @strerror(i32 %7)
%9 = tail call i32 @svz_log(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %1, %6
%11 = phi i32 [ -1, %6 ], [ 0, %1 ]
ret i32 %11
}