#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 */
struct cvals {
  int dummy;
};

/* Variables and functions */
double cdrift_kepu_fchk(double const, double const, double const, double const,
                        double const, double const);
double cdrift_kepu_guess(double const, double const, double const, double const,
                         double const, double);
int cdrift_kepu_lag(double *, double const, double const, double const,
                    double const, double const, double *, struct cvals *);
int cdrift_kepu_new(double *, double const, double const, double const,
                    double const, double const, double *, struct cvals *);
scalar_t__ fabs(double const);
int cdrift_kepu(const double dt, const double r0, const double mu,
                const double alpha, const double u, double *fp,
                struct cvals *cvals) {
  int iflg = 0;
  double s = 0.0;
  s = cdrift_kepu_guess(dt, r0, mu, alpha, u, s);
  const double st = s;
  iflg = cdrift_kepu_new(&s, dt, r0, mu, alpha, u, fp, cvals);
  if (iflg) {
    const double fo = cdrift_kepu_fchk(dt, r0, mu, alpha, u, st);
    const double fn = cdrift_kepu_fchk(dt, r0, mu, alpha, u, s);
    if (fabs(fo) < fabs(fn)) {
      s = st;
    }
    iflg = cdrift_kepu_lag(&s, dt, r0, mu, alpha, u, fp, cvals);
  }
  return iflg;
}


x86 assembly (clang, -O0):
<cdrift_kepu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%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)
movl   $0x0,-0x3c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm4
movsd  -0x48(%rbp),%xmm5
call   1030 <cdrift_kepu_guess@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm4
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
lea    -0x48(%rbp),%rdi
call   1070 <cdrift_kepu_new@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     12a0 <cdrift_kepu+0x150>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm4
movsd  -0x50(%rbp),%xmm5
call   1050 <cdrift_kepu_fchk@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm4
movsd  -0x48(%rbp),%xmm5
call   1050 <cdrift_kepu_fchk@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1040 <fabs@plt>
mov    %rax,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1040 <fabs@plt>
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
cmp    %rcx,%rax
jge    1273 <cdrift_kepu+0x123>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm4
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
lea    -0x48(%rbp),%rdi
call   1060 <cdrift_kepu_lag@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdrift_kepu>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movsd  %xmm4,0x28(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
xorps  %xmm5,%xmm5
call   1030 <cdrift_kepu_guess@plt>
movsd  %xmm0,0x38(%rsp)
movsd  %xmm0,0x30(%rsp)
lea    0x30(%rsp),%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
movsd  0x28(%rsp),%xmm4
mov    %r15,%rsi
mov    %r14,%rdx
call   1070 <cdrift_kepu_new@plt>
test   %eax,%eax
je     127f <cdrift_kepu+0x12f>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
movsd  0x28(%rsp),%xmm4
movsd  0x38(%rsp),%xmm5
call   1050 <cdrift_kepu_fchk@plt>
movsd  %xmm0,0x48(%rsp)
movsd  0x30(%rsp),%xmm5
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
movsd  0x28(%rsp),%xmm4
call   1050 <cdrift_kepu_fchk@plt>
movsd  %xmm0,0x40(%rsp)
movsd  0x48(%rsp),%xmm0
call   1040 <fabs@plt>
mov    %rax,%rbx
movsd  0x40(%rsp),%xmm0
call   1040 <fabs@plt>
cmp    %rax,%rbx
jge    124f <cdrift_kepu+0xff>
movsd  0x38(%rsp),%xmm0
movsd  %xmm0,0x30(%rsp)
lea    0x30(%rsp),%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
movsd  0x28(%rsp),%xmm4
mov    %r15,%rsi
mov    %r14,%rdx
call   1060 <cdrift_kepu_lag@plt>
jmp    1281 <cdrift_kepu+0x131>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.cvals = type { i32 }
define i32 @cdrift_kepu(double %0, double %1, double %2, double %3, double %4, double* %5, %struct.cvals* %6) {
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double*
%14 = alloca %struct.cvals*
%15 = alloca i32
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = 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 %struct.cvals* %6, %struct.cvals** %14
store i32 0, i32* %15
store double 0.000000e+00, double* %16
%20 = load double, double* %8
%21 = load double, double* %9
%22 = load double, double* %10
%23 = load double, double* %11
%24 = load double, double* %12
%25 = load double, double* %16
%26 = call double @cdrift_kepu_guess(double %20, double %21, double %22, double %23, double %24, double %25)
store double %26, double* %16
%27 = load double, double* %16
store double %27, double* %17
%28 = load double, double* %8
%29 = load double, double* %9
%30 = load double, double* %10
%31 = load double, double* %11
%32 = load double, double* %12
%33 = load double*, double** %13
%34 = load %struct.cvals*, %struct.cvals** %14
%35 = call i32 @cdrift_kepu_new(double* %16, double %28, double %29, double %30, double %31, double %32, double* %33, %struct.cvals* %34)
store i32 %35, i32* %15
%36 = load i32, i32* %15
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %69
38: ; preds = %7
%39 = load double, double* %8
%40 = load double, double* %9
%41 = load double, double* %10
%42 = load double, double* %11
%43 = load double, double* %12
%44 = load double, double* %17
%45 = call double @cdrift_kepu_fchk(double %39, double %40, double %41, double %42, double %43, double %44)
store double %45, double* %18
%46 = load double, double* %8
%47 = load double, double* %9
%48 = load double, double* %10
%49 = load double, double* %11
%50 = load double, double* %12
%51 = load double, double* %16
%52 = call double @cdrift_kepu_fchk(double %46, double %47, double %48, double %49, double %50, double %51)
store double %52, double* %19
%53 = load double, double* %18
%54 = call i64 @fabs(double %53)
%55 = load double, double* %19
%56 = call i64 @fabs(double %55)
%57 = icmp slt i64 %54, %56
br i1 %57, label %58, label %60
58: ; preds = %38
%59 = load double, double* %17
store double %59, double* %16
br label %60
60: ; preds = %58, %38
%61 = load double, double* %8
%62 = load double, double* %9
%63 = load double, double* %10
%64 = load double, double* %11
%65 = load double, double* %12
%66 = load double*, double** %13
%67 = load %struct.cvals*, %struct.cvals** %14
%68 = call i32 @cdrift_kepu_lag(double* %16, double %61, double %62, double %63, double %64, double %65, double* %66, %struct.cvals* %67)
store i32 %68, i32* %15
br label %69
69: ; preds = %60, %7
%70 = load i32, i32* %15
ret i32 %70
}

LLVM IR (-O2):
%struct.cvals = type { i32 }
define i32 @cdrift_kepu(double %0, double %1, double %2, double %3, double %4, double* %5, %struct.cvals* %6) {
%8 = alloca double
%9 = bitcast double* %8 to i8*
%10 = tail call double @cdrift_kepu_guess(double %0, double %1, double %2, double %3, double %4, double 0.000000e+00)
store double %10, double* %8
%11 = call i32 @cdrift_kepu_new(double* %8, double %0, double %1, double %2, double %3, double %4, double* %5, %struct.cvals* %6)
%12 = icmp eq i32 %11, 0
br i1 %12, label %23, label %13
13: ; preds = %7
%14 = call double @cdrift_kepu_fchk(double %0, double %1, double %2, double %3, double %4, double %10)
%15 = load double, double* %8
%16 = call double @cdrift_kepu_fchk(double %0, double %1, double %2, double %3, double %4, double %15)
%17 = call i64 @fabs(double %14)
%18 = call i64 @fabs(double %16)
%19 = icmp slt i64 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %13
store double %10, double* %8
br label %21
21: ; preds = %20, %13
%22 = call i32 @cdrift_kepu_lag(double* %8, double %0, double %1, double %2, double %3, double %4, double* %5, %struct.cvals* %6)
br label %23
23: ; preds = %21, %7
%24 = phi i32 [ %22, %21 ], [ 0, %7 ]
ret i32 %24
}