#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, int);
double sqrt(double);
void drift_kepu_p3solve(double dt0, double r0, double mu, double alpha,
                        double u, double *s, int *iflag) {
  double denom = (mu - alpha * r0) / 6.;
  double a2 = 0.5 * u / denom;
  double a1 = r0 / denom;
  double a0 = -dt0 / denom;
  double q = (a1 - a2 * a2 / 3.) / 3.;
  double r = (a1 * a2 - 3. * a0) / 6. - a2 * a2 * a2 / 27.;
  double sq2 = q * q * q + r * r;
  if (sq2 >= 0.) {
    double sq = sqrt(sq2);
    double p1, p2;
    if ((r + sq) <= 0.) {
      p1 = -pow(-(r + sq), 1. / 3.);
    } else {
      p1 = pow(r + sq, 1. / 3.);
    }
    if ((r - sq) <= 0.) {
      p2 = -pow(-(r - sq), 1. / 3.);
    } else {
      p2 = pow(r - sq, 1. / 3.);
    }
    *iflag = 0;
    *s = p1 + p2 - a2 / 3.;
  } else {
    *iflag = 1;
    *s = 0;
  }
}


x86 assembly (clang, -O0):
<drift_kepu_p3solve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe86(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe85(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%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  0xe22(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe12(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  0xdf7(%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  0xdc3(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x48(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movsd  0xda0(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
mulsd  -0x68(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     13df <drift_kepu_p3solve+0x2bf>
movsd  -0x70(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x68(%rbp),%xmm1
addsd  -0x78(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jb     1314 <drift_kepu_p3solve+0x1f4>
movsd  -0x68(%rbp),%xmm0
addsd  -0x78(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
xor    %edi,%edi
call   1030 <pow@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    132a <drift_kepu_p3solve+0x20a>
movsd  -0x68(%rbp),%xmm0
addsd  -0x78(%rbp),%xmm0
xor    %edi,%edi
call   1030 <pow@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x68(%rbp),%xmm1
subsd  -0x78(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jb     138d <drift_kepu_p3solve+0x26d>
movsd  -0x68(%rbp),%xmm0
subsd  -0x78(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
xor    %edi,%edi
call   1030 <pow@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    13a6 <drift_kepu_p3solve+0x286>
movsd  -0x68(%rbp),%xmm0
subsd  -0x78(%rbp),%xmm0
xor    %edi,%edi
call   1030 <pow@plt>
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x38(%rbp),%rax
movl   $0x0,(%rax)
movsd  -0x80(%rbp),%xmm0
addsd  -0x88(%rbp),%xmm0
ff
movsd  -0x48(%rbp),%xmm1
movsd  0xc46(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    13f4 <drift_kepu_p3solve+0x2d4>
mov    -0x38(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x30(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drift_kepu_p3solve>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mulsd  %xmm1,%xmm3
subsd  %xmm3,%xmm2
divsd  0xec9(%rip),%xmm2
mulsd  0xec9(%rip),%xmm4
mov    %rsi,%rbx
mov    %rdi,%r14
divsd  %xmm2,%xmm4
divsd  %xmm2,%xmm0
movapd %xmm4,%xmm5
mulsd  %xmm4,%xmm5
unpcklpd %xmm5,%xmm1
shufpd $0x2,0xebe(%rip),%xmm2
divpd  %xmm2,%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
movapd %xmm1,%xmm3
subsd  %xmm2,%xmm3
movsd  0xe92(%rip),%xmm2
divsd  %xmm2,%xmm3
mulsd  %xmm2,%xmm0
mulsd  %xmm4,%xmm1
addsd  %xmm0,%xmm1
mulsd  %xmm4,%xmm5
unpcklpd %xmm5,%xmm1
divpd  0xe92(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
subsd  %xmm0,%xmm1
movapd %xmm3,%xmm0
mulsd  %xmm3,%xmm0
movapd %xmm1,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jae    11d7 <drift_kepu_p3solve+0xb7>
movl   $0x1,(%rbx)
jmp    1295 <drift_kepu_p3solve+0x175>
movsd  %xmm4,0x8(%rsp)
movapd %xmm1,0x20(%rsp)
jb     11ee <drift_kepu_p3solve+0xce>
xorps  %xmm2,%xmm2
sqrtsd %xmm0,%xmm2
jmp    11fd <drift_kepu_p3solve+0xdd>
call   1040 <sqrt@plt>
movapd 0x20(%rsp),%xmm1
movapd %xmm0,%xmm2
movapd %xmm1,%xmm0
movsd  %xmm2,(%rsp)
addsd  %xmm2,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    121d <drift_kepu_p3solve+0xfd>
xor    %edi,%edi
call   1030 <pow@plt>
jmp    1234 <drift_kepu_p3solve+0x114>
xorpd  0xe1b(%rip),%xmm0
xor    %edi,%edi
call   1030 <pow@plt>
xorpd  0xe0c(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
movapd 0x20(%rsp),%xmm0
subsd  (%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    1258 <drift_kepu_p3solve+0x138>
xor    %edi,%edi
call   1030 <pow@plt>
jmp    126f <drift_kepu_p3solve+0x14f>
xorpd  0xde0(%rip),%xmm0
xor    %edi,%edi
call   1030 <pow@plt>
xorpd  0xdd1(%rip),%xmm0
movapd 0x10(%rsp),%xmm2
addsd  %xmm0,%xmm2
movl   $0x0,(%rbx)
movsd  0x8(%rsp),%xmm1
divsd  0xd8b(%rip),%xmm1
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm2
movsd  %xmm2,(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

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

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