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

/* Variables and functions */
float half2single(uint16_t number) {
  uint32_t fp32;
  uint32_t s = number >> 15;
  uint32_t e = (number >> 10) & 0x01F;
  if (e == 0)
    e = 15 - 127;
  if (e == 0x1F) {
    if (number & 0x03FF)
      fp32 = 0x7FC00000;
    else
      fp32 = s ? 0xFF800000 : 0x7F800000;
  } else
    fp32 = (s << 31) | ((e + 127 - 15) << 23) | ((number & 0x3ff) << 13);
  return *(float *)&fp32;
}


x86 assembly (clang, -O0):
<half2single>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0xf,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
sar    $0xa,%eax
and    $0x1f,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    112d <half2single+0x2d>
movl   $0xffffff90,-0x10(%rbp)
cmpl   $0x1f,-0x10(%rbp)
jne    116f <half2single+0x6f>
mov    -0x4(%rbp),%eax
and    $0x3ff,%eax
cmp    $0x0,%eax
je     1154 <half2single+0x54>
movl   $0x7fc00000,-0x8(%rbp)
jmp    116a <half2single+0x6a>
mov    -0xc(%rbp),%edx
mov    $0x7f800000,%eax
mov    $0xff800000,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    1194 <half2single+0x94>
mov    -0xc(%rbp),%eax
shl    $0x1f,%eax
mov    -0x10(%rbp),%ecx
add    $0x7f,%ecx
sub    $0xf,%ecx
shl    $0x17,%ecx
or     %ecx,%eax
mov    -0x4(%rbp),%ecx
and    $0x3ff,%ecx
shl    $0xd,%ecx
or     %ecx,%eax
mov    %eax,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<half2single>:
mov    %edi,%ecx
shr    $0xa,%ecx
and    $0x1f,%ecx
mov    $0xffffff90,%eax
cmovne %ecx,%eax
cmp    $0x1f,%eax
jne    1127 <half2single+0x27>
mov    $0x7fc00000,%eax
test   $0x3ff,%edi
je     114e <half2single+0x4e>
movd   %eax,%xmm0
ret
mov    %edi,%ecx
shl    $0x10,%ecx
and    $0x80000000,%ecx
shl    $0x17,%eax
add    $0x38000000,%eax
shl    $0xd,%edi
and    $0x7fe000,%edi
or     %ecx,%edi
or     %eax,%edi
mov    %edi,%eax
movd   %eax,%xmm0
ret
cmp    $0x8000,%edi
mov    $0x7f800000,%ecx
mov    $0xff800000,%eax
cmovb  %ecx,%eax
movd   %eax,%xmm0
ret

LLVM IR (-O0):
define float @half2single(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = ashr i32 %6, 15
store i32 %7, i32* %4
%8 = load i32, i32* %2
%9 = ashr i32 %8, 10
%10 = and i32 %9, 31
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %1
store i32 -112, i32* %5
br label %14
14: ; preds = %13, %1
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 31
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load i32, i32* %2
%19 = and i32 %18, 1023
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 2143289344, i32* %3
br label %27
22: ; preds = %17
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 0
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 -8388608, i32 2139095040
store i32 %26, i32* %3
br label %27
27: ; preds = %22, %21
br label %40
28: ; preds = %14
%29 = load i32, i32* %4
%30 = shl i32 %29, 31
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 127
%33 = sub nsw i32 %32, 15
%34 = shl i32 %33, 23
%35 = or i32 %30, %34
%36 = load i32, i32* %2
%37 = and i32 %36, 1023
%38 = shl i32 %37, 13
%39 = or i32 %35, %38
store i32 %39, i32* %3
br label %40
40: ; preds = %28, %27
%41 = bitcast i32* %3 to float*
%42 = load float, float* %41
ret float %42
}

LLVM IR (-O2):
define float @half2single(i32 %0) {
%2 = lshr i32 %0, 10
%3 = and i32 %2, 31
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i32 -112, i32 %3
%6 = icmp eq i32 %5, 31
br i1 %6, label %7, label %13
7: ; preds = %1
%8 = and i32 %0, 1023
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = icmp ult i32 %0, 32768
%12 = select i1 %11, i32 2139095040, i32 -8388608
br label %22
13: ; preds = %1
%14 = shl i32 %0, 16
%15 = and i32 %14, -2147483648
%16 = shl nsw i32 %5, 23
%17 = add nsw i32 %16, 939524096
%18 = shl i32 %0, 13
%19 = and i32 %18, 8380416
%20 = or i32 %19, %15
%21 = or i32 %20, %17
br label %22
22: ; preds = %7, %10, %13
%23 = phi i32 [ %12, %10 ], [ %21, %13 ], [ 2143289344, %7 ]
%24 = bitcast i32 %23 to float
ret float %24
}