#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;
int /*<<< orphan*/ errorout(char *, char const *const, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *const, char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ unlink(char const *const);
void newIniBackupFile(const char *const __restrict fname) {
  FILE *__restrict f = fopen(fname, "wb");
  if (!f) {
    errorout("Fatal: Cannot create %s: %s\n", fname, strerror(errno));
    exit(!0);
  }
  if (fclose(f)) {
    errorout("Fatal: Cannot write to %s: %s\n", fname, strerror(errno));
    unlink(fname);
    exit(!0);
  }
}


x86 assembly (clang, -O0):
<newIniBackupFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11bd <newIniBackupFile+0x5d>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
lea    0xe55(%rip),%rdi
call   1040 <errorout@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
cmp    $0x0,%rax
je     120b <newIniBackupFile+0xab>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
lea    0xe2d(%rip),%rdi
call   1040 <errorout@plt>
mov    -0x8(%rbp),%rdi
call   1030 <unlink@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newIniBackupFile>:
push   %rbx
mov    %rdi,%rbx
lea    0xe95(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1184 <newIniBackupFile+0x24>
mov    %rax,%rdi
call   1050 <fclose@plt>
test   %rax,%rax
jne    11ad <newIniBackupFile+0x4d>
pop    %rbx
ret
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe6a(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <errorout@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe5e(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <errorout@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"wb\00"
@.str.1 = [29 x i8] c"Fatal: Cannot create %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [31 x i8] c"Fatal: Cannot write to %s: %s\0A\00"
define void @newIniBackupFile(i8* noalias %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %14, label %8
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = load i32, i32* @errno
%11 = call i32 @strerror(i32 %10)
%12 = call i32 @errorout(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %9, i32 %11)
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %1
%15 = load i32*, i32** %3
%16 = call i64 @fclose(i32* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i8*, i8** %2
%20 = load i32, i32* @errno
%21 = call i32 @strerror(i32 %20)
%22 = call i32 @errorout(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %19, i32 %21)
%23 = load i8*, i8** %2
%24 = call i32 @unlink(i8* %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"wb\00"
@.str.1 = [29 x i8] c"Fatal: Cannot create %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [31 x i8] c"Fatal: Cannot write to %s: %s\0A\00"
define void @newIniBackupFile(i8* noalias %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = load i32, i32* @errno
%6 = tail call i32 @strerror(i32 %5)
%7 = tail call i32 @errorout(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %1
%10 = tail call i64 @fclose(i32* %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %9
%13 = load i32, i32* @errno
%14 = tail call i32 @strerror(i32 %13)
%15 = tail call i32 @errorout(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %14)
%16 = tail call i32 @unlink(i8* %0)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %9
ret void
}