#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 frexp(double, int *);
double ldexp(double, int);
double CubeRoot(double x) {
  double fr, r;
  int ex, shx;
  fr = frexp(x, &ex);
  shx = ex % 3;
  if (shx > 0)
    shx -= 3;
  ex = (ex - shx) / 3;
  fr = ldexp(fr, shx);
  fr = ((((45.2548339756803022511987494 * fr + 192.2798368355061050458134625) *
              fr +
          119.1654824285581628956914143) *
             fr +
         13.43250139086239872172837314) *
            fr +
        0.1636161226585754240958355063) /
       ((((14.80884093219134573786480845 * fr + 151.9714051044435648658557668) *
              fr +
          168.5254414101568283957668343) *
             fr +
         33.9905941350215598754191872) *
            fr +
        1.0);
  r = ldexp(fr, ex);
  r = (2.0 * r + x / (r * r)) / 3.0;
  r = (2.0 * r + x / (r * r)) / 3.0;
  return (r);
}


x86 assembly (clang, -O0):
<CubeRoot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    -0x1c(%rbp),%rdi
call   1040 <frexp@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    1161 <CubeRoot+0x41>
mov    -0x20(%rbp),%eax
sub    $0x3,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x20(%rbp),%edi
call   1030 <ldexp@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xeb7(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeb3(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe8e(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe71(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe54(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe33(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe2f(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe0a(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xded(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdd0(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
call   1030 <ldexp@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd81(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd50(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CubeRoot>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <frexp@plt>
movslq 0x4(%rsp),%rax
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
mov    %eax,%edx
sub    %ecx,%edx
neg    %ecx
test   %edx,%edx
lea    -0x3(%rax,%rcx,1),%edi
cmovle %edx,%edi
sub    %edi,%eax
cltq
imul   $0x55555556,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
shr    $0x20,%rbx
add    %eax,%ebx
call   1030 <ldexp@plt>
unpcklpd %xmm0,%xmm0
movapd 0xe77(%rip),%xmm1
mulpd  %xmm0,%xmm1
addpd  0xe7b(%rip),%xmm1
mulpd  %xmm0,%xmm1
addpd  0xe7f(%rip),%xmm1
mulpd  %xmm0,%xmm1
addpd  0xe83(%rip),%xmm1
mulpd  %xmm1,%xmm0
addpd  0xe87(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
divsd  %xmm1,%xmm0
mov    %ebx,%edi
call   1030 <ldexp@plt>
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm3
movapd %xmm3,%xmm2
divsd  %xmm1,%xmm2
addsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
movsd  0xe5e(%rip),%xmm1
divsd  %xmm1,%xmm0
movapd %xmm0,%xmm2
mulsd  %xmm0,%xmm2
divsd  %xmm2,%xmm3
addsd  %xmm0,%xmm0
addsd  %xmm3,%xmm0
divsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @CubeRoot(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
store double %0, double* %2
%7 = load double, double* %2
%8 = call double @frexp(double %7, i32* %5)
store double %8, double* %3
%9 = load i32, i32* %5
%10 = srem i32 %9, 3
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i32, i32* %6
%15 = sub nsw i32 %14, 3
store i32 %15, i32* %6
br label %16
16: ; preds = %13, %1
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = sub nsw i32 %17, %18
%20 = sdiv i32 %19, 3
store i32 %20, i32* %5
%21 = load double, double* %3
%22 = load i32, i32* %6
%23 = call double @ldexp(double %21, i32 %22)
store double %23, double* %3
%24 = load double, double* %3
%25 = call double @llvm.fmuladd.f64(double 0x4046A09E6653BA70, double %24, double 0x406808F46C6116E0)
%26 = load double, double* %3
%27 = call double @llvm.fmuladd.f64(double %25, double %26, double 0x405DCA97439CAE14)
%28 = load double, double* %3
%29 = call double @llvm.fmuladd.f64(double %27, double %28, double 0x402ADD70D2827500)
%30 = load double, double* %3
%31 = call double @llvm.fmuladd.f64(double %29, double %30, double 0x3FC4F15F83F55D2D)
%32 = load double, double* %3
%33 = call double @llvm.fmuladd.f64(double 0x402D9E20660EDB21, double %32, double 0x4062FF15C0285815)
%34 = load double, double* %3
%35 = call double @llvm.fmuladd.f64(double %33, double %34, double 0x406510D06A8112CE)
%36 = load double, double* %3
%37 = call double @llvm.fmuladd.f64(double %35, double %36, double 0x4040FECBC9E2C375)
%38 = load double, double* %3
%39 = call double @llvm.fmuladd.f64(double %37, double %38, double 1.000000e+00)
%40 = fdiv double %31, %39
store double %40, double* %3
%41 = load double, double* %3
%42 = load i32, i32* %5
%43 = call double @ldexp(double %41, i32 %42)
store double %43, double* %4
%44 = load double, double* %4
%45 = load double, double* %2
%46 = load double, double* %4
%47 = load double, double* %4
%48 = fmul double %46, %47
%49 = fdiv double %45, %48
%50 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %44, double %49)
%51 = fdiv double %50, 3.000000e+00
store double %51, double* %4
%52 = load double, double* %4
%53 = load double, double* %2
%54 = load double, double* %4
%55 = load double, double* %4
%56 = fmul double %54, %55
%57 = fdiv double %53, %56
%58 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %52, double %57)
%59 = fdiv double %58, 3.000000e+00
store double %59, double* %4
%60 = load double, double* %4
ret double %60
}

LLVM IR (-O2):
define double @CubeRoot(double %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call double @frexp(double %0, i32* %2)
%5 = load i32, i32* %2
%6 = srem i32 %5, 3
%7 = icmp sgt i32 %6, 0
%8 = add nsw i32 %6, -3
%9 = select i1 %7, i32 %8, i32 %6
%10 = sub nsw i32 %5, %9
%11 = sdiv i32 %10, 3
%12 = tail call double @ldexp(double %4, i32 %9)
%13 = insertelement <2 x double> poison, double %12, i64 0
%14 = shufflevector <2 x double> %13, <2 x double> poison, <2 x i32> zeroinitializer
%15 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %14, <2 x double> <double 0x4046A09E6653BA70, double 0x402D9E20660EDB21>, <2 x double> <double 0x406808F46C6116E0, double 0x4062FF15C0285815>)
%16 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %15, <2 x double> %14, <2 x double> <double 0x405DCA97439CAE14, double 0x406510D06A8112CE>)
%17 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %16, <2 x double> %14, <2 x double> <double 0x402ADD70D2827500, double 0x4040FECBC9E2C375>)
%18 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %17, <2 x double> %14, <2 x double> <double 0x3FC4F15F83F55D2D, double 1.000000e+00>)
%19 = extractelement <2 x double> %18, i64 0
%20 = extractelement <2 x double> %18, i64 1
%21 = fdiv double %19, %20
%22 = tail call double @ldexp(double %21, i32 %11)
%23 = fmul double %22, %22
%24 = fdiv double %0, %23
%25 = tail call double @llvm.fmuladd.f64(double %22, double 2.000000e+00, double %24)
%26 = fdiv double %25, 3.000000e+00
%27 = fmul double %26, %26
%28 = fdiv double %0, %27
%29 = tail call double @llvm.fmuladd.f64(double %26, double 2.000000e+00, double %28)
%30 = fdiv double %29, 3.000000e+00
ret double %30
}