int hs_binary_halfToFloatRep(unsigned short c) {
  int s = (c >> 15) & 0x001;
  int e = (c >> 10) & 0x01f;
  int m = c & 0x3ff;
  if (e == 0) {
    if (m == 0)
      return s << 31;
    while (!(m & 0x400)) {
      m <<= 1;
      e -= 1;
    }
    e += 1;
    m &= ~0x400;
  } else if (e == 31)
    return (s << 31) | 0x7f800000 | (m << 13);
  e += 112;
  m <<= 13;
  return (s << 31) | (e << 23) | m;
}


x86 assembly (clang, -O0):
<hs_binary_halfToFloatRep>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x6(%rbp)
movzwl -0x6(%rbp),%eax
sar    $0xf,%eax
and    $0x1,%eax
mov    %eax,-0xc(%rbp)
movzwl -0x6(%rbp),%eax
sar    $0xa,%eax
and    $0x1f,%eax
mov    %eax,-0x10(%rbp)
movzwl -0x6(%rbp),%eax
and    $0x3ff,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11a5 <hs_binary_halfToFloatRep+0xa5>
cmpl   $0x0,-0x14(%rbp)
jne    1153 <hs_binary_halfToFloatRep+0x53>
mov    -0xc(%rbp),%eax
shl    $0x1f,%eax
mov    %eax,-0x4(%rbp)
jmp    11f5 <hs_binary_halfToFloatRep+0xf5>
jmp    1158 <hs_binary_halfToFloatRep+0x58>
mov    -0x14(%rbp),%eax
and    $0x400,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1175 <hs_binary_halfToFloatRep+0x75>
jmp    118c <hs_binary_halfToFloatRep+0x8c>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1158 <hs_binary_halfToFloatRep+0x58>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
and    $0xfffffbff,%eax
mov    %eax,-0x14(%rbp)
jmp    11cf <hs_binary_halfToFloatRep+0xcf>
cmpl   $0x1f,-0x10(%rbp)
jne    11ca <hs_binary_halfToFloatRep+0xca>
mov    -0xc(%rbp),%eax
shl    $0x1f,%eax
or     $0x7f800000,%eax
mov    -0x14(%rbp),%ecx
shl    $0xd,%ecx
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11f5 <hs_binary_halfToFloatRep+0xf5>
jmp    11cf <hs_binary_halfToFloatRep+0xcf>
mov    -0x10(%rbp),%eax
add    $0x70,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
shl    $0xd,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1f,%eax
mov    -0x10(%rbp),%ecx
shl    $0x17,%ecx
or     %ecx,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<hs_binary_halfToFloatRep>:
mov    %edi,%ecx
shr    $0xf,%ecx
mov    %edi,%eax
shr    $0xa,%eax
and    $0x1f,%eax
cmp    $0x1f,%eax
je     1159 <hs_binary_halfToFloatRep+0x59>
and    $0x3ff,%edi
test   %eax,%eax
jne    1146 <hs_binary_halfToFloatRep+0x46>
test   %edi,%edi
je     116a <hs_binary_halfToFloatRep+0x6a>
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nop
mov    %edi,%edx
lea    (%rdx,%rdx,1),%edi
add    $0xffffffff,%eax
test   $0x200,%edx
je     1130 <hs_binary_halfToFloatRep+0x30>
and    $0xfffffbfe,%edi
shl    $0xd,%edi
shl    $0x1f,%ecx
shl    $0x17,%eax
add    $0x38000000,%eax
or     %ecx,%eax
or     %edi,%eax
ret
shl    $0x1f,%ecx
shl    $0xd,%edi
or     %ecx,%edi
or     $0x7f800000,%edi
mov    %edi,%eax
ret
shl    $0x1f,%ecx
mov    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @hs_binary_halfToFloatRep(i16 zeroext %0) {
%2 = alloca i32
%3 = alloca i16
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i16 %0, i16* %3
%7 = load i16, i16* %3
%8 = zext i16 %7 to i32
%9 = ashr i32 %8, 15
%10 = and i32 %9, 1
store i32 %10, i32* %4
%11 = load i16, i16* %3
%12 = zext i16 %11 to i32
%13 = ashr i32 %12, 10
%14 = and i32 %13, 31
store i32 %14, i32* %5
%15 = load i16, i16* %3
%16 = zext i16 %15 to i32
%17 = and i32 %16, 1023
store i32 %17, i32* %6
%18 = load i32, i32* %5
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %42
20: ; preds = %1
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %4
%25 = shl i32 %24, 31
store i32 %25, i32* %2
br label %65
26: ; preds = %20
br label %27
27: ; preds = %32, %26
%28 = load i32, i32* %6
%29 = and i32 %28, 1024
%30 = icmp ne i32 %29, 0
%31 = xor i1 %30, true
br i1 %31, label %32, label %37
32: ; preds = %27
%33 = load i32, i32* %6
%34 = shl i32 %33, 1
store i32 %34, i32* %6
%35 = load i32, i32* %5
%36 = sub nsw i32 %35, 1
store i32 %36, i32* %5
br label %27
37: ; preds = %27
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
%40 = load i32, i32* %6
%41 = and i32 %40, -1025
store i32 %41, i32* %6
br label %53
42: ; preds = %1
%43 = load i32, i32* %5
%44 = icmp eq i32 %43, 31
br i1 %44, label %45, label %52
45: ; preds = %42
%46 = load i32, i32* %4
%47 = shl i32 %46, 31
%48 = or i32 %47, 2139095040
%49 = load i32, i32* %6
%50 = shl i32 %49, 13
%51 = or i32 %48, %50
store i32 %51, i32* %2
br label %65
52: ; preds = %42
br label %53
53: ; preds = %52, %37
%54 = load i32, i32* %5
%55 = add nsw i32 %54, 112
store i32 %55, i32* %5
%56 = load i32, i32* %6
%57 = shl i32 %56, 13
store i32 %57, i32* %6
%58 = load i32, i32* %4
%59 = shl i32 %58, 31
%60 = load i32, i32* %5
%61 = shl i32 %60, 23
%62 = or i32 %59, %61
%63 = load i32, i32* %6
%64 = or i32 %62, %63
store i32 %64, i32* %2
br label %65
65: ; preds = %53, %45, %23
%66 = load i32, i32* %2
ret i32 %66
}

LLVM IR (-O2):
define i32 @hs_binary_halfToFloatRep(i16 zeroext %0) {
%2 = zext i16 %0 to i32
%3 = lshr i32 %2, 15
%4 = lshr i32 %2, 10
%5 = and i32 %4, 31
%6 = and i32 %2, 1023
switch i32 %5, label %25 [
i32 0, label %7
i32 31, label %20
]
7: ; preds = %1
%8 = icmp eq i32 %6, 0
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = shl nuw i32 %3, 31
br label %34
11: ; preds = %7, %11
%12 = phi i32 [ %14, %11 ], [ %6, %7 ]
%13 = phi i32 [ %15, %11 ], [ 0, %7 ]
%14 = shl i32 %12, 1
%15 = add nsw i32 %13, -1
%16 = and i32 %12, 512
%17 = icmp eq i32 %16, 0
br i1 %17, label %11, label %18
18: ; preds = %11
%19 = and i32 %14, -1026
br label %25
20: ; preds = %1
%21 = shl nuw i32 %3, 31
%22 = shl nuw nsw i32 %2, 13
%23 = or i32 %21, %22
%24 = or i32 %23, 2139095040
br label %34
25: ; preds = %1, %18
%26 = phi i32 [ %13, %18 ], [ %5, %1 ]
%27 = phi i32 [ %19, %18 ], [ %6, %1 ]
%28 = shl i32 %27, 13
%29 = shl nuw i32 %3, 31
%30 = shl i32 %26, 23
%31 = add i32 %30, 939524096
%32 = or i32 %31, %29
%33 = or i32 %32, %28
br label %34
34: ; preds = %25, %20, %9
%35 = phi i32 [ %10, %9 ], [ %33, %25 ], [ %24, %20 ]
ret i32 %35
}