#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 halfp2doubles(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 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;
  }
  xp += next;
  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 + 1023 - e;
        xe = (uint32_t)(xes << 20);
        xm = ((uint32_t)(hm & 0x03FFu)) << 10;
        *xp++ = (xs | xe | xm);
      } else if (he == 0x7C00u) {
        if (hm == 0) {
          *xp++ = (((uint32_t)hs) << 16) | ((uint32_t)0x7FF00000u);
        } else {
          *xp++ = (uint32_t)0xFFF80000u;
        }
      } else {
        xs = ((uint32_t)hs) << 16;
        xes = ((int32_t)(he >> 10)) - 15 + 1023;
        xe = (uint32_t)(xes << 20);
        xm = ((uint32_t)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,-0x60(%rbp)
cmpl   $0x0,0x2eed(%rip)
je     119b <halfp2doubles+0x9b>
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
cmpl   $0x0,(%rax)
je     115d <halfp2doubles+0x5d>
movl   $0x0,0x2ed0(%rip)
jmp    1173 <halfp2doubles+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 <halfp2doubles+0x8f>
movl   $0x1,-0x4(%rbp)
jmp    1392 <halfp2doubles+0x292>
movl   $0x1,-0x4(%rbp)
jmp    1392 <halfp2doubles+0x292>
mov    0x2e87(%rip),%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c9 <halfp2doubles+0xc9>
cmpq   $0x0,-0x10(%rbp)
jne    11d5 <halfp2doubles+0xd5>
movl   $0x0,-0x4(%rbp)
jmp    1392 <halfp2doubles+0x292>
jmp    11da <halfp2doubles+0xda>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     138b <halfp2doubles+0x28b>
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    122f <halfp2doubles+0x12f>
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    137a <halfp2doubles+0x27a>
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    12d7 <halfp2doubles+0x1d7>
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     1261 <halfp2doubles+0x161>
mov    -0x38(%rbp),%eax
shl    $0x10,%eax
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%eax
sar    $0xa,%eax
sub    $0xf,%eax
add    $0x3ff,%eax
sub    -0x54(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
shl    $0x14,%eax
mov    %eax,-0x48(%rbp)
mov    -0x40(%rbp),%eax
and    $0x3ff,%eax
shl    $0xa,%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    1375 <halfp2doubles+0x275>
cmpl   $0x7c00,-0x3c(%rbp)
jne    132a <halfp2doubles+0x22a>
cmpl   $0x0,-0x40(%rbp)
jne    1310 <halfp2doubles+0x210>
mov    -0x38(%rbp),%ecx
shl    $0x10,%ecx
or     $0x7ff00000,%ecx
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x30(%rbp)
mov    %ecx,(%rax)
jmp    1325 <halfp2doubles+0x225>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x30(%rbp)
movl   $0xfff80000,(%rax)
jmp    1370 <halfp2doubles+0x270>
mov    -0x38(%rbp),%eax
shl    $0x10,%eax
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%eax
sar    $0xa,%eax
sub    $0xf,%eax
add    $0x3ff,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
shl    $0x14,%eax
mov    %eax,-0x48(%rbp)
mov    -0x40(%rbp),%eax
shl    $0xa,%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    1375 <halfp2doubles+0x275>
jmp    137a <halfp2doubles+0x27a>
mov    -0x30(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
jmp    11da <halfp2doubles+0xda>
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 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* @halfp2doubles.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* @halfp2doubles.next
br label %36
33: ; preds = %27
store i32 1, i32* @halfp2doubles.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 %150
41: ; preds = %36
store i32 1, i32* %4
br label %150
42: ; preds = %3
%43 = load i32, i32* @halfp2doubles.next
%44 = load i32*, i32** %9
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds i32, i32* %44, i64 %45
store i32* %46, i32** %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 %150
53: ; preds = %49
br label %54
54: ; preds = %146, %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 %149
58: ; preds = %54
%59 = load i32*, i32** %8
%60 = getelementptr inbounds i32, i32* %59, i32 1
store i32* %60, i32** %8
%61 = load i32, i32* %59
store i32 %61, i32* %10
%62 = load i32, i32* %10
%63 = and i32 %62, 32767
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %70
65: ; preds = %58
%66 = load i32, i32* %10
%67 = shl i32 %66, 16
%68 = load i32*, i32** %9
%69 = getelementptr inbounds i32, i32* %68, i32 1
store i32* %69, i32** %9
store i32 %67, i32* %68
br label %146
70: ; preds = %58
%71 = load i32, i32* %10
%72 = and i32 %71, 32768
store i32 %72, i32* %11
%73 = load i32, i32* %10
%74 = and i32 %73, 31744
store i32 %74, i32* %12
%75 = load i32, i32* %10
%76 = and i32 %75, 1023
store i32 %76, i32* %13
%77 = load i32, i32* %12
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %110
79: ; preds = %70
store i32 -1, i32* %18
br label %80
80: ; preds = %85, %79
%81 = load i32, i32* %18
%82 = add nsw i32 %81, 1
store i32 %82, i32* %18
%83 = load i32, i32* %13
%84 = shl i32 %83, 1
store i32 %84, i32* %13
br label %85
85: ; preds = %80
%86 = load i32, i32* %13
%87 = and i32 %86, 1024
%88 = icmp eq i32 %87, 0
br i1 %88, label %80, label %89
89: ; preds = %85
%90 = load i32, i32* %11
%91 = shl i32 %90, 16
store i32 %91, i32* %14
%92 = load i32, i32* %12
%93 = ashr i32 %92, 10
%94 = sub nsw i32 %93, 15
%95 = add nsw i32 %94, 1023
%96 = load i32, i32* %18
%97 = sub nsw i32 %95, %96
store i32 %97, i32* %17
%98 = load i32, i32* %17
%99 = shl i32 %98, 20
store i32 %99, i32* %15
%100 = load i32, i32* %13
%101 = and i32 %100, 1023
%102 = shl i32 %101, 10
store i32 %102, i32* %16
%103 = load i32, i32* %14
%104 = load i32, i32* %15
%105 = or i32 %103, %104
%106 = load i32, i32* %16
%107 = or i32 %105, %106
%108 = load i32*, i32** %9
%109 = getelementptr inbounds i32, i32* %108, i32 1
store i32* %109, i32** %9
store i32 %107, i32* %108
br label %145
110: ; preds = %70
%111 = load i32, i32* %12
%112 = icmp eq i32 %111, 31744
br i1 %112, label %113, label %126
113: ; preds = %110
%114 = load i32, i32* %13
%115 = icmp eq i32 %114, 0
br i1 %115, label %116, label %122
116: ; preds = %113
%117 = load i32, i32* %11
%118 = shl i32 %117, 16
%119 = or i32 %118, 2146435072
%120 = load i32*, i32** %9
%121 = getelementptr inbounds i32, i32* %120, i32 1
store i32* %121, i32** %9
store i32 %119, i32* %120
br label %125
122: ; preds = %113
%123 = load i32*, i32** %9
%124 = getelementptr inbounds i32, i32* %123, i32 1
store i32* %124, i32** %9
store i32 -524288, i32* %123
br label %125
125: ; preds = %122, %116
br label %144
126: ; preds = %110
%127 = load i32, i32* %11
%128 = shl i32 %127, 16
store i32 %128, i32* %14
%129 = load i32, i32* %12
%130 = ashr i32 %129, 10
%131 = sub nsw i32 %130, 15
%132 = add nsw i32 %131, 1023
store i32 %132, i32* %17
%133 = load i32, i32* %17
%134 = shl i32 %133, 20
store i32 %134, i32* %15
%135 = load i32, i32* %13
%136 = shl i32 %135, 10
store i32 %136, i32* %16
%137 = load i32, i32* %14
%138 = load i32, i32* %15
%139 = or i32 %137, %138
%140 = load i32, i32* %16
%141 = or i32 %139, %140
%142 = load i32*, i32** %9
%143 = getelementptr inbounds i32, i32* %142, i32 1
store i32* %143, i32** %9
store i32 %141, i32* %142
br label %144
144: ; preds = %126, %125
br label %145
145: ; preds = %144, %89
br label %146
146: ; preds = %145, %65
%147 = load i32*, i32** %9
%148 = getelementptr inbounds i32, i32* %147, i32 1
store i32* %148, i32** %9
br label %54
149: ; preds = %54
store i32 0, i32* %4
br label %150
150: ; preds = %149, %52, %41, %40
%151 = load i32, i32* %4
ret i32 %151
}

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