#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 */
scalar_t__ e(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
float *stbi_loadf_from_file(int /*<<< orphan*/ *, int *, int *, int *, int);
float *stbi_loadf(char const *filename, int *x, int *y, int *comp,
                  int req_comp) {
  FILE *f = fopen(filename, "rb");
  float *result;
  if (!f)
    return ((float *)(e("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   1060 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    119d <stbi_loadf+0x5d>
lea    0xe81(%rip),%rdi
call   1050 <e@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
cmovne %rax,%rax
mov    %rax,-0x8(%rbp)
jmp    11cb <stbi_loadf+0x8b>
mov    -0x38(%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,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x40(%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   1060 <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   1050 <e@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 i32*
%13 = alloca float*
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* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %12
%16 = load i32*, i32** %12
%17 = icmp ne i32* %16, null
br i1 %17, label %24, label %18
18: ; preds = %5
%19 = call i64 @e(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 = bitcast i8* %22 to float*
store float* %23, float** %6
br label %34
24: ; preds = %5
%25 = load i32*, i32** %12
%26 = load i32*, i32** %8
%27 = load i32*, i32** %9
%28 = load i32*, i32** %10
%29 = load i32, i32* %11
%30 = call float* @stbi_loadf_from_file(i32* %25, i32* %26, i32* %27, i32* %28, i32 %29)
store float* %30, float** %13
%31 = load i32*, i32** %12
%32 = call i32 @fclose(i32* %31)
%33 = load float*, float** %13
store float* %33, float** %6
br label %34
34: ; preds = %24, %18
%35 = load float*, float** %6
ret float* %35
}

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* nocapture %0, i32* %1, i32* %2, i32* %3, i32 %4) {
%6 = tail call i32* @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 @e(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
}