#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 halfp2singles(void *target, void *source, int numel) {
  unsigned short *hp = (unsigned short *)source;
  unsigned long *xp = (unsigned long *)target;
  unsigned short h, hs, he, hm;
  unsigned long xs, xe, xm;
  long xes;
  int e;
  static int next;
  static int checkieee = 1;
  double one = 1.0;
  unsigned long *ip;
  if (checkieee) {
    ip = (unsigned long *)&one;
    if (*ip) {
      next = 0;
    } else {
      next = 1;
      ip++;
    }
    if (*ip != 0x3FF00000u) {
      return 1;
    }
    if (sizeof(short) != 2 || sizeof(long) != 4) {
      return 1;
    }
    checkieee = 0;
  }
  if (source == NULL || target == NULL)
    return 0;
  while (numel--) {
    h = *hp++;
    if ((h & 0x7FFFu) == 0) {
      *xp++ = ((unsigned long)h) << 16;
    } else {
      hs = h & 0x8000u;
      he = h & 0x7C00u;
      hm = h & 0x03FFu;
      if (he == 0) {
        e = -1;
        do {
          e++;
          hm <<= 1;
        } while ((hm & 0x0400u) == 0);
        xs = ((unsigned long)hs) << 16;
        xes = ((long)(he >> 10)) - 15 + 127 - e;
        xe = (unsigned long)(xes << 23);
        xm = ((unsigned long)(hm & 0x03FFu)) << 13;
        *xp++ = (xs | xe | xm);
      } else if (he == 0x7C00u) {
        if (hm == 0) {
          *xp++ = (((unsigned long)hs) << 16) | ((unsigned long)0x7F800000u);
        } else {
          *xp++ = (unsigned long)0xFFC00000u;
        }
      } else {
        xs = ((unsigned long)hs) << 16;
        xes = ((long)(he >> 10)) - 15 + 127;
        xe = (unsigned long)(xes << 23);
        xm = ((unsigned long)hm) << 13;
        *xp++ = (xs | xe | xm);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<halfp2singles>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
movsd  0xed9(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
cmpl   $0x0,0x2eed(%rip)
je     119d <halfp2singles+0x9d>
lea    -0x68(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
cmpq   $0x0,(%rax)
je     115e <halfp2singles+0x5e>
movl   $0x0,0x2ecf(%rip)
jmp    1174 <halfp2singles+0x74>
movl   $0x1,0x2ec0(%rip)
mov    -0x70(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
cmpq   $0x3ff00000,(%rax)
je     1191 <halfp2singles+0x91>
movl   $0x1,-0x4(%rbp)
jmp    13b9 <halfp2singles+0x2b9>
movl   $0x1,-0x4(%rbp)
jmp    13b9 <halfp2singles+0x2b9>
cmpq   $0x0,-0x18(%rbp)
je     11b3 <halfp2singles+0xb3>
cmpq   $0x0,-0x10(%rbp)
jne    11bf <halfp2singles+0xbf>
movl   $0x0,-0x4(%rbp)
jmp    13b9 <halfp2singles+0x2b9>
jmp    11c4 <halfp2singles+0xc4>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     13b2 <halfp2singles+0x2b2>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x2,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%ax
mov    %ax,-0x32(%rbp)
movzwl -0x32(%rbp),%eax
and    $0x7fff,%eax
cmp    $0x0,%eax
jne    1221 <halfp2singles+0x121>
movzwl -0x32(%rbp),%eax
mov    %eax,%ecx
shl    $0x10,%rcx
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rcx,(%rax)
jmp    13ad <halfp2singles+0x2ad>
movzwl -0x32(%rbp),%eax
and    $0x8000,%eax
mov    %ax,-0x34(%rbp)
movzwl -0x32(%rbp),%eax
and    $0x7c00,%eax
mov    %ax,-0x36(%rbp)
movzwl -0x32(%rbp),%eax
and    $0x3ff,%eax
mov    %ax,-0x38(%rbp)
movzwl -0x36(%rbp),%eax
cmp    $0x0,%eax
jne    12ec <halfp2singles+0x1ec>
movl   $0xffffffff,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
movzwl -0x38(%rbp),%eax
shl    $0x1,%eax
mov    %ax,-0x38(%rbp)
movzwl -0x38(%rbp),%eax
and    $0x400,%eax
cmp    $0x0,%eax
je     125c <halfp2singles+0x15c>
movzwl -0x34(%rbp),%eax
shl    $0x10,%rax
mov    %rax,-0x40(%rbp)
movzwl -0x36(%rbp),%eax
sar    $0xa,%eax
cltq
sub    $0xf,%rax
add    $0x7f,%rax
movslq -0x5c(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
shl    $0x17,%rax
mov    %rax,-0x48(%rbp)
movzwl -0x38(%rbp),%eax
and    $0x3ff,%eax
mov    %eax,%eax
shl    $0xd,%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rcx
or     -0x48(%rbp),%rcx
or     -0x50(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rcx,(%rax)
jmp    13a8 <halfp2singles+0x2a8>
movzwl -0x36(%rbp),%eax
cmp    $0x7c00,%eax
jne    134c <halfp2singles+0x24c>
movzwl -0x38(%rbp),%eax
cmp    $0x0,%eax
jne    1330 <halfp2singles+0x230>
movzwl -0x34(%rbp),%eax
mov    %eax,%ecx
shl    $0x10,%rcx
or     $0x7f800000,%rcx
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rcx,(%rax)
jmp    1347 <halfp2singles+0x247>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x30(%rbp)
mov    $0xffc00000,%ecx
mov    %rcx,(%rax)
jmp    13a3 <halfp2singles+0x2a3>
movzwl -0x34(%rbp),%eax
shl    $0x10,%rax
mov    %rax,-0x40(%rbp)
movzwl -0x36(%rbp),%eax
sar    $0xa,%eax
cltq
sub    $0xf,%rax
add    $0x7f,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
shl    $0x17,%rax
mov    %rax,-0x48(%rbp)
movzwl -0x38(%rbp),%eax
shl    $0xd,%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rcx
or     -0x48(%rbp),%rcx
or     -0x50(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rcx,(%rax)
jmp    13a8 <halfp2singles+0x2a8>
jmp    13ad <halfp2singles+0x2ad>
jmp    11c4 <halfp2singles+0xc4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<halfp2singles>:
mov    $0x1,%eax
ret

LLVM IR (-O0):
@halfp2singles.next = internal global i32 0
@halfp2singles.checkieee = internal global i32 1
define i32 @halfp2singles(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i16*
%9 = alloca i64*
%10 = alloca i16
%11 = alloca i16
%12 = alloca i16
%13 = alloca i16
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
%18 = alloca i32
%19 = alloca double
%20 = alloca i64*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%21 = load i8*, i8** %6
%22 = bitcast i8* %21 to i16*
store i16* %22, i16** %8
%23 = load i8*, i8** %5
%24 = bitcast i8* %23 to i64*
store i64* %24, i64** %9
store double 1.000000e+00, double* %19
%25 = load i32, i32* @halfp2singles.checkieee
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %42
27: ; preds = %3
%28 = bitcast double* %19 to i64*
store i64* %28, i64** %20
%29 = load i64*, i64** %20
%30 = load i64, i64* %29
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %27
store i32 0, i32* @halfp2singles.next
br label %36
33: ; preds = %27
store i32 1, i32* @halfp2singles.next
%34 = load i64*, i64** %20
%35 = getelementptr inbounds i64, i64* %34, i32 1
store i64* %35, i64** %20
br label %36
36: ; preds = %33, %32
%37 = load i64*, i64** %20
%38 = load i64, i64* %37
%39 = icmp ne i64 %38, 1072693248
br i1 %39, label %40, label %41
40: ; preds = %36
store i32 1, i32* %4
br label %169
41: ; preds = %36
store i32 1, i32* %4
br label %169
42: ; preds = %3
%43 = load i8*, i8** %6
%44 = icmp eq i8* %43, null
br i1 %44, label %48, label %45
45: ; preds = %42
%46 = load i8*, i8** %5
%47 = icmp eq i8* %46, null
br i1 %47, label %48, label %49
48: ; preds = %45, %42
store i32 0, i32* %4
br label %169
49: ; preds = %45
br label %50
50: ; preds = %167, %49
%51 = load i32, i32* %7
%52 = add nsw i32 %51, -1
store i32 %52, i32* %7
%53 = icmp ne i32 %51, 0
br i1 %53, label %54, label %168
54: ; preds = %50
%55 = load i16*, i16** %8
%56 = getelementptr inbounds i16, i16* %55, i32 1
store i16* %56, i16** %8
%57 = load i16, i16* %55
store i16 %57, i16* %10
%58 = load i16, i16* %10
%59 = zext i16 %58 to i32
%60 = and i32 %59, 32767
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %68
62: ; preds = %54
%63 = load i16, i16* %10
%64 = zext i16 %63 to i64
%65 = shl i64 %64, 16
%66 = load i64*, i64** %9
%67 = getelementptr inbounds i64, i64* %66, i32 1
store i64* %67, i64** %9
store i64 %65, i64* %66
br label %167
68: ; preds = %54
%69 = load i16, i16* %10
%70 = zext i16 %69 to i32
%71 = and i32 %70, 32768
%72 = trunc i32 %71 to i16
store i16 %72, i16* %11
%73 = load i16, i16* %10
%74 = zext i16 %73 to i32
%75 = and i32 %74, 31744
%76 = trunc i32 %75 to i16
store i16 %76, i16* %12
%77 = load i16, i16* %10
%78 = zext i16 %77 to i32
%79 = and i32 %78, 1023
%80 = trunc i32 %79 to i16
store i16 %80, i16* %13
%81 = load i16, i16* %12
%82 = zext i16 %81 to i32
%83 = icmp eq i32 %82, 0
br i1 %83, label %84, label %124
84: ; preds = %68
store i32 -1, i32* %18
br label %85
85: ; preds = %92, %84
%86 = load i32, i32* %18
%87 = add nsw i32 %86, 1
store i32 %87, i32* %18
%88 = load i16, i16* %13
%89 = zext i16 %88 to i32
%90 = shl i32 %89, 1
%91 = trunc i32 %90 to i16
store i16 %91, i16* %13
br label %92
92: ; preds = %85
%93 = load i16, i16* %13
%94 = zext i16 %93 to i32
%95 = and i32 %94, 1024
%96 = icmp eq i32 %95, 0
br i1 %96, label %85, label %97
97: ; preds = %92
%98 = load i16, i16* %11
%99 = zext i16 %98 to i64
%100 = shl i64 %99, 16
store i64 %100, i64* %14
%101 = load i16, i16* %12
%102 = zext i16 %101 to i32
%103 = ashr i32 %102, 10
%104 = sext i32 %103 to i64
%105 = sub nsw i64 %104, 15
%106 = add nsw i64 %105, 127
%107 = load i32, i32* %18
%108 = sext i32 %107 to i64
%109 = sub nsw i64 %106, %108
store i64 %109, i64* %17
%110 = load i64, i64* %17
%111 = shl i64 %110, 23
store i64 %111, i64* %15
%112 = load i16, i16* %13
%113 = zext i16 %112 to i32
%114 = and i32 %113, 1023
%115 = zext i32 %114 to i64
%116 = shl i64 %115, 13
store i64 %116, i64* %16
%117 = load i64, i64* %14
%118 = load i64, i64* %15
%119 = or i64 %117, %118
%120 = load i64, i64* %16
%121 = or i64 %119, %120
%122 = load i64*, i64** %9
%123 = getelementptr inbounds i64, i64* %122, i32 1
store i64* %123, i64** %9
store i64 %121, i64* %122
br label %166
124: ; preds = %68
%125 = load i16, i16* %12
%126 = zext i16 %125 to i32
%127 = icmp eq i32 %126, 31744
br i1 %127, label %128, label %143
128: ; preds = %124
%129 = load i16, i16* %13
%130 = zext i16 %129 to i32
%131 = icmp eq i32 %130, 0
br i1 %131, label %132, label %139
132: ; preds = %128
%133 = load i16, i16* %11
%134 = zext i16 %133 to i64
%135 = shl i64 %134, 16
%136 = or i64 %135, 2139095040
%137 = load i64*, i64** %9
%138 = getelementptr inbounds i64, i64* %137, i32 1
store i64* %138, i64** %9
store i64 %136, i64* %137
br label %142
139: ; preds = %128
%140 = load i64*, i64** %9
%141 = getelementptr inbounds i64, i64* %140, i32 1
store i64* %141, i64** %9
store i64 4290772992, i64* %140
br label %142
142: ; preds = %139, %132
br label %165
143: ; preds = %124
%144 = load i16, i16* %11
%145 = zext i16 %144 to i64
%146 = shl i64 %145, 16
store i64 %146, i64* %14
%147 = load i16, i16* %12
%148 = zext i16 %147 to i32
%149 = ashr i32 %148, 10
%150 = sext i32 %149 to i64
%151 = sub nsw i64 %150, 15
%152 = add nsw i64 %151, 127
store i64 %152, i64* %17
%153 = load i64, i64* %17
%154 = shl i64 %153, 23
store i64 %154, i64* %15
%155 = load i16, i16* %13
%156 = zext i16 %155 to i64
%157 = shl i64 %156, 13
store i64 %157, i64* %16
%158 = load i64, i64* %14
%159 = load i64, i64* %15
%160 = or i64 %158, %159
%161 = load i64, i64* %16
%162 = or i64 %160, %161
%163 = load i64*, i64** %9
%164 = getelementptr inbounds i64, i64* %163, i32 1
store i64* %164, i64** %9
store i64 %162, i64* %163
br label %165
165: ; preds = %143, %142
br label %166
166: ; preds = %165, %97
br label %167
167: ; preds = %166, %62
br label %50
168: ; preds = %50
store i32 0, i32* %4
br label %169
169: ; preds = %168, %48, %41, %40
%170 = load i32, i32* %4
ret i32 %170
}

LLVM IR (-O2):
define i32 @halfp2singles(i8* nocapture readnone %0, i8* nocapture readnone %1, i32 %2) {
ret i32 1
}