#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 checkieee = 1;
  double one = 1.0;
  uint32_t *ip;
  if (checkieee) {
    ip = (uint32_t *)&one;
    if (*ip) {
    } else {
      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)h) << 16;
        }
      } 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     1187 <halfp2singles+0x87>
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
cmpl   $0x0,(%rax)
je     1153 <halfp2singles+0x53>
jmp    115f <halfp2singles+0x5f>
mov    -0x68(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
cmpl   $0x3ff00000,(%rax)
je     117b <halfp2singles+0x7b>
movl   $0x1,-0x4(%rbp)
jmp    1358 <halfp2singles+0x258>
movl   $0x1,-0x4(%rbp)
jmp    1358 <halfp2singles+0x258>
cmpq   $0x0,-0x18(%rbp)
je     119d <halfp2singles+0x9d>
cmpq   $0x0,-0x10(%rbp)
jne    11a9 <halfp2singles+0xa9>
movl   $0x0,-0x4(%rbp)
jmp    1358 <halfp2singles+0x258>
jmp    11ae <halfp2singles+0xae>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     1351 <halfp2singles+0x251>
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    1203 <halfp2singles+0x103>
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    134c <halfp2singles+0x24c>
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    12a9 <halfp2singles+0x1a9>
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     1235 <halfp2singles+0x135>
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    1347 <halfp2singles+0x247>
cmpl   $0x7c00,-0x3c(%rbp)
jne    12fe <halfp2singles+0x1fe>
cmpl   $0x0,-0x40(%rbp)
jne    12e2 <halfp2singles+0x1e2>
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    12f9 <halfp2singles+0x1f9>
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    1342 <halfp2singles+0x242>
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    1347 <halfp2singles+0x247>
jmp    134c <halfp2singles+0x24c>
jmp    11ae <halfp2singles+0xae>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

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

LLVM IR (-O0):
@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
br label %36
33: ; preds = %27
%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 %146
41: ; preds = %36
store i32 1, i32* %4
br label %146
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 %146
49: ; preds = %45
br label %50
50: ; preds = %144, %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 %145
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 %144
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 %143
106: ; preds = %66
%107 = load i32, i32* %12
%108 = icmp eq i32 %107, 31744
br i1 %108, label %109, label %124
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 %123
118: ; preds = %109
%119 = load i32, i32* %10
%120 = shl i32 %119, 16
%121 = load i32*, i32** %9
%122 = getelementptr inbounds i32, i32* %121, i32 1
store i32* %122, i32** %9
store i32 %120, i32* %121
br label %123
123: ; preds = %118, %112
br label %142
124: ; preds = %106
%125 = load i32, i32* %11
%126 = shl i32 %125, 16
store i32 %126, i32* %14
%127 = load i32, i32* %12
%128 = ashr i32 %127, 10
%129 = sub nsw i32 %128, 15
%130 = add nsw i32 %129, 127
store i32 %130, i32* %17
%131 = load i32, i32* %17
%132 = shl i32 %131, 23
store i32 %132, i32* %15
%133 = load i32, i32* %13
%134 = shl i32 %133, 13
store i32 %134, i32* %16
%135 = load i32, i32* %14
%136 = load i32, i32* %15
%137 = or i32 %135, %136
%138 = load i32, i32* %16
%139 = or i32 %137, %138
%140 = load i32*, i32** %9
%141 = getelementptr inbounds i32, i32* %140, i32 1
store i32* %141, i32** %9
store i32 %139, i32* %140
br label %142
142: ; preds = %124, %123
br label %143
143: ; preds = %142, %85
br label %144
144: ; preds = %143, %61
br label %50
145: ; preds = %50
store i32 0, i32* %4
br label %146
146: ; preds = %145, %48, %41, %40
%147 = load i32, i32* %4
ret i32 %147
}

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