#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 *);
float *ldr_to_hdr(unsigned char *, int, int, int);
float *stbi_hdr_load_from_file(int /*<<< orphan*/ *, int *, int *, int *, int);
scalar_t__ stbi_hdr_test_file(int /*<<< orphan*/ *);
unsigned char *stbi_load_from_file(int /*<<< orphan*/ *, int *, int *, int *,
                                   int);
float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) {
  unsigned char *data;
  if (stbi_hdr_test_file(f))
    return stbi_hdr_load_from_file(f, x, y, comp, req_comp);
  data = stbi_load_from_file(f, x, y, comp, req_comp);
  if (data)
    return ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp);
  return (
      (float *)(e("Image not of any known type, or corrupt") ? NULL : NULL));
}


x86 assembly (clang, -O0):
<stbi_loadf_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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
call   1040 <stbi_hdr_test_file@plt>
cmp    $0x0,%rax
je     11a1 <stbi_loadf_from_file+0x51>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1030 <stbi_hdr_load_from_file@plt>
mov    %rax,-0x8(%rbp)
jmp    1239 <stbi_loadf_from_file+0xe9>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1050 <stbi_load_from_file@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     121c <stbi_loadf_from_file+0xcc>
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     11f8 <stbi_loadf_from_file+0xa8>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    1201 <stbi_loadf_from_file+0xb1>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x3c(%rbp),%edx
mov    -0x40(%rbp),%esi
mov    -0x48(%rbp),%rdi
mov    -0x4c(%rbp),%ecx
call   1070 <ldr_to_hdr@plt>
mov    %rax,-0x8(%rbp)
jmp    1239 <stbi_loadf_from_file+0xe9>
lea    0xddd(%rip),%rdi
call   1060 <e@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
cmovne %rax,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stbi_loadf_from_file>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r15d
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%rbp
mov    %rdi,%rbx
call   1040 <stbi_hdr_test_file@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     118d <stbi_loadf_from_file+0x3d>
mov    %rbp,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
mov    %r15d,%r8d
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <stbi_hdr_load_from_file@plt>
mov    %rbp,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
mov    %r15d,%r8d
call   1050 <stbi_load_from_file@plt>
test   %rax,%rax
je     11c5 <stbi_loadf_from_file+0x75>
mov    0x0(%rbp),%esi
mov    (%r12),%edx
test   %r15d,%r15d
jne    11b2 <stbi_loadf_from_file+0x62>
mov    (%r14),%r15d
mov    %rax,%rdi
mov    %r15d,%ecx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <ldr_to_hdr@plt>
lea    0xe34(%rip),%rdi
call   1060 <e@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"Image not of any known type, or corrupt\00"
define float* @stbi_loadf_from_file(i32* %0, i32* %1, i32* %2, i32* %3, i32 %4) {
%6 = alloca float*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i8*
store i32* %0, i32** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32 %4, i32* %11
%13 = load i32*, i32** %7
%14 = call i64 @stbi_hdr_test_file(i32* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %5
%17 = load i32*, i32** %7
%18 = load i32*, i32** %8
%19 = load i32*, i32** %9
%20 = load i32*, i32** %10
%21 = load i32, i32* %11
%22 = call float* @stbi_hdr_load_from_file(i32* %17, i32* %18, i32* %19, i32* %20, i32 %21)
store float* %22, float** %6
br label %54
23: ; preds = %5
%24 = load i32*, i32** %7
%25 = load i32*, i32** %8
%26 = load i32*, i32** %9
%27 = load i32*, i32** %10
%28 = load i32, i32* %11
%29 = call i8* @stbi_load_from_file(i32* %24, i32* %25, i32* %26, i32* %27, i32 %28)
store i8* %29, i8** %12
%30 = load i8*, i8** %12
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %48
32: ; preds = %23
%33 = load i8*, i8** %12
%34 = load i32*, i32** %8
%35 = load i32, i32* %34
%36 = load i32*, i32** %9
%37 = load i32, i32* %36
%38 = load i32, i32* %11
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %32
%41 = load i32, i32* %11
br label %45
42: ; preds = %32
%43 = load i32*, i32** %10
%44 = load i32, i32* %43
br label %45
45: ; preds = %42, %40
%46 = phi i32 [ %41, %40 ], [ %44, %42 ]
%47 = call float* @ldr_to_hdr(i8* %33, i32 %35, i32 %37, i32 %46)
store float* %47, float** %6
br label %54
48: ; preds = %23
%49 = call i64 @e(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%50 = icmp ne i64 %49, 0
%51 = zext i1 %50 to i64
%52 = select i1 %50, i8* null, i8* null
%53 = bitcast i8* %52 to float*
store float* %53, float** %6
br label %54
54: ; preds = %48, %45, %16
%55 = load float*, float** %6
ret float* %55
}

LLVM IR (-O2):
@.str = [40 x i8] c"Image not of any known type, or corrupt\00"
define float* @stbi_loadf_from_file(i32* %0, i32* %1, i32* %2, i32* %3, i32 %4) {
%6 = tail call i64 @stbi_hdr_test_file(i32* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call float* @stbi_hdr_load_from_file(i32* %0, i32* %1, i32* %2, i32* %3, i32 %4)
br label %24
10: ; preds = %5
%11 = tail call i8* @stbi_load_from_file(i32* %0, i32* %1, i32* %2, i32* %3, i32 %4)
%12 = icmp eq i8* %11, null
br i1 %12, label %22, label %13
13: ; preds = %10
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = icmp eq i32 %4, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = load i32, i32* %3
br label %19
19: ; preds = %13, %17
%20 = phi i32 [ %18, %17 ], [ %4, %13 ]
%21 = tail call float* @ldr_to_hdr(i8* %11, i32 %14, i32 %15, i32 %20)
br label %24
22: ; preds = %10
%23 = tail call i64 @e(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %19, %8
%25 = phi float* [ %9, %8 ], [ %21, %19 ], [ null, %22 ]
ret float* %25
}