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


x86 assembly (clang, -O0):
<editFic>:
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 <editFic+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    11f5 <editFic+0xa5>
mov    -0x18(%rbp),%rdi
call   1060 <verifyFicHeader@plt>
cmp    $0x0,%rax
je     11b8 <editFic+0x68>
jmp    11ee <editFic+0x9e>
mov    -0x18(%rbp),%rdi
call   1030 <modifyPages@plt>
cmp    $0x0,%rax
je     11d0 <editFic+0x80>
jmp    11e5 <editFic+0x95>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f5 <editFic+0xa5>
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):
<editFic>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbp
lea    0xea3(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1197 <editFic+0x47>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <verifyFicHeader@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    11b4 <editFic+0x64>
mov    %rbx,%rdi
call   1030 <modifyPages@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    11b4 <editFic+0x64>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe5d(%rip),%rsi
mov    %rbp,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"r+b\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"Unable to open %s!\0A\00"
define i32 @editFic(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 @verifyFicHeader(i32* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
br label %29
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
%27 = load i32*, i32** %4
%28 = call i32 @fclose(i32* %27)
br label %29
29: ; preds = %26, %17
store i32 1, i32* %2
br label %30
30: ; preds = %29, %23, %9
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [4 x i8] c"r+b\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"Unable to open %s!\0A\00"
define i32 @editFic(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 %15
7: ; preds = %1
%8 = tail call i64 @verifyFicHeader(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 ne i64 %11, 0
%13 = tail call i32 @fclose(i32* %2)
%14 = zext i1 %12 to i32
br label %15
15: ; preds = %10, %7, %4
%16 = phi i32 [ 1, %4 ], [ 1, %7 ], [ %14, %10 ]
ret i32 %16
}