#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 pow(double, double);
double sqrt(double);
double corbel_zget(double q) {
  int iflag = 0;
  double x, tmp, corbel_zget_out;
  if (q < 0.0) {
    iflag = 1;
    q = -q;
  }
  if (q < 1.0e-3) {
    corbel_zget_out = q * (1.0 - (q * q / 3.0) * (1.0 - q * q));
  } else {
    x = 0.50 * (3.0 * q + sqrt(9.0 * (pow(q, 2)) + 4.0));
    tmp = pow(x, (1.0 / 3.0));
    corbel_zget_out = tmp - 1.0 / tmp;
  }
  if (iflag == 1) {
    corbel_zget_out = -corbel_zget_out;
    q = -q;
  }
  return corbel_zget_out;
}


x86 assembly (clang, -O0):
<corbel_zget>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    116a <corbel_zget+0x4a>
movl   $0x1,-0xc(%rbp)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xe8e(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11fe <corbel_zget+0xde>
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  0xe8c(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  -0x8(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm3
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm2
movsd  0xe43(%rip),%xmm3
addsd  %xmm3,%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xe1c(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    128f <corbel_zget+0x16f>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe23(%rip),%xmm1
call   1030 <pow@plt>
movsd  0xe06(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe02(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  -0x30(%rbp),%xmm1
movsd  0xddc(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xdc4(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xda6(%rip),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xd87(%rip),%xmm1
divsd  -0x20(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    12db <corbel_zget+0x1bb>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<corbel_zget>:
sub    $0x28,%rsp
movapd %xmm0,%xmm4
movapd 0xed0(%rip),%xmm0
xorpd  %xmm4,%xmm0
xorpd  %xmm1,%xmm1
movapd %xmm4,%xmm5
cmpltsd %xmm1,%xmm5
andpd  %xmm5,%xmm0
andnpd %xmm4,%xmm5
orpd   %xmm0,%xmm5
movsd  0xebb(%rip),%xmm0
ucomisd %xmm5,%xmm0
movapd %xmm5,%xmm0
mulsd  %xmm5,%xmm0
jbe    1191 <corbel_zget+0x71>
movapd %xmm5,%xmm1
mulsd  %xmm5,%xmm1
movsd  0xed5(%rip),%xmm2
movapd %xmm2,%xmm3
divsd  0xed1(%rip),%xmm0
subsd  %xmm1,%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm5,%xmm0
jmp    1205 <corbel_zget+0xe5>
movapd %xmm4,0x10(%rsp)
mulsd  0xe79(%rip),%xmm0
addsd  0xe79(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11b3 <corbel_zget+0x93>
sqrtsd %xmm0,%xmm0
jmp    11c2 <corbel_zget+0xa2>
movapd %xmm5,(%rsp)
call   1040 <sqrt@plt>
movapd (%rsp),%xmm5
movsd  0xe5e(%rip),%xmm2
mulsd  %xmm5,%xmm2
addsd  %xmm0,%xmm2
mulsd  0xe56(%rip),%xmm2
movsd  0xe56(%rip),%xmm1
movapd %xmm2,%xmm0
call   1030 <pow@plt>
movapd %xmm0,%xmm1
movsd  0xe49(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
movapd 0x10(%rsp),%xmm4
movapd 0xdf3(%rip),%xmm1
xorpd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
cmpltsd %xmm2,%xmm4
andpd  %xmm4,%xmm1
andnpd %xmm0,%xmm4
orpd   %xmm1,%xmm4
movapd %xmm4,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @corbel_zget(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %2
store i32 0, i32* %3
%7 = load double, double* %2
%8 = fcmp olt double %7, 0.000000e+00
br i1 %8, label %9, label %12
9: ; preds = %1
store i32 1, i32* %3
%10 = load double, double* %2
%11 = fneg double %10
store double %11, double* %2
br label %12
12: ; preds = %9, %1
%13 = load double, double* %2
%14 = fcmp olt double %13, 1.000000e-03
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = load double, double* %2
%17 = load double, double* %2
%18 = load double, double* %2
%19 = fmul double %17, %18
%20 = fdiv double %19, 3.000000e+00
%21 = load double, double* %2
%22 = load double, double* %2
%23 = fneg double %21
%24 = call double @llvm.fmuladd.f64(double %23, double %22, double 1.000000e+00)
%25 = fneg double %20
%26 = call double @llvm.fmuladd.f64(double %25, double %24, double 1.000000e+00)
%27 = fmul double %16, %26
store double %27, double* %6
br label %42
28: ; preds = %12
%29 = load double, double* %2
%30 = load double, double* %2
%31 = call double @pow(double %30, double 2.000000e+00)
%32 = call double @llvm.fmuladd.f64(double 9.000000e+00, double %31, double 4.000000e+00)
%33 = call double @sqrt(double %32)
%34 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %29, double %33)
%35 = fmul double 5.000000e-01, %34
store double %35, double* %4
%36 = load double, double* %4
%37 = call double @pow(double %36, double 0x3FD5555555555555)
store double %37, double* %5
%38 = load double, double* %5
%39 = load double, double* %5
%40 = fdiv double 1.000000e+00, %39
%41 = fsub double %38, %40
store double %41, double* %6
br label %42
42: ; preds = %28, %15
%43 = load i32, i32* %3
%44 = icmp eq i32 %43, 1
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load double, double* %6
%47 = fneg double %46
store double %47, double* %6
%48 = load double, double* %2
%49 = fneg double %48
store double %49, double* %2
br label %50
50: ; preds = %45, %42
%51 = load double, double* %6
ret double %51
}

LLVM IR (-O2):
define double @corbel_zget(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = fneg double %0
%4 = select i1 %2, double %3, double %0
%5 = fcmp olt double %4, 1.000000e-03
%6 = fmul double %4, %4
br i1 %5, label %7, label %13
7: ; preds = %1
%8 = fneg double %4
%9 = tail call double @llvm.fmuladd.f64(double %8, double %4, double 1.000000e+00)
%10 = fdiv double %6, -3.000000e+00
%11 = tail call double @llvm.fmuladd.f64(double %10, double %9, double 1.000000e+00)
%12 = fmul double %4, %11
br label %21
13: ; preds = %1
%14 = tail call double @llvm.fmuladd.f64(double %6, double 9.000000e+00, double 4.000000e+00)
%15 = tail call double @sqrt(double %14)
%16 = tail call double @llvm.fmuladd.f64(double %4, double 3.000000e+00, double %15)
%17 = fmul double %16, 5.000000e-01
%18 = tail call double @pow(double %17, double 0x3FD5555555555555)
%19 = fdiv double 1.000000e+00, %18
%20 = fsub double %18, %19
br label %21
21: ; preds = %13, %7
%22 = phi double [ %12, %7 ], [ %20, %13 ]
%23 = fneg double %22
%24 = select i1 %2, double %23, double %22
ret double %24
}