#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 nkep_drift3(double, double *, double *, double);
void drift_shep_nonrecurs(double mu, double *r0, double *v0, double dt) {
  double at = 0.0;
  double step = dt;
  double dest = dt;
  int stat;
  while (at < dest) {
    stat = nkep_drift3(mu, r0, v0, step);
    if (stat == -1) {
      step /= 2;
    } else {
      at += step;
      step = dest - at;
    }
  }
}


x86 assembly (clang, -O0):
<drift_shep_nonrecurs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11bc <drift_shep_nonrecurs+0xac>
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsd  -0x30(%rbp),%xmm1
call   1030 <nkep_drift3@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    1199 <drift_shep_nonrecurs+0x89>
movsd  -0x30(%rbp),%xmm0
movsd  0xe75(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11b7 <drift_shep_nonrecurs+0xa7>
movsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1146 <drift_shep_nonrecurs+0x36>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drift_shep_nonrecurs>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movsd  %xmm0,0x10(%rsp)
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jbe    11aa <drift_shep_nonrecurs+0x9a>
mov    %rsi,%r14
mov    %rdi,%rbx
movapd %xmm1,%xmm3
movapd %xmm1,%xmm2
movsd  %xmm1,(%rsp)
jmp    1163 <drift_shep_nonrecurs+0x53>
movsd  0x8(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
movsd  (%rsp),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
ucomisd %xmm0,%xmm1
movapd %xmm2,%xmm3
jbe    11aa <drift_shep_nonrecurs+0x9a>
movsd  %xmm2,0x20(%rsp)
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
movsd  %xmm3,0x18(%rsp)
movapd %xmm3,%xmm1
call   1030 <nkep_drift3@plt>
movsd  0x20(%rsp),%xmm2
mulsd  0xe68(%rip),%xmm2
cmp    $0xffffffff,%eax
jne    1140 <drift_shep_nonrecurs+0x30>
movsd  (%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
jmp    1159 <drift_shep_nonrecurs+0x49>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @drift_shep_nonrecurs(double %0, double* %1, double* %2, double %3) {
%5 = alloca double
%6 = alloca double*
%7 = alloca double*
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
store double %0, double* %5
store double* %1, double** %6
store double* %2, double** %7
store double %3, double* %8
store double 0.000000e+00, double* %9
%13 = load double, double* %8
store double %13, double* %10
%14 = load double, double* %8
store double %14, double* %11
br label %15
15: ; preds = %37, %4
%16 = load double, double* %9
%17 = load double, double* %11
%18 = fcmp olt double %16, %17
br i1 %18, label %19, label %38
19: ; preds = %15
%20 = load double, double* %5
%21 = load double*, double** %6
%22 = load double*, double** %7
%23 = load double, double* %10
%24 = call i32 @nkep_drift3(double %20, double* %21, double* %22, double %23)
store i32 %24, i32* %12
%25 = load i32, i32* %12
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %19
%28 = load double, double* %10
%29 = fdiv double %28, 2.000000e+00
store double %29, double* %10
br label %37
30: ; preds = %19
%31 = load double, double* %10
%32 = load double, double* %9
%33 = fadd double %32, %31
store double %33, double* %9
%34 = load double, double* %11
%35 = load double, double* %9
%36 = fsub double %34, %35
store double %36, double* %10
br label %37
37: ; preds = %30, %27
br label %15
38: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @drift_shep_nonrecurs(double %0, double* %1, double* %2, double %3) {
%5 = fcmp ogt double %3, 0.000000e+00
br i1 %5, label %6, label %17
6: ; preds = %4, %6
%7 = phi double [ %15, %6 ], [ 0.000000e+00, %4 ]
%8 = phi double [ %14, %6 ], [ %3, %4 ]
%9 = tail call i32 @nkep_drift3(double %0, double* %1, double* %2, double %8)
%10 = icmp eq i32 %9, -1
%11 = fmul double %8, 5.000000e-01
%12 = fadd double %8, %7
%13 = fsub double %3, %12
%14 = select i1 %10, double %11, double %13
%15 = select i1 %10, double %7, double %12
%16 = fcmp olt double %15, %3
br i1 %16, label %6, label %17
17: ; preds = %6, %4
ret void
}