#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 fabs(double);
double CubeRoot(double a, double error) {
  double _0 = (double)(0);
  double _1 = (double)(1);
  double _2 = (double)(2);
  double _3 = (double)(3);
  double xPrev = a;
  double xNext;
  double diff;
  do {
    xNext = ((_2 * xPrev) + (a / (xPrev * xPrev))) / _3;
    diff = fabs(xPrev - xNext);
    xPrev = xNext;
  } while (diff > error);
  return (xNext);
}


x86 assembly (clang, -O0):
<CubeRoot>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xef2(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xedd(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xec8(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm3
mulsd  -0x38(%rbp),%xmm3
divsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movaps 0xe99(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     1147 <CubeRoot+0x47>
movsd  -0x40(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<CubeRoot>:
movsd  0xef8(%rip),%xmm3
movapd 0xf00(%rip),%xmm4
movapd %xmm0,%xmm2
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movapd %xmm2,%xmm5
movapd %xmm2,%xmm6
mulsd  %xmm2,%xmm6
movapd %xmm0,%xmm7
divsd  %xmm6,%xmm7
addsd  %xmm2,%xmm2
addsd  %xmm7,%xmm2
divsd  %xmm3,%xmm2
subsd  %xmm2,%xmm5
andpd  %xmm4,%xmm5
ucomisd %xmm1,%xmm5
ja     1120 <CubeRoot+0x20>
movapd %xmm2,%xmm0
ret

LLVM IR (-O0):
define double @CubeRoot(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %3
store double %1, double* %4
store double 0.000000e+00, double* %5
store double 1.000000e+00, double* %6
store double 2.000000e+00, double* %7
store double 3.000000e+00, double* %8
%12 = load double, double* %3
store double %12, double* %9
br label %13
13: ; preds = %29, %2
%14 = load double, double* %7
%15 = load double, double* %9
%16 = load double, double* %3
%17 = load double, double* %9
%18 = load double, double* %9
%19 = fmul double %17, %18
%20 = fdiv double %16, %19
%21 = call double @llvm.fmuladd.f64(double %14, double %15, double %20)
%22 = load double, double* %8
%23 = fdiv double %21, %22
store double %23, double* %10
%24 = load double, double* %9
%25 = load double, double* %10
%26 = fsub double %24, %25
%27 = call double @llvm.fabs.f64(double %26)
store double %27, double* %11
%28 = load double, double* %10
store double %28, double* %9
br label %29
29: ; preds = %13
%30 = load double, double* %11
%31 = load double, double* %4
%32 = fcmp ogt double %30, %31
br i1 %32, label %13, label %33
33: ; preds = %29
%34 = load double, double* %10
ret double %34
}

LLVM IR (-O2):
define double @CubeRoot(double %0, double %1) {
br label %3
3: ; preds = %3, %2
%4 = phi double [ %0, %2 ], [ %8, %3 ]
%5 = fmul double %4, %4
%6 = fdiv double %0, %5
%7 = tail call double @llvm.fmuladd.f64(double %4, double 2.000000e+00, double %6)
%8 = fdiv double %7, 3.000000e+00
%9 = fsub double %4, %8
%10 = tail call double @llvm.fabs.f64(double %9)
%11 = fcmp ogt double %10, %1
br i1 %11, label %3, label %12
12: ; preds = %3
ret double %8
}