#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 */
scalar_t__ ldexp(double, unsigned char);
void VIGRA_rgbe2float(float *red, float *green, float *blue,
                      unsigned char rgbe[4]) {
  float f;
  if (rgbe[3]) {
    f = (float)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):
<VIGRA_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     11ac <VIGRA_rgbe2float+0x9c>
mov    -0x20(%rbp),%rax
movzbl 0x3(%rax),%eax
sub    $0x88,%eax
movsd  0xeb5(%rip),%xmm0
movzbl %al,%edi
call   1030 <ldexp@plt>
cvtsi2ss %rax,%xmm0
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    11cd <VIGRA_rgbe2float+0xbd>
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):
<VIGRA_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     1180 <VIGRA_rgbe2float+0x70>
mov    %rcx,%rbx
add    $0x78,%al
movzbl %al,%edi
movsd  0xec8(%rip),%xmm0
call   1030 <ldexp@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
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    1196 <VIGRA_rgbe2float+0x86>
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 @VIGRA_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 %47
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 i64 @ldexp(double 1.000000e+00, i8 zeroext %20)
%22 = sitofp i64 %21 to float
store float %22, float* %9
%23 = load i8*, i8** %8
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = sitofp i32 %26 to float
%28 = load float, float* %9
%29 = fmul float %27, %28
%30 = load float*, float** %5
store float %29, float* %30
%31 = load i8*, i8** %8
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = sitofp i32 %34 to float
%36 = load float, float* %9
%37 = fmul float %35, %36
%38 = load float*, float** %6
store float %37, float* %38
%39 = load i8*, i8** %8
%40 = getelementptr inbounds i8, i8* %39, i64 2
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = sitofp i32 %42 to float
%44 = load float, float* %9
%45 = fmul float %43, %44
%46 = load float*, float** %7
store float %45, float* %46
br label %51
47: ; preds = %4
%48 = load float*, float** %7
store float 0.000000e+00, float* %48
%49 = load float*, float** %6
store float 0.000000e+00, float* %49
%50 = load float*, float** %5
store float 0.000000e+00, float* %50
br label %51
51: ; preds = %47, %14
ret void
}

LLVM IR (-O2):
define void @VIGRA_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 %23, label %8
8: ; preds = %4
%9 = add i8 %6, 120
%10 = tail call i64 @ldexp(double 1.000000e+00, i8 zeroext %9)
%11 = sitofp i64 %10 to float
%12 = load i8, i8* %3
%13 = uitofp i8 %12 to float
%14 = fmul float %11, %13
store float %14, float* %0
%15 = getelementptr inbounds i8, i8* %3, i64 1
%16 = load i8, i8* %15
%17 = uitofp i8 %16 to float
%18 = fmul float %11, %17
store float %18, float* %1
%19 = getelementptr inbounds i8, i8* %3, i64 2
%20 = load i8, i8* %19
%21 = uitofp i8 %20 to float
%22 = fmul float %11, %21
store float %22, float* %2
br label %24
23: ; 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 %24
24: ; preds = %23, %8
ret void
}