#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 */
double pow(int, int);
double IEEE754todouble(unsigned int ip) {
  unsigned int sn = 0, ep = 0, ma;
  double op;
  sn = (ip >> 31) & 0x1;
  ep = (ip >> 23) & 0xff;
  ma = ip & 0x7fffff;
  if (ep == 0) {
    op = (double)ma / (double)(1 << 23);
    op *= pow(2, (-126.0));
  } else {
    op = (double)(ma | (1 << 23)) / (double)(1 << 23);
    op *= pow(2, (((int)ep) - 127.0));
  }
  if (sn)
    op = -op;
  return op;
}


x86 assembly (clang, -O0):
<IEEE754todouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
shr    $0x1f,%eax
and    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
shr    $0x17,%eax
and    $0xff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
and    $0x7fffff,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    118f <IEEE754todouble+0x7f>
mov    -0x10(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xea0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x2,%edi
mov    $0xffffff82,%esi
call   1030 <pow@plt>
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11d6 <IEEE754todouble+0xc6>
mov    -0x10(%rbp),%eax
or     $0x800000,%eax
cvtsi2sd %rax,%xmm0
movsd  0xe64(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xe46(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
mov    $0x2,%edi
call   1030 <pow@plt>
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1201 <IEEE754todouble+0xf1>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IEEE754todouble>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    %edi,%eax
shr    $0x17,%eax
movzbl %al,%eax
mov    %edi,%ecx
and    $0x7fffff,%ecx
lea    0x800000(%rcx),%edx
lea    -0x7f(%rax),%edi
test   %eax,%eax
mov    $0xffffff82,%esi
cmovne %edi,%esi
cmove  %ecx,%edx
cvtsi2sd %edx,%xmm0
mulsd  0xeb7(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
test   %ebx,%ebx
jns    116b <IEEE754todouble+0x5b>
xorpd  0xea5(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @IEEE754todouble(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%7 = load i32, i32* %2
%8 = lshr i32 %7, 31
%9 = and i32 %8, 1
store i32 %9, i32* %3
%10 = load i32, i32* %2
%11 = lshr i32 %10, 23
%12 = and i32 %11, 255
store i32 %12, i32* %4
%13 = load i32, i32* %2
%14 = and i32 %13, 8388607
store i32 %14, i32* %5
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %1
%18 = load i32, i32* %5
%19 = uitofp i32 %18 to double
%20 = fdiv double %19, 0x4160000000000000
store double %20, double* %6
%21 = call double @pow(i32 2, i32 -126)
%22 = load double, double* %6
%23 = fmul double %22, %21
store double %23, double* %6
br label %36
24: ; preds = %1
%25 = load i32, i32* %5
%26 = or i32 %25, 8388608
%27 = uitofp i32 %26 to double
%28 = fdiv double %27, 0x4160000000000000
store double %28, double* %6
%29 = load i32, i32* %4
%30 = sitofp i32 %29 to double
%31 = fsub double %30, 1.270000e+02
%32 = fptosi double %31 to i32
%33 = call double @pow(i32 2, i32 %32)
%34 = load double, double* %6
%35 = fmul double %34, %33
store double %35, double* %6
br label %36
36: ; preds = %24, %17
%37 = load i32, i32* %3
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load double, double* %6
%41 = fneg double %40
store double %41, double* %6
br label %42
42: ; preds = %39, %36
%43 = load double, double* %6
ret double %43
}

LLVM IR (-O2):
define double @IEEE754todouble(i32 %0) {
%2 = lshr i32 %0, 23
%3 = and i32 %2, 255
%4 = and i32 %0, 8388607
%5 = icmp eq i32 %3, 0
%6 = or i32 %4, 8388608
%7 = add nsw i32 %3, -127
%8 = select i1 %5, i32 -126, i32 %7
%9 = select i1 %5, i32 %4, i32 %6
%10 = uitofp i32 %9 to double
%11 = fmul double %10, 0x3E80000000000000
%12 = tail call double @pow(i32 2, i32 %8)
%13 = fmul double %11, %12
%14 = icmp sgt i32 %0, -1
%15 = fneg double %13
%16 = select i1 %14, double %13, double %15
ret double %16
}