#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 cos(double);
int /*<<< orphan*/ drift_kepu_p3solve(double, double, double, double, double,
                                      double *, int *);
double sin(double);
double sqrt(double);
void drift_kepu_guess(double dt0, double r0, double mu, double alpha, double u,
                      double *s) {
  if (alpha > 0.) {
    if ((dt0 / r0) <= 0.4) {
      *s = dt0 / r0 - (dt0 * dt0 * u) / (2. * r0 * r0 * r0);
      return;
    } else {
      double a = mu / alpha;
      double en = sqrt(mu / (a * a * a));
      double ec = 1. - r0 / a;
      double es = u / (en * a * a);
      double e = sqrt(ec * ec + es * es);
      double y = en * dt0 - es;
      double sy = sin(y);
      double cy = cos(y);
      double sigma = ((es * cy + ec * sy) >= 0 ? 1. : -1.);
      double x = y + sigma * 0.85 * e;
      *s = x / sqrt(alpha);
    }
  } else {
    int iflag = 0;
    drift_kepu_p3solve(dt0, r0, mu, alpha, u, s, &iflag);
    if (iflag != 0) {
      *s = dt0 / r0;
    }
  }
}


x86 assembly (clang, -O0):
<drift_kepu_guess>:
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)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    135a <drift_kepu_guess+0x21a>
movsd  -0x8(%rbp),%xmm1
divsd  -0x10(%rbp),%xmm1
movsd  0xe74(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11db <drift_kepu_guess+0x9b>
movsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
movsd  0xe69(%rip),%xmm2
mulsd  -0x10(%rbp),%xmm2
mulsd  -0x10(%rbp),%xmm2
mulsd  -0x10(%rbp),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    13b1 <drift_kepu_guess+0x271>
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm1
divsd  -0x38(%rbp),%xmm1
movsd  0xdf2(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd31(%rip),%xmm3
movsd  0xd31(%rip),%xmm2
xorps  %xmm0,%xmm0
cmplesd %xmm1,%xmm0
movaps %xmm0,%xmm1
andpd  %xmm3,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x60(%rbp),%xmm1
movsd  0xcf8(%rip),%xmm0
mulsd  -0x78(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    13b1 <drift_kepu_guess+0x271>
movl   $0x0,-0x84(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm4
mov    -0x30(%rbp),%rdi
lea    -0x84(%rbp),%rsi
call   1040 <drift_kepu_p3solve@plt>
cmpl   $0x0,-0x84(%rbp)
je     13ac <drift_kepu_guess+0x26c>
movsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    13b1 <drift_kepu_guess+0x271>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drift_kepu_guess>:
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
xorpd  %xmm5,%xmm5
ucomisd %xmm5,%xmm3
jbe    119f <drift_kepu_guess+0x5f>
movapd %xmm0,%xmm5
divsd  %xmm1,%xmm5
movsd  0xe9e(%rip),%xmm6
ucomisd %xmm5,%xmm6
jae    11e0 <drift_kepu_guess+0xa0>
movapd %xmm2,%xmm6
divsd  %xmm3,%xmm6
movapd %xmm6,%xmm5
mulsd  %xmm6,%xmm5
mulsd  %xmm6,%xmm5
divsd  %xmm5,%xmm2
xorpd  %xmm5,%xmm5
ucomisd %xmm5,%xmm2
movsd  %xmm3,0x38(%rsp)
movsd  %xmm0,0x10(%rsp)
jb     1209 <drift_kepu_guess+0xc9>
sqrtsd %xmm2,%xmm2
jmp    123e <drift_kepu_guess+0xfe>
movl   $0x0,0x24(%rsp)
lea    0x24(%rsp),%rsi
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
movsd  %xmm1,0x8(%rsp)
call   1040 <drift_kepu_p3solve@plt>
cmpl   $0x0,0x24(%rsp)
je     133b <drift_kepu_guess+0x1fb>
movsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rbx)
jmp    133b <drift_kepu_guess+0x1fb>
mulsd  %xmm0,%xmm0
mulsd  %xmm4,%xmm0
movapd %xmm1,%xmm2
addsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
divsd  %xmm2,%xmm0
subsd  %xmm0,%xmm5
movsd  %xmm5,(%rbx)
jmp    133b <drift_kepu_guess+0x1fb>
movapd %xmm2,%xmm0
movsd  %xmm4,0x28(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm6,0x18(%rsp)
call   1060 <sqrt@plt>
movsd  0x18(%rsp),%xmm6
xorpd  %xmm5,%xmm5
movsd  0x8(%rsp),%xmm1
movsd  0x28(%rsp),%xmm4
movapd %xmm0,%xmm2
divsd  %xmm6,%xmm1
movsd  0xdbe(%rip),%xmm3
subsd  %xmm1,%xmm3
movapd %xmm6,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm6,%xmm0
divsd  %xmm0,%xmm4
movapd %xmm4,%xmm1
mulsd  %xmm4,%xmm1
movsd  %xmm3,0x30(%rsp)
movapd %xmm3,%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm5,%xmm0
movsd  %xmm4,0x28(%rsp)
jb     128a <drift_kepu_guess+0x14a>
sqrtsd %xmm0,%xmm0
jmp    12a1 <drift_kepu_guess+0x161>
movsd  %xmm2,0x8(%rsp)
call   1060 <sqrt@plt>
movsd  0x8(%rsp),%xmm2
movsd  0x28(%rsp),%xmm4
movsd  0x10(%rsp),%xmm1
movsd  %xmm0,0x18(%rsp)
mulsd  %xmm1,%xmm2
subsd  %xmm4,%xmm2
movsd  %xmm2,0x8(%rsp)
movapd %xmm2,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movsd  0x18(%rsp),%xmm2
movsd  0x30(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
mulsd  0x28(%rsp),%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
xor    %eax,%eax
ucomisd %xmm1,%xmm0
setae  %al
lea    0xd0b(%rip),%rcx
mulsd  (%rcx,%rax,8),%xmm2
addsd  0x8(%rsp),%xmm2
movsd  0x38(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jb     1322 <drift_kepu_guess+0x1e2>
sqrtsd %xmm0,%xmm0
jmp    1333 <drift_kepu_guess+0x1f3>
movsd  %xmm2,0x18(%rsp)
call   1060 <sqrt@plt>
movsd  0x18(%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,(%rbx)
add    $0x40,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @drift_kepu_guess(double %0, double %1, double %2, double %3, double %4, double* %5) {
%7 = alloca i32
%8 = fcmp ogt double %3, 0.000000e+00
br i1 %8, label %9, label %45
9: ; preds = %6
%10 = fdiv double %0, %1
%11 = fcmp ugt double %10, 4.000000e-01
br i1 %11, label %20, label %12
12: ; preds = %9
%13 = fmul double %0, %0
%14 = fmul double %13, %4
%15 = fmul double %1, 2.000000e+00
%16 = fmul double %15, %1
%17 = fmul double %16, %1
%18 = fdiv double %14, %17
%19 = fsub double %10, %18
store double %19, double* %5
br label %53
20: ; preds = %9
%21 = fdiv double %2, %3
%22 = fmul double %21, %21
%23 = fmul double %21, %22
%24 = fdiv double %2, %23
%25 = tail call double @sqrt(double %24)
%26 = fdiv double %1, %21
%27 = fsub double 1.000000e+00, %26
%28 = fmul double %21, %25
%29 = fmul double %21, %28
%30 = fdiv double %4, %29
%31 = fmul double %30, %30
%32 = tail call double @llvm.fmuladd.f64(double %27, double %27, double %31)
%33 = tail call double @sqrt(double %32)
%34 = fneg double %30
%35 = tail call double @llvm.fmuladd.f64(double %25, double %0, double %34)
%36 = tail call double @sin(double %35)
%37 = tail call double @cos(double %35)
%38 = fmul double %27, %36
%39 = tail call double @llvm.fmuladd.f64(double %30, double %37, double %38)
%40 = fcmp oge double %39, 0.000000e+00
%41 = select i1 %40, double 8.500000e-01, double -8.500000e-01
%42 = tail call double @llvm.fmuladd.f64(double %41, double %33, double %35)
%43 = tail call double @sqrt(double %3)
%44 = fdiv double %42, %43
store double %44, double* %5
br label %53
45: ; preds = %6
%46 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%47 = call i32 @drift_kepu_p3solve(double %0, double %1, double %2, double %3, double %4, double* %5, i32* %7)
%48 = load i32, i32* %7
%49 = icmp eq i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %45
%51 = fdiv double %0, %1
store double %51, double* %5
br label %52
52: ; preds = %50, %45
br label %53
53: ; preds = %12, %52, %20
ret void
}