#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;
typedef int int32_t;
typedef int /*<<< orphan*/ int16_t;

/* Variables and functions */
int halfp2singles(void *target, void *source, int numel) {
  uint16_t *hp = (uint16_t *)source;
  uint32_t *xp = (uint32_t *)target;
  uint16_t h, hs, he, hm;
  uint32_t xs, xe, xm;
  int32_t xes;
  int e;
  static int __attribute__((unused)) next;
  static int checkieee = 1;
  double one = 1.0;
  uint32_t *ip;
  if (checkieee) {
    ip = (uint32_t *)&one;
    if (*ip) {
      next = 0;
    } else {
      next = 1;
      ip++;
    }
    if (*ip != 0x3FF00000u) {
      return 1;
    }
    if (sizeof(int16_t) != 2 || sizeof(int32_t) != 4) {
      return 1;
    }
    checkieee = 0;
  }
  if (source == NULL || target == NULL)
    return 0;
  while (numel--) {
    h = *hp++;
    if ((h & 0x7FFFu) == 0) {
      *xp++ = ((uint32_t)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 = ((uint32_t)hs) << 16;
        xes = ((int32_t)(he >> 10)) - 15 + 127 - e;
        xe = (uint32_t)(xes << 23);
        xm = ((uint32_t)(hm & 0x03FFu)) << 13;
        *xp++ = (xs | xe | xm);
      } else if (he == 0x7C00u) {
        if (hm == 0) {
          *xp++ = (((uint32_t)hs) << 16) | ((uint32_t)0x7F800000u);
        } else {
          *xp++ = (uint32_t)0xFFC00000u;
        }
      } else {
        xs = ((uint32_t)hs) << 16;
        xes = ((int32_t)(he >> 10)) - 15 + 127;
        xe = (uint32_t)(xes << 23);
        xm = ((uint32_t)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,-0x60(%rbp)
cmpl   $0x0,0x2eed(%rip)
je     119b <halfp2singles+0x9b>
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
cmpl   $0x0,(%rax)
je     115d <halfp2singles+0x5d>
movl   $0x0,0x2ed0(%rip)
jmp    1173 <halfp2singles+0x73>
movl   $0x1,0x2ec1(%rip)
mov    -0x68(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
cmpl   $0x3ff00000,(%rax)
je     118f <halfp2singles+0x8f>
movl   $0x1,-0x4(%rbp)
jmp    136a <halfp2singles+0x26a>
movl   $0x1,-0x4(%rbp)
jmp    136a <halfp2singles+0x26a>
cmpq   $0x0,-0x18(%rbp)
je     11b1 <halfp2singles+0xb1>
cmpq   $0x0,-0x10(%rbp)
jne    11bd <halfp2singles+0xbd>
movl   $0x0,-0x4(%rbp)
jmp    136a <halfp2singles+0x26a>
jmp    11c2 <halfp2singles+0xc2>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     1363 <halfp2singles+0x263>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
and    $0x7fff,%eax
cmp    $0x0,%eax
jne    1217 <halfp2singles+0x117>
mov    -0x34(%rbp),%ecx
shl    $0x10,%ecx
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x30(%rbp)
mov    %ecx,(%rax)
jmp    135e <halfp2singles+0x25e>
mov    -0x34(%rbp),%eax
and    $0x8000,%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
and    $0x7c00,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%eax
and    $0x3ff,%eax
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    12bd <halfp2singles+0x1bd>
movl   $0xffffffff,-0x54(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x40(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
and    $0x400,%eax
cmp    $0x0,%eax
je     1249 <halfp2singles+0x149>
mov    -0x38(%rbp),%eax
shl    $0x10,%eax
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%eax
sar    $0xa,%eax
sub    $0xf,%eax
add    $0x7f,%eax
sub    -0x54(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
shl    $0x17,%eax
mov    %eax,-0x48(%rbp)
mov    -0x40(%rbp),%eax
and    $0x3ff,%eax
shl    $0xd,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x44(%rbp),%ecx
or     -0x48(%rbp),%ecx
or     -0x4c(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x30(%rbp)
mov    %ecx,(%rax)
jmp    1359 <halfp2singles+0x259>
cmpl   $0x7c00,-0x3c(%rbp)
jne    1310 <halfp2singles+0x210>
cmpl   $0x0,-0x40(%rbp)
jne    12f6 <halfp2singles+0x1f6>
mov    -0x38(%rbp),%ecx
shl    $0x10,%ecx
or     $0x7f800000,%ecx
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x30(%rbp)
mov    %ecx,(%rax)
jmp    130b <halfp2singles+0x20b>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x30(%rbp)
movl   $0xffc00000,(%rax)
jmp    1354 <halfp2singles+0x254>
mov    -0x38(%rbp),%eax
shl    $0x10,%eax
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%eax
sar    $0xa,%eax
sub    $0xf,%eax
add    $0x7f,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
shl    $0x17,%eax
mov    %eax,-0x48(%rbp)
mov    -0x40(%rbp),%eax
shl    $0xd,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x44(%rbp),%ecx
or     -0x48(%rbp),%ecx
or     -0x4c(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x30(%rbp)
mov    %ecx,(%rax)
jmp    1359 <halfp2singles+0x259>
jmp    135e <halfp2singles+0x25e>
jmp    11c2 <halfp2singles+0xc2>
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 i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca double
%20 = alloca i32*
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 i32*
store i32* %22, i32** %8
%23 = load i8*, i8** %5
%24 = bitcast i8* %23 to i32*
store i32* %24, i32** %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 i32*
store i32* %28, i32** %20
%29 = load i32*, i32** %20
%30 = load i32, i32* %29
%31 = icmp ne i32 %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 i32*, i32** %20
%35 = getelementptr inbounds i32, i32* %34, i32 1
store i32* %35, i32** %20
br label %36
36: ; preds = %33, %32
%37 = load i32*, i32** %20
%38 = load i32, i32* %37
%39 = icmp ne i32 %38, 1072693248
br i1 %39, label %40, label %41
40: ; preds = %36
store i32 1, i32* %4
br label %144
41: ; preds = %36
store i32 1, i32* %4
br label %144
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 %144
49: ; preds = %45
br label %50
50: ; preds = %142, %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 %143
54: ; preds = %50
%55 = load i32*, i32** %8
%56 = getelementptr inbounds i32, i32* %55, i32 1
store i32* %56, i32** %8
%57 = load i32, i32* %55
store i32 %57, i32* %10
%58 = load i32, i32* %10
%59 = and i32 %58, 32767
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %66
61: ; preds = %54
%62 = load i32, i32* %10
%63 = shl i32 %62, 16
%64 = load i32*, i32** %9
%65 = getelementptr inbounds i32, i32* %64, i32 1
store i32* %65, i32** %9
store i32 %63, i32* %64
br label %142
66: ; preds = %54
%67 = load i32, i32* %10
%68 = and i32 %67, 32768
store i32 %68, i32* %11
%69 = load i32, i32* %10
%70 = and i32 %69, 31744
store i32 %70, i32* %12
%71 = load i32, i32* %10
%72 = and i32 %71, 1023
store i32 %72, i32* %13
%73 = load i32, i32* %12
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %106
75: ; preds = %66
store i32 -1, i32* %18
br label %76
76: ; preds = %81, %75
%77 = load i32, i32* %18
%78 = add nsw i32 %77, 1
store i32 %78, i32* %18
%79 = load i32, i32* %13
%80 = shl i32 %79, 1
store i32 %80, i32* %13
br label %81
81: ; preds = %76
%82 = load i32, i32* %13
%83 = and i32 %82, 1024
%84 = icmp eq i32 %83, 0
br i1 %84, label %76, label %85
85: ; preds = %81
%86 = load i32, i32* %11
%87 = shl i32 %86, 16
store i32 %87, i32* %14
%88 = load i32, i32* %12
%89 = ashr i32 %88, 10
%90 = sub nsw i32 %89, 15
%91 = add nsw i32 %90, 127
%92 = load i32, i32* %18
%93 = sub nsw i32 %91, %92
store i32 %93, i32* %17
%94 = load i32, i32* %17
%95 = shl i32 %94, 23
store i32 %95, i32* %15
%96 = load i32, i32* %13
%97 = and i32 %96, 1023
%98 = shl i32 %97, 13
store i32 %98, i32* %16
%99 = load i32, i32* %14
%100 = load i32, i32* %15
%101 = or i32 %99, %100
%102 = load i32, i32* %16
%103 = or i32 %101, %102
%104 = load i32*, i32** %9
%105 = getelementptr inbounds i32, i32* %104, i32 1
store i32* %105, i32** %9
store i32 %103, i32* %104
br label %141
106: ; preds = %66
%107 = load i32, i32* %12
%108 = icmp eq i32 %107, 31744
br i1 %108, label %109, label %122
109: ; preds = %106
%110 = load i32, i32* %13
%111 = icmp eq i32 %110, 0
br i1 %111, label %112, label %118
112: ; preds = %109
%113 = load i32, i32* %11
%114 = shl i32 %113, 16
%115 = or i32 %114, 2139095040
%116 = load i32*, i32** %9
%117 = getelementptr inbounds i32, i32* %116, i32 1
store i32* %117, i32** %9
store i32 %115, i32* %116
br label %121
118: ; preds = %109
%119 = load i32*, i32** %9
%120 = getelementptr inbounds i32, i32* %119, i32 1
store i32* %120, i32** %9
store i32 -4194304, i32* %119
br label %121
121: ; preds = %118, %112
br label %140
122: ; preds = %106
%123 = load i32, i32* %11
%124 = shl i32 %123, 16
store i32 %124, i32* %14
%125 = load i32, i32* %12
%126 = ashr i32 %125, 10
%127 = sub nsw i32 %126, 15
%128 = add nsw i32 %127, 127
store i32 %128, i32* %17
%129 = load i32, i32* %17
%130 = shl i32 %129, 23
store i32 %130, i32* %15
%131 = load i32, i32* %13
%132 = shl i32 %131, 13
store i32 %132, i32* %16
%133 = load i32, i32* %14
%134 = load i32, i32* %15
%135 = or i32 %133, %134
%136 = load i32, i32* %16
%137 = or i32 %135, %136
%138 = load i32*, i32** %9
%139 = getelementptr inbounds i32, i32* %138, i32 1
store i32* %139, i32** %9
store i32 %137, i32* %138
br label %140
140: ; preds = %122, %121
br label %141
141: ; preds = %140, %85
br label %142
142: ; preds = %141, %61
br label %50
143: ; preds = %50
store i32 0, i32* %4
br label %144
144: ; preds = %143, %48, %41, %40
%145 = load i32, i32* %4
ret i32 %145
}

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