#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*/ *const);
int /*<<< orphan*/ *fopen(char const *const, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *const);
scalar_t__ modifyPages(int /*<<< orphan*/ *const);
int /*<<< orphan*/ stderr;
scalar_t__ writeFicHeader(int /*<<< orphan*/ *const);
unsigned createNewFic(const char *const fLoc) {
  FILE *const fp = fopen(fLoc, "w+b");
  if (!fp) {
    fprintf(stderr, "Unable to open %s!\n", fLoc);
    return 1;
  }
  if (writeFicHeader(fp)) {
    goto exit_header_write;
  }
  if (modifyPages(fp)) {
    goto exit_modify_pages;
  }
  fclose(fp);
  return 0;
exit_modify_pages:
exit_header_write:
  fclose(fp);
  return 1;
}


x86 assembly (clang, -O0):
<createNewFic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a0 <createNewFic+0x50>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe75(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fa <createNewFic+0xaa>
mov    -0x18(%rbp),%rdi
call   1060 <writeFicHeader@plt>
cmp    $0x0,%rax
je     11b8 <createNewFic+0x68>
jmp    11ea <createNewFic+0x9a>
mov    -0x18(%rbp),%rdi
call   1030 <modifyPages@plt>
cmp    $0x0,%rax
je     11d0 <createNewFic+0x80>
jmp    11e5 <createNewFic+0x95>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    11fa <createNewFic+0xaa>
jmp    11ea <createNewFic+0x9a>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createNewFic>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xea2(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     118f <createNewFic+0x3f>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <writeFicHeader@plt>
test   %rax,%rax
jne    1185 <createNewFic+0x35>
mov    %rbx,%rdi
call   1030 <modifyPages@plt>
test   %rax,%rax
je     11b4 <createNewFic+0x64>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    11a7 <createNewFic+0x57>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
mov    %r14,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11ac <createNewFic+0x5c>

LLVM IR (-O0):
@.str = [4 x i8] c"w+b\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"Unable to open %s!\0A\00"
define i32 @createNewFic(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %4
%7 = load i32*, i32** %4
%8 = icmp ne i32* %7, null
br i1 %8, label %13, label %9
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %3
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %11)
store i32 1, i32* %2
br label %30
13: ; preds = %1
%14 = load i32*, i32** %4
%15 = call i64 @writeFicHeader(i32* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
br label %27
18: ; preds = %13
%19 = load i32*, i32** %4
%20 = call i64 @modifyPages(i32* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
br label %26
23: ; preds = %18
%24 = load i32*, i32** %4
%25 = call i32 @fclose(i32* %24)
store i32 0, i32* %2
br label %30
26: ; preds = %22
br label %27
27: ; preds = %26, %17
%28 = load i32*, i32** %4
%29 = call i32 @fclose(i32* %28)
store i32 1, i32* %2
br label %30
30: ; preds = %27, %23, %9
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [4 x i8] c"w+b\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"Unable to open %s!\0A\00"
define i32 @createNewFic(i8* %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %17
7: ; preds = %1
%8 = tail call i64 @writeFicHeader(i32* %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = tail call i64 @modifyPages(i32* %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @fclose(i32* %2)
br label %17
15: ; preds = %10, %7
%16 = tail call i32 @fclose(i32* %2)
br label %17
17: ; preds = %15, %13, %4
%18 = phi i32 [ 1, %15 ], [ 0, %13 ], [ 1, %4 ]
ret i32 %18
}