#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
int ldexp(float, int);
float IEE754_binary32_decode(char out[4]) {
  bool sign = out[0] & 0x80;
  uint8_t exponent = ((out[0] << 1) & 0xFE) | ((out[1] >> 7) & 0x01);
  uint32_t fraction = ((uint32_t)(out[1] & 0x7F) << 16) |
                      ((uint32_t)(out[2] & 0xFF) << 8) |
                      (uint32_t)(out[3] & 0xFF) | ((uint32_t)1 << 23);
  float frac = (float)fraction / ((uint32_t)2 << 23);
  if (exponent == 0xFF) {
    if (fraction == (uint32_t)1 << 23) {
      return sign ? -1.0 / 0.0 : 1.0 / 0.0;
    } else {
      return sign ? 0.0 / 0.0 : -(0.0 / 0.0);
    }
  }
  return ldexp(frac, exponent - 126) * (sign ? -1 : 1);
}


x86 assembly (clang, -O0):
<IEE754_binary32_decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
and    $0x80,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
shl    $0x1,%eax
and    $0xfe,%eax
mov    -0x10(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
sar    $0x7,%ecx
and    $0x1,%ecx
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
and    $0x7f,%eax
shl    $0x10,%eax
mov    -0x10(%rbp),%rcx
movsbl 0x2(%rcx),%ecx
and    $0xff,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
movsbl 0x3(%rcx),%ecx
and    $0xff,%ecx
or     %ecx,%eax
or     $0x800000,%eax
mov    %eax,-0x1c(%rbp)
cvtsi2ssl -0x1c(%rbp),%xmm0
movss  0xe6d(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
cmpl   $0xff,-0x18(%rbp)
jne    123a <IEE754_binary32_decode+0x12a>
cmpl   $0x800000,-0x1c(%rbp)
jne    11f9 <IEE754_binary32_decode+0xe9>
mov    -0x14(%rbp),%eax
movsd  0xe57(%rip),%xmm0
movsd  0xe57(%rip),%xmm1
movsd  %xmm1,-0x30(%rbp)
cmp    $0x0,%eax
movsd  %xmm0,-0x28(%rbp)
jne    11e6 <IEE754_binary32_decode+0xd6>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1269 <IEE754_binary32_decode+0x159>
cmpl   $0x0,-0x14(%rbp)
je     1215 <IEE754_binary32_decode+0x105>
movsd  0xe05(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1227 <IEE754_binary32_decode+0x117>
movsd  0xdeb(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1227 <IEE754_binary32_decode+0x117>
movsd  -0x38(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1269 <IEE754_binary32_decode+0x159>
movss  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%edi
sub    $0x7e,%edi
call   1030 <ldexp@plt>
mov    -0x14(%rbp),%esi
mov    $0x1,%ecx
mov    $0xffffffff,%edx
cmp    $0x0,%esi
cmovne %edx,%ecx
imul   %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IEE754_binary32_decode>:
push   %rbx
mov    %rdi,%rax
movsbl (%rdi),%ebx
mov    %ebx,%ecx
and    $0x7f,%ecx
movsbl 0x1(%rdi),%edx
mov    %edx,%esi
shr    $0x7,%esi
and    $0x1,%esi
lea    (%rsi,%rcx,2),%edi
and    $0x7f,%edx
shl    $0x10,%edx
movzbl 0x2(%rax),%ecx
shl    $0x8,%ecx
or     %edx,%ecx
movzbl 0x3(%rax),%eax
add    %ecx,%eax
add    $0x800000,%eax
cmp    $0xff,%edi
jne    1165 <IEE754_binary32_decode+0x55>
cmp    $0x800000,%eax
jne    118c <IEE754_binary32_decode+0x7c>
xor    %eax,%eax
test   $0x80,%bl
sete   %al
lea    0xea9(%rip),%rcx
jmp    119b <IEE754_binary32_decode+0x8b>
cvtsi2ss %eax,%xmm0
mulss  0xe8f(%rip),%xmm0
add    $0xffffff82,%edi
call   1030 <ldexp@plt>
mov    %eax,%ecx
neg    %ecx
test   $0x80,%bl
cmove  %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
pop    %rbx
ret
xor    %eax,%eax
test   $0x80,%bl
sete   %al
lea    0xe69(%rip),%rcx
movss  (%rcx,%rax,4),%xmm0
pop    %rbx
ret

LLVM IR (-O0):
define float @IEE754_binary32_decode(i8* %0) {
%2 = alloca float
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = and i32 %11, 128
store i32 %12, i32* %4
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = shl i32 %16, 1
%18 = and i32 %17, 254
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = ashr i32 %22, 7
%24 = and i32 %23, 1
%25 = or i32 %18, %24
store i32 %25, i32* %5
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = and i32 %29, 127
%31 = shl i32 %30, 16
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 2
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = and i32 %35, 255
%37 = shl i32 %36, 8
%38 = or i32 %31, %37
%39 = load i8*, i8** %3
%40 = getelementptr inbounds i8, i8* %39, i64 3
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = and i32 %42, 255
%44 = or i32 %38, %43
%45 = or i32 %44, 8388608
store i32 %45, i32* %6
%46 = load i32, i32* %6
%47 = sitofp i32 %46 to float
%48 = fdiv float %47, 0x4170000000000000
store float %48, float* %7
%49 = load i32, i32* %5
%50 = icmp eq i32 %49, 255
br i1 %50, label %51, label %68
51: ; preds = %1
%52 = load i32, i32* %6
%53 = icmp eq i32 %52, 8388608
br i1 %53, label %54, label %60
54: ; preds = %51
%55 = load i32, i32* %4
%56 = icmp ne i32 %55, 0
%57 = zext i1 %56 to i64
%58 = select i1 %56, double 0xFFF0000000000000, double 0x7FF0000000000000
%59 = fptrunc double %58 to float
store float %59, float* %2
br label %79
60: ; preds = %51
%61 = load i32, i32* %4
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %60
br label %65
64: ; preds = %60
br label %65
65: ; preds = %64, %63
%66 = phi double [ 0x7FF8000000000000, %63 ], [ 0xFFF8000000000000, %64 ]
%67 = fptrunc double %66 to float
store float %67, float* %2
br label %79
68: ; preds = %1
%69 = load float, float* %7
%70 = load i32, i32* %5
%71 = sub nsw i32 %70, 126
%72 = call i32 @ldexp(float %69, i32 %71)
%73 = load i32, i32* %4
%74 = icmp ne i32 %73, 0
%75 = zext i1 %74 to i64
%76 = select i1 %74, i32 -1, i32 1
%77 = mul nsw i32 %72, %76
%78 = sitofp i32 %77 to float
store float %78, float* %2
br label %79
79: ; preds = %68, %65, %54
%80 = load float, float* %2
ret float %80
}

LLVM IR (-O2):
define float @IEE754_binary32_decode(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
%4 = and i32 %3, 128
%5 = shl nsw i32 %3, 1
%6 = and i32 %5, 254
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = lshr i32 %9, 7
%11 = and i32 %10, 1
%12 = or i32 %11, %6
%13 = shl nsw i32 %9, 16
%14 = and i32 %13, 8323072
%15 = getelementptr inbounds i8, i8* %0, i64 2
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = shl nuw nsw i32 %17, 8
%19 = or i32 %14, %18
%20 = getelementptr inbounds i8, i8* %0, i64 3
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = or i32 %19, %22
%24 = or i32 %23, 8388608
%25 = icmp eq i32 %12, 255
br i1 %25, label %26, label %33
26: ; preds = %1
%27 = icmp eq i32 %24, 8388608
%28 = icmp eq i32 %4, 0
br i1 %27, label %29, label %31
29: ; preds = %26
%30 = select i1 %28, float 0x7FF0000000000000, float 0xFFF0000000000000
br label %42
31: ; preds = %26
%32 = select i1 %28, float 0xFFF8000000000000, float 0x7FF8000000000000
br label %42
33: ; preds = %1
%34 = sitofp i32 %24 to float
%35 = fmul float %34, 0x3E70000000000000
%36 = add nsw i32 %12, -126
%37 = tail call i32 @ldexp(float %35, i32 %36)
%38 = icmp eq i32 %4, 0
%39 = sub nsw i32 0, %37
%40 = select i1 %38, i32 %37, i32 %39
%41 = sitofp i32 %40 to float
br label %42
42: ; preds = %33, %31, %29
%43 = phi float [ %30, %29 ], [ %32, %31 ], [ %41, %33 ]
ret float %43
}