#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 */
char *Fnv1a_create_string_from_file(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *const, char *);
char *Fnv1a_create_string_from_path(char const *const inPathPtr) {
  char *retVal = NULL;
  if (inPathPtr != NULL) {
    FILE *filePtr = fopen(inPathPtr, "rb");
    if (filePtr != NULL) {
      retVal = Fnv1a_create_string_from_file(filePtr);
      fclose(filePtr);
      filePtr = NULL;
    }
  }
  return retVal;
}


x86 assembly (clang, -O0):
<Fnv1a_create_string_from_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1191 <Fnv1a_create_string_from_path+0x61>
mov    -0x8(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118c <Fnv1a_create_string_from_path+0x5c>
mov    -0x18(%rbp),%rdi
call   1050 <Fnv1a_create_string_from_file@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x18(%rbp)
jmp    1191 <Fnv1a_create_string_from_path+0x61>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Fnv1a_create_string_from_path>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1165 <Fnv1a_create_string_from_path+0x35>
lea    0xec0(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     1165 <Fnv1a_create_string_from_path+0x35>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <Fnv1a_create_string_from_file@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rax
jmp    1167 <Fnv1a_create_string_from_path+0x37>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
define i8* @Fnv1a_create_string_from_path(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %2
store i8* null, i8** %3
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %18
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %4
%10 = load i32*, i32** %4
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = load i32*, i32** %4
%14 = call i8* @Fnv1a_create_string_from_file(i32* %13)
store i8* %14, i8** %3
%15 = load i32*, i32** %4
%16 = call i32 @fclose(i32* %15)
store i32* null, i32** %4
br label %17
17: ; preds = %12, %7
br label %18
18: ; preds = %17, %1
%19 = load i8*, i8** %3
ret i8* %19
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
define i8* @Fnv1a_create_string_from_path(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %9, label %3
3: ; preds = %1
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i8* @Fnv1a_create_string_from_file(i32* %4)
%8 = tail call i32 @fclose(i32* %4)
br label %9
9: ; preds = %3, %6, %1
%10 = phi i8* [ null, %1 ], [ %7, %6 ], [ null, %3 ]
ret i8* %10
}