#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 halfp2doubles(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;
  }
  xp += next;
  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 + 1023 - e;
        xe = (unsigned long)(xes << 20);
        xm = ((unsigned long)(hm & 0x03FFu)) << 10;
        *xp++ = (xs | xe | xm);
      } else if (he == 0x7C00u) {
        if (hm == 0) {
          *xp++ = (((unsigned long)hs) << 16) | ((unsigned long)0x7FF00000u);
        } else {
          *xp++ = (unsigned long)0xFFF80000u;
        }
      } else {
        xs = ((unsigned long)hs) << 16;
        xes = ((long)(he >> 10)) - 15 + 1023;
        xe = (unsigned long)(xes << 20);
        xm = ((unsigned long)hm) << 10;
        *xp++ = (xs | xe | xm);
      }
    }
    xp++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<halfp2doubles>:
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 <halfp2doubles+0x9d>
lea    -0x68(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
cmpq   $0x0,(%rax)
je     115e <halfp2doubles+0x5e>
movl   $0x0,0x2ecf(%rip)
jmp    1174 <halfp2doubles+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 <halfp2doubles+0x91>
movl   $0x1,-0x4(%rbp)
jmp    13e1 <halfp2doubles+0x2e1>
movl   $0x1,-0x4(%rbp)
jmp    13e1 <halfp2doubles+0x2e1>
mov    0x2e85(%rip),%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11cb <halfp2doubles+0xcb>
cmpq   $0x0,-0x10(%rbp)
jne    11d7 <halfp2doubles+0xd7>
movl   $0x0,-0x4(%rbp)
jmp    13e1 <halfp2doubles+0x2e1>
jmp    11dc <halfp2doubles+0xdc>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     13da <halfp2doubles+0x2da>
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    1239 <halfp2doubles+0x139>
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    13c9 <halfp2doubles+0x2c9>
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    1306 <halfp2doubles+0x206>
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     1274 <halfp2doubles+0x174>
movzwl -0x34(%rbp),%eax
shl    $0x10,%rax
mov    %rax,-0x40(%rbp)
movzwl -0x36(%rbp),%eax
sar    $0xa,%eax
cltq
sub    $0xf,%rax
add    $0x3ff,%rax
movslq -0x5c(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
shl    $0x14,%rax
mov    %rax,-0x48(%rbp)
movzwl -0x38(%rbp),%eax
and    $0x3ff,%eax
mov    %eax,%eax
shl    $0xa,%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    13c4 <halfp2doubles+0x2c4>
movzwl -0x36(%rbp),%eax
cmp    $0x7c00,%eax
jne    1366 <halfp2doubles+0x266>
movzwl -0x38(%rbp),%eax
cmp    $0x0,%eax
jne    134a <halfp2doubles+0x24a>
movzwl -0x34(%rbp),%eax
mov    %eax,%ecx
shl    $0x10,%rcx
or     $0x7ff00000,%rcx
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rcx,(%rax)
jmp    1361 <halfp2doubles+0x261>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x30(%rbp)
mov    $0xfff80000,%ecx
mov    %rcx,(%rax)
jmp    13bf <halfp2doubles+0x2bf>
movzwl -0x34(%rbp),%eax
shl    $0x10,%rax
mov    %rax,-0x40(%rbp)
movzwl -0x36(%rbp),%eax
sar    $0xa,%eax
cltq
sub    $0xf,%rax
add    $0x3ff,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
shl    $0x14,%rax
mov    %rax,-0x48(%rbp)
movzwl -0x38(%rbp),%eax
shl    $0xa,%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    13c4 <halfp2doubles+0x2c4>
jmp    13c9 <halfp2doubles+0x2c9>
mov    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
jmp    11dc <halfp2doubles+0xdc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

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

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

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