#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 */
int pow(int, int);
long double gstDWord2Float(int lWord, int hWord) {
  long double value = 0.0;
  int sign = 1;
  int exponent;
  int mantissa;
  int temp;
  int i;
  if ((lWord < 0 || lWord > 65535) || (hWord < 0 || hWord > 65535))
    return 0;
  if (hWord > 32768) {
    sign = -1;
  }
  exponent = hWord >> 7;
  exponent = exponent & 0xFF;
  exponent -= 127;
  mantissa = (hWord & 0x7F) << 16;
  mantissa += lWord;
  for (i = 23; i >= 0; i--) {
    temp = mantissa >> i;
    temp = temp & 1;
    value += temp * pow(2, i - 23);
  }
  value = (1 + value) * pow(2, exponent);
  value = value * sign;
  return value;
}


x86 assembly (clang, -O0):
<gstDWord2Float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
fldz
fstpt  -0x30(%rbp)
movl   $0x1,-0x34(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1158 <gstDWord2Float+0x48>
cmpl   $0xffff,-0x14(%rbp)
jg     1158 <gstDWord2Float+0x48>
cmpl   $0x0,-0x18(%rbp)
jl     1158 <gstDWord2Float+0x48>
cmpl   $0xffff,-0x18(%rbp)
jle    1162 <gstDWord2Float+0x52>
fldz
fstpt  -0x10(%rbp)
jmp    1243 <gstDWord2Float+0x133>
cmpl   $0x8000,-0x18(%rbp)
jle    1176 <gstDWord2Float+0x66>
movl   $0xffffffff,-0x34(%rbp)
mov    -0x18(%rbp),%eax
sar    $0x7,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
sub    $0x7f,%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
and    $0x7f,%eax
shl    $0x10,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x14(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movl   $0x17,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jl     1207 <gstDWord2Float+0xf7>
mov    -0x3c(%rbp),%eax
mov    -0x44(%rbp),%cl
sar    %cl,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x44(%rbp),%esi
add    $0xffffffe9,%esi
mov    $0x2,%edi
call   1030 <pow@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x50(%rbp)
fildl  -0x50(%rbp)
fldt   -0x30(%rbp)
faddp  %st,%st(1)
fstpt  -0x30(%rbp)
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
jmp    11af <gstDWord2Float+0x9f>
fldt   -0x30(%rbp)
fld1
faddp  %st,%st(1)
fstpt  -0x60(%rbp)
mov    -0x38(%rbp),%esi
mov    $0x2,%edi
call   1030 <pow@plt>
fldt   -0x60(%rbp)
mov    %eax,-0x4c(%rbp)
fildl  -0x4c(%rbp)
fmulp  %st,%st(1)
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x48(%rbp)
fildl  -0x48(%rbp)
fmulp  %st,%st(1)
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gstDWord2Float>:
mov    %esi,%eax
or     %edi,%eax
fldz
cmp    $0xffff,%eax
ja     123b <gstDWord2Float+0x12b>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %esi,%r15d
fstp   %st(0)
mov    %esi,%eax
shr    $0x7,%eax
movzbl %al,%r14d
mov    %esi,%r12d
and    $0x7f,%r12d
shl    $0x10,%r12d
add    %edi,%r12d
fldz
fstpt  0xc(%rsp)
mov    $0x17,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %r12d,%ebx
mov    %ebp,%ecx
shr    %cl,%ebx
and    $0x1,%ebx
lea    -0x17(%rbp),%r13d
mov    $0x2,%edi
mov    %r13d,%esi
call   1030 <pow@plt>
imul   %ebx,%eax
mov    %eax,0x1c(%rsp)
add    $0x16,%r13b
mov    %r12d,%ebx
mov    %r13d,%ecx
shr    %cl,%ebx
fldt   0xc(%rsp)
fiaddl 0x1c(%rsp)
fstpt  0xc(%rsp)
and    $0x1,%ebx
lea    -0x18(%rbp),%esi
mov    $0x2,%edi
call   1030 <pow@plt>
imul   %ebx,%eax
mov    %eax,0x20(%rsp)
lea    -0x2(%rbp),%r13d
mov    %r12d,%ebx
mov    %r13d,%ecx
shr    %cl,%ebx
fldt   0xc(%rsp)
fiaddl 0x20(%rsp)
fstpt  0xc(%rsp)
and    $0x1,%ebx
add    $0xffffffe7,%ebp
mov    $0x2,%edi
mov    %ebp,%esi
call   1030 <pow@plt>
imul   %ebx,%eax
mov    %eax,0x24(%rsp)
fldt   0xc(%rsp)
fiaddl 0x24(%rsp)
fstpt  0xc(%rsp)
sub    $0x1,%r13d
mov    %r13d,%ebp
jae    1160 <gstDWord2Float+0x50>
add    $0xffffff81,%r14d
mov    $0x2,%edi
mov    %r14d,%esi
call   1030 <pow@plt>
cmp    $0x8001,%r15d
fld1
fldt   0xc(%rsp)
faddp  %st,%st(1)
mov    %eax,0x18(%rsp)
fimull 0x18(%rsp)
fld    %st(0)
fchs
fxch   %st(1)
fcmovnb %st(1),%st
fstp   %st(1)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define x86_fp80 @gstDWord2Float(i32 %0, i32 %1) {
%3 = alloca x86_fp80
%4 = alloca i32
%5 = alloca i32
%6 = alloca x86_fp80
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store x86_fp80 0xK00000000000000000000, x86_fp80* %6
store i32 1, i32* %7
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 0
br i1 %13, label %23, label %14
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 65535
br i1 %16, label %23, label %17
17: ; preds = %14
%18 = load i32, i32* %5
%19 = icmp slt i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* %5
%22 = icmp sgt i32 %21, 65535
br i1 %22, label %23, label %24
23: ; preds = %20, %17, %14, %2
store x86_fp80 0xK00000000000000000000, x86_fp80* %3
br label %73
24: ; preds = %20
%25 = load i32, i32* %5
%26 = icmp sgt i32 %25, 32768
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 -1, i32* %7
br label %28
28: ; preds = %27, %24
%29 = load i32, i32* %5
%30 = ashr i32 %29, 7
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = and i32 %31, 255
store i32 %32, i32* %8
%33 = load i32, i32* %8
%34 = sub nsw i32 %33, 127
store i32 %34, i32* %8
%35 = load i32, i32* %5
%36 = and i32 %35, 127
%37 = shl i32 %36, 16
store i32 %37, i32* %9
%38 = load i32, i32* %4
%39 = load i32, i32* %9
%40 = add nsw i32 %39, %38
store i32 %40, i32* %9
store i32 23, i32* %11
br label %41
41: ; preds = %58, %28
%42 = load i32, i32* %11
%43 = icmp sge i32 %42, 0
br i1 %43, label %44, label %61
44: ; preds = %41
%45 = load i32, i32* %9
%46 = load i32, i32* %11
%47 = ashr i32 %45, %46
store i32 %47, i32* %10
%48 = load i32, i32* %10
%49 = and i32 %48, 1
store i32 %49, i32* %10
%50 = load i32, i32* %10
%51 = load i32, i32* %11
%52 = sub nsw i32 %51, 23
%53 = call i32 @pow(i32 2, i32 %52)
%54 = mul nsw i32 %50, %53
%55 = sitofp i32 %54 to x86_fp80
%56 = load x86_fp80, x86_fp80* %6
%57 = fadd x86_fp80 %56, %55
store x86_fp80 %57, x86_fp80* %6
br label %58
58: ; preds = %44
%59 = load i32, i32* %11
%60 = add nsw i32 %59, -1
store i32 %60, i32* %11
br label %41
61: ; preds = %41
%62 = load x86_fp80, x86_fp80* %6
%63 = fadd x86_fp80 0xK3FFF8000000000000000, %62
%64 = load i32, i32* %8
%65 = call i32 @pow(i32 2, i32 %64)
%66 = sitofp i32 %65 to x86_fp80
%67 = fmul x86_fp80 %63, %66
store x86_fp80 %67, x86_fp80* %6
%68 = load x86_fp80, x86_fp80* %6
%69 = load i32, i32* %7
%70 = sitofp i32 %69 to x86_fp80
%71 = fmul x86_fp80 %68, %70
store x86_fp80 %71, x86_fp80* %6
%72 = load x86_fp80, x86_fp80* %6
store x86_fp80 %72, x86_fp80* %3
br label %73
73: ; preds = %61, %23
%74 = load x86_fp80, x86_fp80* %3
ret x86_fp80 %74
}

LLVM IR (-O2):
define x86_fp80 @gstDWord2Float(i32 %0, i32 %1) {
%3 = or i32 %1, %0
%4 = icmp ult i32 %3, 65536
br i1 %4, label %5, label %48
5: ; preds = %2
%6 = lshr i32 %1, 7
%7 = and i32 %6, 255
%8 = shl nuw i32 %1, 16
%9 = and i32 %8, 8323072
%10 = add nuw nsw i32 %9, %0
br label %11
11: ; preds = %11, %5
%12 = phi i32 [ 23, %5 ], [ %37, %11 ]
%13 = phi x86_fp80 [ 0xK00000000000000000000, %5 ], [ %36, %11 ]
%14 = lshr i32 %10, %12
%15 = and i32 %14, 1
%16 = add nsw i32 %12, -23
%17 = tail call i32 @pow(i32 2, i32 %16)
%18 = mul nuw nsw i32 %17, %15
%19 = sitofp i32 %18 to x86_fp80
%20 = fadd x86_fp80 %13, %19
%21 = add nsw i32 %12, -1
%22 = lshr i32 %10, %21
%23 = and i32 %22, 1
%24 = add nsw i32 %12, -24
%25 = tail call i32 @pow(i32 2, i32 %24)
%26 = mul nuw nsw i32 %25, %23
%27 = sitofp i32 %26 to x86_fp80
%28 = fadd x86_fp80 %20, %27
%29 = add nsw i32 %12, -2
%30 = lshr i32 %10, %29
%31 = and i32 %30, 1
%32 = add nsw i32 %12, -25
%33 = tail call i32 @pow(i32 2, i32 %32)
%34 = mul nuw nsw i32 %33, %31
%35 = sitofp i32 %34 to x86_fp80
%36 = fadd x86_fp80 %28, %35
%37 = add nsw i32 %12, -3
%38 = icmp eq i32 %29, 0
br i1 %38, label %39, label %11
39: ; preds = %11
%40 = icmp ugt i32 %1, 32768
%41 = add nsw i32 %7, -127
%42 = fadd x86_fp80 %36, 0xK3FFF8000000000000000
%43 = tail call i32 @pow(i32 2, i32 %41)
%44 = sitofp i32 %43 to x86_fp80
%45 = fmul x86_fp80 %42, %44
%46 = fneg x86_fp80 %45
%47 = select i1 %40, x86_fp80 %46, x86_fp80 %45
br label %48
48: ; preds = %2, %39
%49 = phi x86_fp80 [ %47, %39 ], [ 0xK00000000000000000000, %2 ]
ret x86_fp80 %49
}