#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 */
int /*<<< orphan*/ fabs(double);
double pow(int /*<<< orphan*/, int);
double cbrt(double a) {
  double w;
  if (a == 0.)
    return 0.;
  w = pow(fabs(a), 1. / 3.);
  if (a < 0.)
    w = -w;
  return (w + 3. * a / (2. * w * w + a / w)) / 2.;
}


x86 assembly (clang, -O0):
<cbrt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1152 <cbrt+0x32>
jp     1152 <cbrt+0x32>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e8 <cbrt+0xc8>
movsd  -0x10(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1040 <pow@plt>
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1199 <cbrt+0x79>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe62(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xe4d(%rip),%xmm2
mulsd  -0x18(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm4
movsd  -0x10(%rbp),%xmm3
divsd  -0x18(%rbp),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  0xe21(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cbrt>:
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1131 <cbrt+0x11>
jp     1131 <cbrt+0x11>
ret
push   %rax
movapd %xmm1,%xmm0
movsd  %xmm1,(%rsp)
call   1030 <fabs@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1040 <pow@plt>
movapd 0xeaf(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
movsd  (%rsp),%xmm4
movapd %xmm4,%xmm3
cmpltsd %xmm2,%xmm3
movapd %xmm3,%xmm2
andnpd %xmm0,%xmm2
andpd  %xmm1,%xmm3
orpd   %xmm2,%xmm3
movsd  0xe91(%rip),%xmm0
movapd %xmm4,%xmm2
mulsd  %xmm4,%xmm0
movapd %xmm3,%xmm1
addsd  %xmm3,%xmm1
divsd  %xmm3,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
addsd  %xmm3,%xmm0
mulsd  0xe6d(%rip),%xmm0
add    $0x8,%rsp
ret

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

LLVM IR (-O2):
define double @cbrt(double %0) {
%2 = fcmp oeq double %0, 0.000000e+00
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = tail call i32 @fabs(double %0)
%5 = tail call double @pow(i32 %4, i32 0)
%6 = fcmp olt double %0, 0.000000e+00
%7 = fneg double %5
%8 = select i1 %6, double %7, double %5
%9 = fmul double %0, 3.000000e+00
%10 = fmul double %8, 2.000000e+00
%11 = fdiv double %0, %8
%12 = tail call double @llvm.fmuladd.f64(double %10, double %8, double %11)
%13 = fdiv double %9, %12
%14 = fadd double %8, %13
%15 = fmul double %14, 5.000000e-01
br label %16
16: ; preds = %1, %3
%17 = phi double [ %15, %3 ], [ 0.000000e+00, %1 ]
ret double %17
}