#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 const, double);
double sqrt(double const);
int cdrift_kepu_p3solve(const double dt, const double r0, const double mu,
                        const double alpha, const double u, double *s) {
  const double denom = (mu - alpha * r0) / 6.0;
  const double a2 = 0.5 * u / denom;
  const double a1 = r0 / denom;
  const double a0 = -dt / denom;
  const double q = (a1 - a2 * a2 / 3.0) / 3.0;
  const double r = (a1 * a2 - 3.0 * a0) / 6.0 - (pow(a2, 3)) / 27.0;
  const double sq2 = pow(q, 3) + pow(r, 2);
  if (sq2 >= 0.0) {
    const double sq = sqrt(sq2);
    double p2 = 0.0, p1 = 0.0;
    if ((r + sq) <= 0.0) {
      p1 = pow(-(-(r + sq)), (1.0 / 3.0));
    } else {
      p1 = pow((r + sq), (1.0 / 3.0));
    }
    if ((r - sq) <= 0.0) {
      p2 = pow(-(-(r - sq)), (1.0 / 3.0));
    } else {
      p2 = pow((r - sq), (1.0 / 3.0));
    }
    *s = p1 + p2 - a2 / 3.0;
    return 0;
  }
  *s = 0;
  return -1;
}


x86 assembly (clang, -O0):
<cdrift_kepu_p3solve>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
mov    %rdi,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe9a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe91(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movsd  0xe1e(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe0e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  0xdf3(%rip),%xmm1
mulsd  -0x58(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdd7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
movsd  0xdae(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
movsd  0xd9e(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  0xd7c(%rip),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
movsd  0xd5a(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1433 <cdrift_kepu_p3solve+0x313>
movsd  -0x70(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x78(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x68(%rbp),%xmm1
addsd  -0x78(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jb     135c <cdrift_kepu_p3solve+0x23c>
movsd  -0x68(%rbp),%xmm0
addsd  -0x78(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xcde(%rip),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x88(%rbp)
ff
jmp    137b <cdrift_kepu_p3solve+0x25b>
movsd  -0x68(%rbp),%xmm0
addsd  -0x78(%rbp),%xmm0
movsd  0xcba(%rip),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x68(%rbp),%xmm1
subsd  -0x78(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jb     13e1 <cdrift_kepu_p3solve+0x2c1>
movsd  -0x68(%rbp),%xmm0
subsd  -0x78(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xc56(%rip),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x80(%rbp)
jmp    13fd <cdrift_kepu_p3solve+0x2dd>
movsd  -0x68(%rbp),%xmm0
subsd  -0x78(%rbp),%xmm0
movsd  0xc35(%rip),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x88(%rbp),%xmm0
ff
addsd  -0x80(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xbf1(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1445 <cdrift_kepu_p3solve+0x325>
mov    -0x38(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdrift_kepu_p3solve>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
mulsd  %xmm1,%xmm3
subsd  %xmm3,%xmm2
divsd  0xec8(%rip),%xmm2
mulsd  0xec8(%rip),%xmm4
divsd  %xmm2,%xmm4
divsd  %xmm2,%xmm0
movapd %xmm4,%xmm5
mulsd  %xmm4,%xmm5
movapd %xmm1,%xmm3
unpcklpd %xmm5,%xmm3
shufpd $0x2,0xecf(%rip),%xmm2
divpd  %xmm2,%xmm3
movapd %xmm3,%xmm1
unpckhpd %xmm3,%xmm1
movapd %xmm3,%xmm2
subsd  %xmm1,%xmm2
movsd  0xe93(%rip),%xmm1
divsd  %xmm1,%xmm2
movapd %xmm2,0x10(%rsp)
mulsd  %xmm1,%xmm0
mulsd  %xmm4,%xmm3
addsd  %xmm0,%xmm3
movapd %xmm3,(%rsp)
movsd  %xmm4,0x28(%rsp)
movapd %xmm4,%xmm0
call   1030 <pow@plt>
movapd (%rsp),%xmm1
unpcklpd %xmm0,%xmm1
divpd  0xe88(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
subsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
movapd 0x10(%rsp),%xmm0
movsd  0xe39(%rip),%xmm1
call   1030 <pow@plt>
movapd %xmm0,%xmm1
movapd (%rsp),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    $0xffffffff,%eax
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     126c <cdrift_kepu_p3solve+0x14c>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     120f <cdrift_kepu_p3solve+0xef>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    1218 <cdrift_kepu_p3solve+0xf8>
call   1040 <sqrt@plt>
movapd %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
movapd (%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  0xde9(%rip),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,0x10(%rsp)
movapd (%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
movsd  0xdcb(%rip),%xmm1
call   1030 <pow@plt>
addsd  0x10(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
divsd  0xdba(%rip),%xmm1
addsd  %xmm0,%xmm1
xor    %eax,%eax
movsd  %xmm1,(%rbx)
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @cdrift_kepu_p3solve(double %0, double %1, double %2, double %3, double %4, double* %5) {
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double*
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double* %5, double** %13
%24 = load double, double* %10
%25 = load double, double* %11
%26 = load double, double* %9
%27 = fneg double %25
%28 = call double @llvm.fmuladd.f64(double %27, double %26, double %24)
%29 = fdiv double %28, 6.000000e+00
store double %29, double* %14
%30 = load double, double* %12
%31 = fmul double 5.000000e-01, %30
%32 = load double, double* %14
%33 = fdiv double %31, %32
store double %33, double* %15
%34 = load double, double* %9
%35 = load double, double* %14
%36 = fdiv double %34, %35
store double %36, double* %16
%37 = load double, double* %8
%38 = fneg double %37
%39 = load double, double* %14
%40 = fdiv double %38, %39
store double %40, double* %17
%41 = load double, double* %16
%42 = load double, double* %15
%43 = load double, double* %15
%44 = fmul double %42, %43
%45 = fdiv double %44, 3.000000e+00
%46 = fsub double %41, %45
%47 = fdiv double %46, 3.000000e+00
store double %47, double* %18
%48 = load double, double* %16
%49 = load double, double* %15
%50 = load double, double* %17
%51 = fmul double 3.000000e+00, %50
%52 = fneg double %51
%53 = call double @llvm.fmuladd.f64(double %48, double %49, double %52)
%54 = fdiv double %53, 6.000000e+00
%55 = load double, double* %15
%56 = call double @pow(double %55, double 3.000000e+00)
%57 = fdiv double %56, 2.700000e+01
%58 = fsub double %54, %57
store double %58, double* %19
%59 = load double, double* %18
%60 = call double @pow(double %59, double 3.000000e+00)
%61 = load double, double* %19
%62 = call double @pow(double %61, double 2.000000e+00)
%63 = fadd double %60, %62
store double %63, double* %20
%64 = load double, double* %20
%65 = fcmp oge double %64, 0.000000e+00
br i1 %65, label %66, label %110
66: ; preds = %6
%67 = load double, double* %20
%68 = call double @sqrt(double %67)
store double %68, double* %21
store double 0.000000e+00, double* %22
store double 0.000000e+00, double* %23
%69 = load double, double* %19
%70 = load double, double* %21
%71 = fadd double %69, %70
%72 = fcmp ole double %71, 0.000000e+00
br i1 %72, label %73, label %80
73: ; preds = %66
%74 = load double, double* %19
%75 = load double, double* %21
%76 = fadd double %74, %75
%77 = fneg double %76
%78 = fneg double %77
%79 = call double @pow(double %78, double 0x3FD5555555555555)
store double %79, double* %23
br label %85
80: ; preds = %66
%81 = load double, double* %19
%82 = load double, double* %21
%83 = fadd double %81, %82
%84 = call double @pow(double %83, double 0x3FD5555555555555)
store double %84, double* %23
br label %85
85: ; preds = %80, %73
%86 = load double, double* %19
%87 = load double, double* %21
%88 = fsub double %86, %87
%89 = fcmp ole double %88, 0.000000e+00
br i1 %89, label %90, label %97
90: ; preds = %85
%91 = load double, double* %19
%92 = load double, double* %21
%93 = fsub double %91, %92
%94 = fneg double %93
%95 = fneg double %94
%96 = call double @pow(double %95, double 0x3FD5555555555555)
store double %96, double* %22
br label %102
97: ; preds = %85
%98 = load double, double* %19
%99 = load double, double* %21
%100 = fsub double %98, %99
%101 = call double @pow(double %100, double 0x3FD5555555555555)
store double %101, double* %22
br label %102
102: ; preds = %97, %90
%103 = load double, double* %23
%104 = load double, double* %22
%105 = fadd double %103, %104
%106 = load double, double* %15
%107 = fdiv double %106, 3.000000e+00
%108 = fsub double %105, %107
%109 = load double*, double** %13
store double %108, double* %109
store i32 0, i32* %7
br label %112
110: ; preds = %6
%111 = load double*, double** %13
store double 0.000000e+00, double* %111
store i32 -1, i32* %7
br label %112
112: ; preds = %110, %102
%113 = load i32, i32* %7
ret i32 %113
}

LLVM IR (-O2):
define i32 @cdrift_kepu_p3solve(double %0, double %1, double %2, double %3, double %4, double* nocapture writeonly %5) {
%7 = fneg double %3
%8 = tail call double @llvm.fmuladd.f64(double %7, double %1, double %2)
%9 = fdiv double %8, 6.000000e+00
%10 = fmul double %4, 5.000000e-01
%11 = fdiv double %10, %9
%12 = fneg double %0
%13 = fdiv double %12, %9
%14 = fmul double %11, %11
%15 = insertelement <2 x double> poison, double %1, i64 0
%16 = insertelement <2 x double> %15, double %14, i64 1
%17 = insertelement <2 x double> <double poison, double 3.000000e+00>, double %9, i64 0
%18 = fdiv <2 x double> %16, %17
%19 = extractelement <2 x double> %18, i64 0
%20 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%21 = fsub <2 x double> %18, %20
%22 = extractelement <2 x double> %21, i64 0
%23 = fdiv double %22, 3.000000e+00
%24 = fmul double %13, -3.000000e+00
%25 = tail call double @llvm.fmuladd.f64(double %19, double %11, double %24)
%26 = tail call double @pow(double %11, double 3.000000e+00)
%27 = insertelement <2 x double> poison, double %25, i64 0
%28 = insertelement <2 x double> %27, double %26, i64 1
%29 = fdiv <2 x double> %28, <double 6.000000e+00, double 2.700000e+01>
%30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%31 = fsub <2 x double> %29, %30
%32 = extractelement <2 x double> %31, i64 0
%33 = tail call double @pow(double %23, double 3.000000e+00)
%34 = fmul <2 x double> %31, %31
%35 = extractelement <2 x double> %34, i64 0
%36 = fadd double %33, %35
%37 = fcmp ult double %36, 0.000000e+00
br i1 %37, label %47, label %38
38: ; preds = %6
%39 = tail call double @sqrt(double %36)
%40 = fadd double %32, %39
%41 = tail call double @pow(double %40, double 0x3FD5555555555555)
%42 = fsub double %32, %39
%43 = tail call double @pow(double %42, double 0x3FD5555555555555)
%44 = fadd double %41, %43
%45 = fdiv double %11, 3.000000e+00
%46 = fsub double %44, %45
br label %47
47: ; preds = %6, %38
%48 = phi double [ %46, %38 ], [ 0.000000e+00, %6 ]
%49 = phi i32 [ 0, %38 ], [ -1, %6 ]
store double %48, double* %5
ret i32 %49
}