#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 exp(double);
double fabs(double);
double log(double);
double cubroot(double x) {
  double a, b;
  if (x == 0.0)
    return 0.0;
  else {
    a = fabs(x);
    b = exp(log(a) / 3.0);
    return x > 0.0 ? b : -b;
  }
}


x86 assembly (clang, -O0):
<cubroot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1152 <cubroot+0x32>
jp     1152 <cubroot+0x32>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d3 <cubroot+0xb3>
movsd  -0x10(%rbp),%xmm0
movaps 0xeb2(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <log@plt>
movsd  0xe87(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11a8 <cubroot+0x88>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11c9 <cubroot+0xa9>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cubroot>:
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1131 <cubroot+0x11>
jp     1131 <cubroot+0x11>
ret
sub    $0x18,%rsp
movapd 0xec3(%rip),%xmm0
andpd  %xmm1,%xmm0
movapd %xmm1,(%rsp)
call   1040 <log@plt>
divsd  0xecd(%rip),%xmm0
call   1030 <exp@plt>
movapd %xmm0,%xmm1
movapd 0xeac(%rip),%xmm2
xorpd  %xmm0,%xmm2
xorpd  %xmm0,%xmm0
cmpltsd (%rsp),%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @cubroot(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
%6 = load double, double* %3
%7 = fcmp oeq double %6, 0.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %1
store double 0.000000e+00, double* %2
br label %25
9: ; preds = %1
%10 = load double, double* %3
%11 = call double @llvm.fabs.f64(double %10)
store double %11, double* %4
%12 = load double, double* %4
%13 = call double @log(double %12)
%14 = fdiv double %13, 3.000000e+00
%15 = call double @exp(double %14)
store double %15, double* %5
%16 = load double, double* %3
%17 = fcmp ogt double %16, 0.000000e+00
br i1 %17, label %18, label %20
18: ; preds = %9
%19 = load double, double* %5
br label %23
20: ; preds = %9
%21 = load double, double* %5
%22 = fneg double %21
br label %23
23: ; preds = %20, %18
%24 = phi double [ %19, %18 ], [ %22, %20 ]
store double %24, double* %2
br label %25
25: ; preds = %23, %8
%26 = load double, double* %2
ret double %26
}

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