#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 */
double pow2i(int);
__attribute__((visibility("default"))) const double xldexp(double x, int exp) {
  if (exp > 2100)
    exp = 2100;
  if (exp < -2100)
    exp = -2100;
  int e0 = exp >> 2;
  if (exp < 0)
    e0++;
  if (-100 < exp && exp < 100)
    e0 = 0;
  int e1 = exp - (e0 << 2);
  double p = pow2i(e0);
  double ret = x * pow2i(e1) * p * p * p * p;
  return ret;
}


x86 assembly (clang, -O0):
<xldexp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
cmpl   $0x834,-0xc(%rbp)
jle    1134 <xldexp+0x24>
movl   $0x834,-0xc(%rbp)
cmpl   $0xfffff7cc,-0xc(%rbp)
jge    1148 <xldexp+0x38>
movl   $0xfffff7cc,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1164 <xldexp+0x54>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    $0xffffff9c,%eax
cmp    -0xc(%rbp),%eax
jge    1183 <xldexp+0x73>
cmpl   $0x64,-0xc(%rbp)
jge    1183 <xldexp+0x73>
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x2,%ecx
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <pow2i@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <pow2i@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xldexp>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movsd  %xmm0,0x8(%rsp)
cmp    $0x834,%edi
mov    $0x834,%eax
cmovge %eax,%ebx
cmp    $0xfffff7cd,%ebx
mov    $0xfffff7cc,%eax
cmovl  %eax,%ebx
mov    %ebx,%eax
sar    $0x2,%eax
mov    %ebx,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
lea    0x63(%rbx),%eax
xor    %edi,%edi
cmp    $0xc7,%eax
cmovae %ecx,%edi
lea    0x0(,%rdi,4),%eax
sub    %eax,%ebx
call   1030 <pow2i@plt>
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
call   1030 <pow2i@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @xldexp(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
store double %0, double* %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 2100
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 2100, i32* %4
br label %12
12: ; preds = %11, %2
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, -2100
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 -2100, i32* %4
br label %16
16: ; preds = %15, %12
%17 = load i32, i32* %4
%18 = ashr i32 %17, 2
store i32 %18, i32* %5
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %24
24: ; preds = %21, %16
%25 = load i32, i32* %4
%26 = icmp slt i32 -100, %25
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 100
br i1 %29, label %30, label %31
30: ; preds = %27
store i32 0, i32* %5
br label %31
31: ; preds = %30, %27, %24
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = shl i32 %33, 2
%35 = sub nsw i32 %32, %34
store i32 %35, i32* %6
%36 = load i32, i32* %5
%37 = call double @pow2i(i32 %36)
store double %37, double* %7
%38 = load double, double* %3
%39 = load i32, i32* %6
%40 = call double @pow2i(i32 %39)
%41 = fmul double %38, %40
%42 = load double, double* %7
%43 = fmul double %41, %42
%44 = load double, double* %7
%45 = fmul double %43, %44
%46 = load double, double* %7
%47 = fmul double %45, %46
%48 = load double, double* %7
%49 = fmul double %47, %48
store double %49, double* %8
%50 = load double, double* %8
ret double %50
}

LLVM IR (-O2):
define double @xldexp(double %0, i32 %1) {
%3 = icmp slt i32 %1, 2100
%4 = select i1 %3, i32 %1, i32 2100
%5 = icmp sgt i32 %4, -2100
%6 = select i1 %5, i32 %4, i32 -2100
%7 = ashr i32 %6, 2
%8 = lshr i32 %6, 31
%9 = add nsw i32 %7, %8
%10 = add nsw i32 %6, 99
%11 = icmp ult i32 %10, 199
%12 = select i1 %11, i32 0, i32 %9
%13 = mul nsw i32 %12, -4
%14 = add nsw i32 %13, %6
%15 = tail call double @pow2i(i32 %12)
%16 = tail call double @pow2i(i32 %14)
%17 = fmul double %16, %0
%18 = fmul double %15, %17
%19 = fmul double %15, %18
%20 = fmul double %15, %19
%21 = fmul double %15, %20
ret double %21
}