#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*/ *);
scalar_t__ stbi__err(char *);
int /*<<< orphan*/ *stbi__fopen(char const *, char *);
float *stbi_loadf_from_file(int /*<<< orphan*/ *, int *, int *, int *, int);
extern float *stbi_loadf(char const *filename, int *x, int *y, int *comp,
                         int req_comp) {
  float *result;
  FILE *f = stbi__fopen(filename, "rb");
  if (!f)
    return ((float *)(size_t)(stbi__err("can't fopen") ? NULL : NULL));
  result = stbi_loadf_from_file(f, x, y, comp, req_comp);
  fclose(f);
  return result;
}


x86 assembly (clang, -O0):
<stbi_loadf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1050 <stbi__fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    119d <stbi_loadf+0x5d>
lea    0xe81(%rip),%rdi
call   1060 <stbi__err@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
cmovne %rax,%rax
mov    %rax,-0x8(%rbp)
jmp    11cb <stbi_loadf+0x8b>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1030 <stbi_loadf_from_file@plt>
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stbi_loadf>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
lea    0xea5(%rip),%rsi
call   1050 <stbi__fopen@plt>
test   %rax,%rax
je     118c <stbi_loadf+0x4c>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14d,%r8d
call   1030 <stbi_loadf_from_file@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rax
jmp    119a <stbi_loadf+0x5a>
lea    0xe70(%rip),%rdi
call   1060 <stbi__err@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [12 x i8] c"can't fopen\00"
define float* @stbi_loadf(i8* %0, i32* %1, i32* %2, i32* %3, i32 %4) {
%6 = alloca float*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca float*
%13 = alloca i32*
store i8* %0, i8** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32 %4, i32* %11
%14 = load i8*, i8** %7
%15 = call i32* @stbi__fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %13
%16 = load i32*, i32** %13
%17 = icmp ne i32* %16, null
br i1 %17, label %25, label %18
18: ; preds = %5
%19 = call i64 @stbi__err(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* null, i8* null
%23 = ptrtoint i8* %22 to i64
%24 = inttoptr i64 %23 to float*
store float* %24, float** %6
br label %35
25: ; preds = %5
%26 = load i32*, i32** %13
%27 = load i32*, i32** %8
%28 = load i32*, i32** %9
%29 = load i32*, i32** %10
%30 = load i32, i32* %11
%31 = call float* @stbi_loadf_from_file(i32* %26, i32* %27, i32* %28, i32* %29, i32 %30)
store float* %31, float** %12
%32 = load i32*, i32** %13
%33 = call i32 @fclose(i32* %32)
%34 = load float*, float** %12
store float* %34, float** %6
br label %35
35: ; preds = %25, %18
%36 = load float*, float** %6
ret float* %36
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [12 x i8] c"can't fopen\00"
define float* @stbi_loadf(i8* %0, i32* %1, i32* %2, i32* %3, i32 %4) {
%6 = tail call i32* @stbi__fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i64 @stbi__err(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %13
10: ; preds = %5
%11 = tail call float* @stbi_loadf_from_file(i32* %6, i32* %1, i32* %2, i32* %3, i32 %4)
%12 = tail call i32 @fclose(i32* %6)
br label %13
13: ; preds = %10, %8
%14 = phi float* [ %11, %10 ], [ null, %8 ]
ret float* %14
}