#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 */
int /*<<< orphan*/ fabs(double);
int /*<<< orphan*/ reb_drift_kepu_stumpff(double, double *, double *, double *,
                                          double *);
int sqrt(int /*<<< orphan*/);
void reb_drift_kepu_lag(double *s, double dt0, double r0, double mu,
                        double alpha, double u, double *fp, double *c1,
                        double *c2, double *c3, int *iflag) {
  int ncmax = 400;
  double ln = 5.;
  int nc;
  for (nc = 0; nc <= ncmax; nc++) {
    double x = (*s) * (*s) * alpha;
    double c0;
    reb_drift_kepu_stumpff(x, &c0, c1, c2, c3);
    *c1 = (*c1) * (*s);
    *c2 = (*c2) * (*s) * (*s);
    *c3 = (*c3) * (*s) * (*s) * (*s);
    double f = r0 * (*c1) + u * (*c2) + mu * (*c3) - dt0;
    (*fp) = r0 * c0 + u * (*c1) + mu * (*c2);
    double fpp = (-40. * alpha + mu) * (*c1) + u * c0;
    double ds = -ln * f /
                ((*fp) + ((*fp) > 0. ? 1. : -1.) *
                             sqrt(fabs((ln - 1.) * (ln - 1.) * (*fp) * (*fp) -
                                       (ln - 1.) * ln * f * fpp)));
    *s = (*s) + ds;
    double fdt = f / dt0;
    if (fdt * fdt < 1.e-13 * 1.e-13) {
      *iflag = 0;
      return;
    }
  }
  *iflag = 2;
}


x86 assembly (clang, -O0):
<reb_drift_kepu_lag>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    %rcx,-0x48(%rbp)
mov    %r8,-0x50(%rbp)
mov    %r9,-0x58(%rbp)
movl   $0x190,-0x5c(%rbp)
movsd  0xe85(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x5c(%rbp),%eax
jg     147e <reb_drift_kepu_lag+0x34e>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rcx
lea    -0x80(%rbp),%rdi
call   1030 <reb_drift_kepu_stumpff@plt>
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x48(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x50(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm1
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x30(%rbp),%xmm0
mov    -0x48(%rbp),%rax
mulsd  (%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mov    -0x50(%rbp),%rax
movsd  (%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x18(%rbp),%xmm1
movsd  -0x80(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm0
mov    -0x40(%rbp),%rax
mulsd  (%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movsd  (%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xd67(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x80(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0xa8(%rbp)
ff
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm1
movsd  0xce1(%rip),%xmm3
movsd  0xce1(%rip),%xmm2
xorps  %xmm0,%xmm0
cmpltsd %xmm1,%xmm0
movaps %xmm0,%xmm1
andpd  %xmm3,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
movsd  0xcad(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  -0x68(%rbp),%xmm1
movsd  0xc9c(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x68(%rbp),%xmm1
movsd  0xc77(%rip),%xmm3
subsd  %xmm3,%xmm1
mulsd  -0x68(%rbp),%xmm1
mulsd  -0x88(%rbp),%xmm1
ff
mulsd  -0x90(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <fabs@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
movsd  -0xb8(%rbp),%xmm1
ff
movsd  -0xb0(%rbp),%xmm2
ff
movsd  -0xa8(%rbp),%xmm0
ff
cvtsi2sd %eax,%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
addsd  -0x98(%rbp),%xmm0
ff
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x88(%rbp),%xmm0
ff
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm1
ff
mulsd  -0xa0(%rbp),%xmm1
ff
movsd  0xbb6(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    146b <reb_drift_kepu_lag+0x33b>
mov    -0x58(%rbp),%rax
movl   $0x0,(%rax)
jmp    1488 <reb_drift_kepu_lag+0x358>
jmp    1470 <reb_drift_kepu_lag+0x340>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1187 <reb_drift_kepu_lag+0x57>
mov    -0x58(%rbp),%rax
movl   $0x2,(%rax)
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reb_drift_kepu_lag>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,0x8(%rsp)
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %rsi,0x40(%rsp)
movsd  %xmm4,0x38(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    %rdi,%rbp
movsd  0xe92(%rip),%xmm0
movsd  %xmm3,0x30(%rsp)
mulsd  %xmm3,%xmm0
movsd  %xmm2,0x28(%rsp)
addsd  %xmm2,%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  (%rdi),%xmm2
mov    $0x191,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mulsd  %xmm2,%xmm2
mulsd  0x30(%rsp),%xmm2
movapd %xmm2,%xmm0
lea    0x60(%rsp),%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
call   1030 <reb_drift_kepu_stumpff@plt>
movsd  (%rbx),%xmm0
mulsd  0x0(%rbp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x0(%rbp),%xmm0
movsd  (%r12),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r12)
movsd  0x0(%rbp),%xmm0
movsd  (%r15),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r15)
movapd %xmm1,%xmm6
movsd  (%rbx),%xmm0
movsd  (%r12),%xmm7
movapd %xmm7,%xmm1
movsd  0x38(%rsp),%xmm3
mulsd  %xmm3,%xmm1
movsd  0x20(%rsp),%xmm5
movapd %xmm5,%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  0x28(%rsp),%xmm4
mulsd  %xmm4,%xmm6
addsd  %xmm2,%xmm6
movsd  0x60(%rsp),%xmm1
mulsd  %xmm3,%xmm0
movapd %xmm5,%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
mulsd  %xmm4,%xmm7
addsd  %xmm2,%xmm7
xor    %r13d,%r13d
ucomisd 0xdc1(%rip),%xmm7
seta   %r13b
subsd  0x10(%rsp),%xmm6
mov    0x40(%rsp),%rax
movsd  %xmm7,(%rax)
movsd  %xmm7,0x50(%rsp)
mulsd  %xmm3,%xmm1
movsd  (%rbx),%xmm2
mulsd  0x18(%rsp),%xmm2
addsd  %xmm1,%xmm2
movapd %xmm6,%xmm1
movsd  %xmm6,0x58(%rsp)
movapd %xmm6,%xmm0
mulsd  0xd60(%rip),%xmm0
movsd  %xmm0,0x48(%rsp)
movapd %xmm7,%xmm0
mulsd  0xd56(%rip),%xmm0
mulsd  0xd56(%rip),%xmm1
mulsd  %xmm2,%xmm1
mulsd  %xmm7,%xmm0
addsd  %xmm1,%xmm0
call   1040 <fabs@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
movsd  0x48(%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xd42(%rip),%rax
mulsd  (%rax,%r13,8),%xmm0
addsd  0x50(%rsp),%xmm0
divsd  %xmm0,%xmm2
addsd  0x0(%rbp),%xmm2
movsd  %xmm2,0x0(%rbp)
movsd  0x58(%rsp),%xmm1
divsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm1
movsd  0xd00(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     133d <reb_drift_kepu_lag+0x20d>
add    $0xffffffff,%r14d
jne    11a0 <reb_drift_kepu_lag+0x70>
mov    0x8(%rsp),%rax
movl   $0x2,(%rax)
jmp    1348 <reb_drift_kepu_lag+0x218>
mov    0x8(%rsp),%rax
movl   $0x0,(%rax)
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @reb_drift_kepu_lag(double* %0, double %1, double %2, double %3, double %4, double %5, double* %6, double* %7, double* %8, double* %9, i32* %10) {
%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 i32*
%23 = alloca i32
%24 = alloca double
%25 = alloca i32
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca double
%31 = alloca double
store double* %0, double** %12
store double %1, double* %13
store double %2, double* %14
store double %3, double* %15
store double %4, double* %16
store double %5, double* %17
store double* %6, double** %18
store double* %7, double** %19
store double* %8, double** %20
store double* %9, double** %21
store i32* %10, i32** %22
store i32 400, i32* %23
store double 5.000000e+00, double* %24
store i32 0, i32* %25
br label %32
32: ; preds = %162, %11
%33 = load i32, i32* %25
%34 = load i32, i32* %23
%35 = icmp sle i32 %33, %34
br i1 %35, label %36, label %165
36: ; preds = %32
%37 = load double*, double** %12
%38 = load double, double* %37
%39 = load double*, double** %12
%40 = load double, double* %39
%41 = fmul double %38, %40
%42 = load double, double* %16
%43 = fmul double %41, %42
store double %43, double* %26
%44 = load double, double* %26
%45 = load double*, double** %19
%46 = load double*, double** %20
%47 = load double*, double** %21
%48 = call i32 @reb_drift_kepu_stumpff(double %44, double* %27, double* %45, double* %46, double* %47)
%49 = load double*, double** %19
%50 = load double, double* %49
%51 = load double*, double** %12
%52 = load double, double* %51
%53 = fmul double %50, %52
%54 = load double*, double** %19
store double %53, double* %54
%55 = load double*, double** %20
%56 = load double, double* %55
%57 = load double*, double** %12
%58 = load double, double* %57
%59 = fmul double %56, %58
%60 = load double*, double** %12
%61 = load double, double* %60
%62 = fmul double %59, %61
%63 = load double*, double** %20
store double %62, double* %63
%64 = load double*, double** %21
%65 = load double, double* %64
%66 = load double*, double** %12
%67 = load double, double* %66
%68 = fmul double %65, %67
%69 = load double*, double** %12
%70 = load double, double* %69
%71 = fmul double %68, %70
%72 = load double*, double** %12
%73 = load double, double* %72
%74 = fmul double %71, %73
%75 = load double*, double** %21
store double %74, double* %75
%76 = load double, double* %14
%77 = load double*, double** %19
%78 = load double, double* %77
%79 = load double, double* %17
%80 = load double*, double** %20
%81 = load double, double* %80
%82 = fmul double %79, %81
%83 = call double @llvm.fmuladd.f64(double %76, double %78, double %82)
%84 = load double, double* %15
%85 = load double*, double** %21
%86 = load double, double* %85
%87 = call double @llvm.fmuladd.f64(double %84, double %86, double %83)
%88 = load double, double* %13
%89 = fsub double %87, %88
store double %89, double* %28
%90 = load double, double* %14
%91 = load double, double* %27
%92 = load double, double* %17
%93 = load double*, double** %19
%94 = load double, double* %93
%95 = fmul double %92, %94
%96 = call double @llvm.fmuladd.f64(double %90, double %91, double %95)
%97 = load double, double* %15
%98 = load double*, double** %20
%99 = load double, double* %98
%100 = call double @llvm.fmuladd.f64(double %97, double %99, double %96)
%101 = load double*, double** %18
store double %100, double* %101
%102 = load double, double* %16
%103 = load double, double* %15
%104 = call double @llvm.fmuladd.f64(double -4.000000e+01, double %102, double %103)
%105 = load double*, double** %19
%106 = load double, double* %105
%107 = load double, double* %17
%108 = load double, double* %27
%109 = fmul double %107, %108
%110 = call double @llvm.fmuladd.f64(double %104, double %106, double %109)
store double %110, double* %29
%111 = load double, double* %24
%112 = fneg double %111
%113 = load double, double* %28
%114 = fmul double %112, %113
%115 = load double*, double** %18
%116 = load double, double* %115
%117 = load double*, double** %18
%118 = load double, double* %117
%119 = fcmp ogt double %118, 0.000000e+00
%120 = zext i1 %119 to i64
%121 = select i1 %119, double 1.000000e+00, double -1.000000e+00
%122 = load double, double* %24
%123 = fsub double %122, 1.000000e+00
%124 = load double, double* %24
%125 = fsub double %124, 1.000000e+00
%126 = fmul double %123, %125
%127 = load double*, double** %18
%128 = load double, double* %127
%129 = fmul double %126, %128
%130 = load double*, double** %18
%131 = load double, double* %130
%132 = load double, double* %24
%133 = fsub double %132, 1.000000e+00
%134 = load double, double* %24
%135 = fmul double %133, %134
%136 = load double, double* %28
%137 = fmul double %135, %136
%138 = load double, double* %29
%139 = fmul double %137, %138
%140 = fneg double %139
%141 = call double @llvm.fmuladd.f64(double %129, double %131, double %140)
%142 = call i32 @fabs(double %141)
%143 = call i32 @sqrt(i32 %142)
%144 = sitofp i32 %143 to double
%145 = call double @llvm.fmuladd.f64(double %121, double %144, double %116)
%146 = fdiv double %114, %145
store double %146, double* %30
%147 = load double*, double** %12
%148 = load double, double* %147
%149 = load double, double* %30
%150 = fadd double %148, %149
%151 = load double*, double** %12
store double %150, double* %151
%152 = load double, double* %28
%153 = load double, double* %13
%154 = fdiv double %152, %153
store double %154, double* %31
%155 = load double, double* %31
%156 = load double, double* %31
%157 = fmul double %155, %156
%158 = fcmp olt double %157, 1.000000e-26
br i1 %158, label %159, label %161
159: ; preds = %36
%160 = load i32*, i32** %22
store i32 0, i32* %160
br label %167
161: ; preds = %36
br label %162
162: ; preds = %161
%163 = load i32, i32* %25
%164 = add nsw i32 %163, 1
store i32 %164, i32* %25
br label %32
165: ; preds = %32
%166 = load i32*, i32** %22
store i32 2, i32* %166
br label %167
167: ; preds = %165, %159
ret void
}

LLVM IR (-O2):
define void @reb_drift_kepu_lag(double* nocapture %0, double %1, double %2, double %3, double %4, double %5, double* nocapture writeonly %6, double* %7, double* %8, double* %9, i32* nocapture writeonly %10) {
%12 = alloca double
%13 = bitcast double* %12 to i8*
%14 = call double @llvm.fmuladd.f64(double %4, double -4.000000e+01, double %3)
%15 = load double, double* %0
br label %16
16: ; preds = %11, %65
%17 = phi double [ %15, %11 ], [ %60, %65 ]
%18 = phi i32 [ 0, %11 ], [ %66, %65 ]
%19 = fmul double %17, %17
%20 = fmul double %19, %4
%21 = call i32 @reb_drift_kepu_stumpff(double %20, double* %12, double* %7, double* %8, double* %9)
%22 = load double, double* %7
%23 = load double, double* %0
%24 = fmul double %22, %23
store double %24, double* %7
%25 = load double, double* %8
%26 = load double, double* %0
%27 = fmul double %25, %26
%28 = fmul double %26, %27
store double %28, double* %8
%29 = load double, double* %9
%30 = load double, double* %0
%31 = fmul double %29, %30
%32 = fmul double %30, %31
%33 = fmul double %30, %32
store double %33, double* %9
%34 = load double, double* %7
%35 = load double, double* %8
%36 = fmul double %35, %5
%37 = call double @llvm.fmuladd.f64(double %2, double %34, double %36)
%38 = call double @llvm.fmuladd.f64(double %3, double %33, double %37)
%39 = fsub double %38, %1
%40 = load double, double* %12
%41 = fmul double %34, %5
%42 = call double @llvm.fmuladd.f64(double %2, double %40, double %41)
%43 = call double @llvm.fmuladd.f64(double %3, double %35, double %42)
store double %43, double* %6
%44 = load double, double* %7
%45 = fmul double %40, %5
%46 = call double @llvm.fmuladd.f64(double %14, double %44, double %45)
%47 = fmul double %39, 5.000000e+00
%48 = fcmp ogt double %43, 0.000000e+00
%49 = select i1 %48, double 1.000000e+00, double -1.000000e+00
%50 = fmul double %43, 1.600000e+01
%51 = fmul double %39, -2.000000e+01
%52 = fmul double %46, %51
%53 = call double @llvm.fmuladd.f64(double %50, double %43, double %52)
%54 = call i32 @fabs(double %53)
%55 = call i32 @sqrt(i32 %54)
%56 = sitofp i32 %55 to double
%57 = call double @llvm.fmuladd.f64(double %49, double %56, double %43)
%58 = fdiv double %47, %57
%59 = load double, double* %0
%60 = fsub double %59, %58
store double %60, double* %0
%61 = fdiv double %39, %1
%62 = fmul double %61, %61
%63 = fcmp olt double %62, 1.000000e-26
br i1 %63, label %64, label %65
64: ; preds = %16
store i32 0, i32* %10
br label %69
65: ; preds = %16
%66 = add nuw nsw i32 %18, 1
%67 = icmp eq i32 %66, 401
br i1 %67, label %68, label %16
68: ; preds = %65
store i32 2, i32* %10
br label %69
69: ; preds = %64, %68
ret void
}