#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 */

/* Variables and functions */
float ldexp(double, unsigned char);
void rgbe2float(float *red, float *green, float *blue, unsigned char rgbe[4]) {
  float f;
  if (rgbe[3]) {
    f = ldexp(1.0, rgbe[3] - (int)(128 + 8));
    *red = rgbe[0] * f;
    *green = rgbe[1] * f;
    *blue = rgbe[2] * f;
  } else
    *red = *green = *blue = 0.0;
}


x86 assembly (clang, -O0):
<rgbe2float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,0x3(%rax)
je     11a7 <rgbe2float+0x97>
mov    -0x20(%rbp),%rax
movzbl 0x3(%rax),%eax
sub    $0x88,%eax
movsd  0xeb5(%rip),%xmm0
movzbl %al,%edi
call   1030 <ldexp@plt>
movss  %xmm0,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cvtsi2ss %eax,%xmm0
mulss  -0x24(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%eax
cvtsi2ss %eax,%xmm0
mulss  -0x24(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movzbl 0x2(%rax),%eax
cvtsi2ss %eax,%xmm0
mulss  -0x24(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    11c8 <rgbe2float+0xb8>
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rgbe2float>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    0x3(%rcx),%al
test   %al,%al
je     1178 <rgbe2float+0x68>
mov    %rcx,%rbx
add    $0x78,%al
movzbl %al,%edi
movsd  0xec8(%rip),%xmm0
call   1030 <ldexp@plt>
movzbl (%rbx),%eax
cvtsi2ss %eax,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%r12)
movzbl 0x1(%rbx),%eax
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%r15)
movzbl 0x2(%rbx),%eax
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%r14)
jmp    118e <rgbe2float+0x7e>
movl   $0x0,(%r14)
movl   $0x0,(%r15)
movl   $0x0,(%r12)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @rgbe2float(float* %0, float* %1, float* %2, i8* %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca i8*
%9 = alloca float
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %7
store i8* %3, i8** %8
%10 = load i8*, i8** %8
%11 = getelementptr inbounds i8, i8* %10, i64 3
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %46
14: ; preds = %4
%15 = load i8*, i8** %8
%16 = getelementptr inbounds i8, i8* %15, i64 3
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = sub nsw i32 %18, 136
%20 = trunc i32 %19 to i8
%21 = call float @ldexp(double 1.000000e+00, i8 zeroext %20)
store float %21, float* %9
%22 = load i8*, i8** %8
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = sitofp i32 %25 to float
%27 = load float, float* %9
%28 = fmul float %26, %27
%29 = load float*, float** %5
store float %28, float* %29
%30 = load i8*, i8** %8
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = sitofp i32 %33 to float
%35 = load float, float* %9
%36 = fmul float %34, %35
%37 = load float*, float** %6
store float %36, float* %37
%38 = load i8*, i8** %8
%39 = getelementptr inbounds i8, i8* %38, i64 2
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = sitofp i32 %41 to float
%43 = load float, float* %9
%44 = fmul float %42, %43
%45 = load float*, float** %7
store float %44, float* %45
br label %50
46: ; preds = %4
%47 = load float*, float** %7
store float 0.000000e+00, float* %47
%48 = load float*, float** %6
store float 0.000000e+00, float* %48
%49 = load float*, float** %5
store float 0.000000e+00, float* %49
br label %50
50: ; preds = %46, %14
ret void
}

LLVM IR (-O2):
define void @rgbe2float(float* nocapture writeonly %0, float* nocapture writeonly %1, float* nocapture writeonly %2, i8* nocapture %3) {
%5 = getelementptr inbounds i8, i8* %3, i64 3
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %22, label %8
8: ; preds = %4
%9 = add i8 %6, 120
%10 = tail call float @ldexp(double 1.000000e+00, i8 zeroext %9)
%11 = load i8, i8* %3
%12 = uitofp i8 %11 to float
%13 = fmul float %10, %12
store float %13, float* %0
%14 = getelementptr inbounds i8, i8* %3, i64 1
%15 = load i8, i8* %14
%16 = uitofp i8 %15 to float
%17 = fmul float %10, %16
store float %17, float* %1
%18 = getelementptr inbounds i8, i8* %3, i64 2
%19 = load i8, i8* %18
%20 = uitofp i8 %19 to float
%21 = fmul float %10, %20
store float %21, float* %2
br label %23
22: ; preds = %4
store float 0.000000e+00, float* %2
store float 0.000000e+00, float* %1
store float 0.000000e+00, float* %0
br label %23
23: ; preds = %22, %8
ret void
}