#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 fabsk(double);
int ilogbk(double);
double ldexp2k(double, int);
double mla(double, double, double);
double mulsign(double, double);
__attribute__((visibility("default"))) const double xcbrt(double d) {
  double x, y, q = 1.0;
  int e, r;
  e = ilogbk(fabsk(d)) + 1;
  d = ldexp2k(d, -e);
  r = (e + 6144) % 3;
  q = (r == 1) ? 1.2599210498948731647672106 : q;
  q = (r == 2) ? 1.5874010519681994747517056 : q;
  q = ldexp2k(q, (e + 6144) / 3 - 2048);
  q = mulsign(q, d);
  d = fabsk(d);
  x = -0.640245898480692909870982;
  x = mla(x, d, 2.96155103020039511818595);
  x = mla(x, d, -5.73353060922947843636166);
  x = mla(x, d, 6.03990368989458747961407);
  x = mla(x, d, -3.85841935510444988821632);
  x = mla(x, d, 2.2307275302496609725722);
  y = x * x;
  y = y * y;
  x -= (d * y - x) * (1.0 / 3.0);
  y = d * x * x;
  y = (y - (2.0 / 3.0) * y * (y * x - 1)) * q;
  return y;
}


x86 assembly (clang, -O0):
<xcbrt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xe9b(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <fabsk@plt>
call   1060 <ilogbk@plt>
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x8(%rbp),%xmm0
xor    %edi,%edi
sub    -0x24(%rbp),%edi
call   1040 <ldexp2k@plt>
movsd  %xmm0,-0x8(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1800,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
jne    11c2 <xcbrt+0x72>
movsd  0xe50(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11cc <xcbrt+0x7c>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x2,-0x28(%rbp)
jne    11f2 <xcbrt+0xa2>
movsd  0xe28(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11fc <xcbrt+0xac>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x24(%rbp),%eax
add    $0x1800,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
sub    $0x800,%edi
call   1040 <ldexp2k@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
call   1030 <mulsign@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <fabsk@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  0xe00(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xde1(%rip),%xmm2
call   1070 <mla@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xdbd(%rip),%xmm2
call   1070 <mla@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xd99(%rip),%xmm2
call   1070 <mla@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xd75(%rip),%xmm2
call   1070 <mla@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xd51(%rip),%xmm2
call   1070 <mla@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xccf(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  0xc99(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xc76(%rip),%xmm3
addsd  %xmm3,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xcbrt>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,(%rsp)
call   1050 <fabsk@plt>
call   1060 <ilogbk@plt>
mov    %eax,%ebx
mov    %eax,%edi
not    %edi
movsd  (%rsp),%xmm0
call   1040 <ldexp2k@plt>
movsd  %xmm0,(%rsp)
mov    %ebx,%eax
add    $0x1801,%eax
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
lea    (%rax,%rcx,1),%edx
lea    (%rdx,%rdx,2),%edx
neg    %edx
lea    (%rbx,%rdx,1),%esi
add    $0x1801,%esi
xor    %edx,%edx
cmp    $0x1,%esi
sete   %bl
cmp    $0x2,%esi
je     11c2 <xcbrt+0x72>
mov    %bl,%dl
lea    0xe45(%rip),%rsi
movsd  (%rsi,%rdx,8),%xmm0
jmp    11ca <xcbrt+0x7a>
movsd  0xe46(%rip),%xmm0
lea    (%rax,%rcx,1),%edi
add    $0xfffff800,%edi
call   1040 <ldexp2k@plt>
movsd  (%rsp),%xmm1
call   1030 <mulsign@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1050 <fabsk@plt>
movaps %xmm0,%xmm1
movsd  %xmm0,(%rsp)
movsd  0xe16(%rip),%xmm0
movsd  0xe16(%rip),%xmm2
call   1070 <mla@plt>
movsd  0xe11(%rip),%xmm2
movsd  (%rsp),%xmm1
call   1070 <mla@plt>
movsd  0xe07(%rip),%xmm2
movsd  (%rsp),%xmm1
call   1070 <mla@plt>
movsd  0xdfd(%rip),%xmm2
movsd  (%rsp),%xmm1
call   1070 <mla@plt>
movsd  0xdf3(%rip),%xmm2
movsd  (%rsp),%xmm1
call   1070 <mla@plt>
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm1,%xmm1
movsd  (%rsp),%xmm2
mulsd  %xmm2,%xmm1
subsd  %xmm0,%xmm1
mulsd  0xdd0(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm2,%xmm0
addsd  0xdc0(%rip),%xmm0
movsd  0xdc0(%rip),%xmm1
mulsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
mulsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @xcbrt(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
store double %0, double* %2
store double 1.000000e+00, double* %5
%8 = load double, double* %2
%9 = call double @fabsk(double %8)
%10 = call i32 @ilogbk(double %9)
%11 = add nsw i32 %10, 1
store i32 %11, i32* %6
%12 = load double, double* %2
%13 = load i32, i32* %6
%14 = sub nsw i32 0, %13
%15 = call double @ldexp2k(double %12, i32 %14)
store double %15, double* %2
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 6144
%18 = srem i32 %17, 3
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %22
21: ; preds = %1
br label %24
22: ; preds = %1
%23 = load double, double* %5
br label %24
24: ; preds = %22, %21
%25 = phi double [ 0x3FF428A2F98D728B, %21 ], [ %23, %22 ]
store double %25, double* %5
%26 = load i32, i32* %7
%27 = icmp eq i32 %26, 2
br i1 %27, label %28, label %29
28: ; preds = %24
br label %31
29: ; preds = %24
%30 = load double, double* %5
br label %31
31: ; preds = %29, %28
%32 = phi double [ 0x3FF965FEA53D6E3D, %28 ], [ %30, %29 ]
store double %32, double* %5
%33 = load double, double* %5
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 6144
%36 = sdiv i32 %35, 3
%37 = sub nsw i32 %36, 2048
%38 = call double @ldexp2k(double %33, i32 %37)
store double %38, double* %5
%39 = load double, double* %5
%40 = load double, double* %2
%41 = call double @mulsign(double %39, double %40)
store double %41, double* %5
%42 = load double, double* %2
%43 = call double @fabsk(double %42)
store double %43, double* %2
store double 0xBFE47CE4F76BED42, double* %3
%44 = load double, double* %3
%45 = load double, double* %2
%46 = call double @mla(double %44, double %45, double 0x4007B141AAA12A9C)
store double %46, double* %3
%47 = load double, double* %3
%48 = load double, double* %2
%49 = call double @mla(double %47, double %48, double 0xC016EF22A5E505B3)
store double %49, double* %3
%50 = load double, double* %3
%51 = load double, double* %2
%52 = call double @mla(double %50, double %51, double 0x401828DC834C5911)
store double %52, double* %3
%53 = load double, double* %3
%54 = load double, double* %2
%55 = call double @mla(double %53, double %54, double 0xC00EDE0AF7836A8B)
store double %55, double* %3
%56 = load double, double* %3
%57 = load double, double* %2
%58 = call double @mla(double %56, double %57, double 0x4001D887ACE5AC54)
store double %58, double* %3
%59 = load double, double* %3
%60 = load double, double* %3
%61 = fmul double %59, %60
store double %61, double* %4
%62 = load double, double* %4
%63 = load double, double* %4
%64 = fmul double %62, %63
store double %64, double* %4
%65 = load double, double* %2
%66 = load double, double* %4
%67 = load double, double* %3
%68 = fneg double %67
%69 = call double @llvm.fmuladd.f64(double %65, double %66, double %68)
%70 = load double, double* %3
%71 = fneg double %69
%72 = call double @llvm.fmuladd.f64(double %71, double 0x3FD5555555555555, double %70)
store double %72, double* %3
%73 = load double, double* %2
%74 = load double, double* %3
%75 = fmul double %73, %74
%76 = load double, double* %3
%77 = fmul double %75, %76
store double %77, double* %4
%78 = load double, double* %4
%79 = load double, double* %4
%80 = fmul double 0x3FE5555555555555, %79
%81 = load double, double* %4
%82 = load double, double* %3
%83 = call double @llvm.fmuladd.f64(double %81, double %82, double -1.000000e+00)
%84 = fneg double %80
%85 = call double @llvm.fmuladd.f64(double %84, double %83, double %78)
%86 = load double, double* %5
%87 = fmul double %85, %86
store double %87, double* %4
%88 = load double, double* %4
ret double %88
}

LLVM IR (-O2):
define double @xcbrt(double %0) {
%2 = tail call double @fabsk(double %0)
%3 = tail call i32 @ilogbk(double %2)
%4 = xor i32 %3, -1
%5 = tail call double @ldexp2k(double %0, i32 %4)
%6 = add nsw i32 %3, 6145
%7 = srem i32 %6, 3
%8 = icmp eq i32 %7, 1
%9 = select i1 %8, double 0x3FF428A2F98D728B, double 1.000000e+00
%10 = icmp eq i32 %7, 2
%11 = select i1 %10, double 0x3FF965FEA53D6E3D, double %9
%12 = sdiv i32 %6, 3
%13 = add nsw i32 %12, -2048
%14 = tail call double @ldexp2k(double %11, i32 %13)
%15 = tail call double @mulsign(double %14, double %5)
%16 = tail call double @fabsk(double %5)
%17 = tail call double @mla(double 0xBFE47CE4F76BED42, double %16, double 0x4007B141AAA12A9C)
%18 = tail call double @mla(double %17, double %16, double 0xC016EF22A5E505B3)
%19 = tail call double @mla(double %18, double %16, double 0x401828DC834C5911)
%20 = tail call double @mla(double %19, double %16, double 0xC00EDE0AF7836A8B)
%21 = tail call double @mla(double %20, double %16, double 0x4001D887ACE5AC54)
%22 = fmul double %21, %21
%23 = fmul double %22, %22
%24 = fneg double %21
%25 = tail call double @llvm.fmuladd.f64(double %16, double %23, double %24)
%26 = fneg double %25
%27 = tail call double @llvm.fmuladd.f64(double %26, double 0x3FD5555555555555, double %21)
%28 = fmul double %16, %27
%29 = fmul double %27, %28
%30 = tail call double @llvm.fmuladd.f64(double %29, double %27, double -1.000000e+00)
%31 = fmul double %29, 0xBFE5555555555555
%32 = tail call double @llvm.fmuladd.f64(double %31, double %30, double %29)
%33 = fmul double %15, %32
ret double %33
}