#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*/ leapfrog_step(double, double, double, double);
void integrate_buff(int n, int i0, double dx, double y0, double dy0, double E,
                    double *V_buff, double *y_buff, double *dy_buff) {
  double y = y0;
  double dy = dy0;
  y_buff[i0] = y;
  dy_buff[i0] = dy;
  for (int i = i0 + 1; i < n; i++) {
    double V = (V_buff[i - 1] - E);
    leapfrog_step(dx, V, y, dy);
    y_buff[i] = y;
    dy_buff[i] = dy;
  }
  dx = -dx;
  y = y0;
  dy = dy0;
  for (int i = i0 - 1; i >= 0; i--) {
    double V = (V_buff[i + 1] - E);
    leapfrog_step(dx, V, y, dy);
    y_buff[i] = y;
    dy_buff[i] = dy;
  }
}


x86 assembly (clang, -O0):
<integrate_buff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f2 <integrate_buff+0xe2>
mov    -0x30(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm3
call   1030 <leapfrog_step@plt>
movsd  -0x48(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    117f <integrate_buff+0x6f>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jl     12a1 <integrate_buff+0x191>
mov    -0x30(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm3
call   1030 <leapfrog_step@plt>
movsd  -0x48(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x64(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x64(%rbp)
jmp    1230 <integrate_buff+0x120>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<integrate_buff>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdx,%r13
movaps %xmm2,%xmm4
movsd  %xmm1,(%rsp)
movslq %esi,%rax
mov    %rcx,0x10(%rsp)
movsd  %xmm1,(%rcx,%rax,8)
mov    %r8,0x18(%rsp)
movsd  %xmm2,(%r8,%rax,8)
add    $0x1,%eax
mov    %esi,0xc(%rsp)
mov    %esi,%ebp
cmp    %edi,%eax
movsd  %xmm3,0x28(%rsp)
movsd  %xmm2,0x20(%rsp)
jge    11e1 <integrate_buff+0xd1>
cltq
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%rbx
mov    0x18(%rsp),%rcx
lea    (%rcx,%rax,8),%r12
mov    $0x1,%r14d
sub    %edi,%r14d
add    %rbp,%r14
xor    %r15d,%r15d
movaps %xmm0,0x30(%rsp)
cs nopw 0x0(%rax,%rax,1)
lea    (%r15,%rbp,1),%eax
cltq
movsd  0x0(%r13,%rax,8),%xmm1
subsd  %xmm3,%xmm1
movaps 0x30(%rsp),%xmm0
movsd  (%rsp),%xmm2
movaps %xmm4,%xmm3
call   1030 <leapfrog_step@plt>
movsd  0x20(%rsp),%xmm4
movsd  0x28(%rsp),%xmm3
movsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx,%r15,8)
movaps 0x30(%rsp),%xmm0
movsd  %xmm4,(%r12,%r15,8)
add    $0x1,%r15
mov    %r14d,%eax
add    %r15d,%eax
jne    1190 <integrate_buff+0x80>
cmpl   $0x0,0xc(%rsp)
mov    0x18(%rsp),%r14
mov    0x10(%rsp),%r15
jle    1257 <integrate_buff+0x147>
xorps  0xe07(%rip),%xmm0
add    $0x1,%rbp
movaps %xmm0,0x30(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x2(%rbp),%ebx
movsd  -0x8(%r13,%rbp,8),%xmm1
subsd  %xmm3,%xmm1
movaps 0x30(%rsp),%xmm0
movsd  (%rsp),%xmm2
movaps %xmm4,%xmm3
call   1030 <leapfrog_step@plt>
movsd  0x20(%rsp),%xmm4
movsd  0x28(%rsp),%xmm3
movsd  (%rsp),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
movsd  %xmm4,(%r14,%rbx,8)
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%rbp
ja     1210 <integrate_buff+0x100>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @integrate_buff(i32 %0, i32 %1, double %2, double %3, double %4, double %5, double* %6, double* %7, double* %8) {
%10 = alloca i32
%11 = alloca i32
%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 i32
%22 = alloca double
%23 = alloca i32
%24 = alloca double
store i32 %0, i32* %10
store i32 %1, i32* %11
store double %2, double* %12
store double %3, double* %13
store double %4, double* %14
store double %5, double* %15
store double* %6, double** %16
store double* %7, double** %17
store double* %8, double** %18
%25 = load double, double* %13
store double %25, double* %19
%26 = load double, double* %14
store double %26, double* %20
%27 = load double, double* %19
%28 = load double*, double** %17
%29 = load i32, i32* %11
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
store double %27, double* %31
%32 = load double, double* %20
%33 = load double*, double** %18
%34 = load i32, i32* %11
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
store double %32, double* %36
%37 = load i32, i32* %11
%38 = add nsw i32 %37, 1
store i32 %38, i32* %21
br label %39
39: ; preds = %67, %9
%40 = load i32, i32* %21
%41 = load i32, i32* %10
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %70
43: ; preds = %39
%44 = load double*, double** %16
%45 = load i32, i32* %21
%46 = sub nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %44, i64 %47
%49 = load double, double* %48
%50 = load double, double* %15
%51 = fsub double %49, %50
store double %51, double* %22
%52 = load double, double* %12
%53 = load double, double* %22
%54 = load double, double* %19
%55 = load double, double* %20
%56 = call i32 @leapfrog_step(double %52, double %53, double %54, double %55)
%57 = load double, double* %19
%58 = load double*, double** %17
%59 = load i32, i32* %21
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
store double %57, double* %61
%62 = load double, double* %20
%63 = load double*, double** %18
%64 = load i32, i32* %21
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
store double %62, double* %66
br label %67
67: ; preds = %43
%68 = load i32, i32* %21
%69 = add nsw i32 %68, 1
store i32 %69, i32* %21
br label %39
70: ; preds = %39
%71 = load double, double* %12
%72 = fneg double %71
store double %72, double* %12
%73 = load double, double* %13
store double %73, double* %19
%74 = load double, double* %14
store double %74, double* %20
%75 = load i32, i32* %11
%76 = sub nsw i32 %75, 1
store i32 %76, i32* %23
br label %77
77: ; preds = %104, %70
%78 = load i32, i32* %23
%79 = icmp sge i32 %78, 0
br i1 %79, label %80, label %107
80: ; preds = %77
%81 = load double*, double** %16
%82 = load i32, i32* %23
%83 = add nsw i32 %82, 1
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds double, double* %81, i64 %84
%86 = load double, double* %85
%87 = load double, double* %15
%88 = fsub double %86, %87
store double %88, double* %24
%89 = load double, double* %12
%90 = load double, double* %24
%91 = load double, double* %19
%92 = load double, double* %20
%93 = call i32 @leapfrog_step(double %89, double %90, double %91, double %92)
%94 = load double, double* %19
%95 = load double*, double** %17
%96 = load i32, i32* %23
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds double, double* %95, i64 %97
store double %94, double* %98
%99 = load double, double* %20
%100 = load double*, double** %18
%101 = load i32, i32* %23
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds double, double* %100, i64 %102
store double %99, double* %103
br label %104
104: ; preds = %80
%105 = load i32, i32* %23
%106 = add nsw i32 %105, -1
store i32 %106, i32* %23
br label %77
107: ; preds = %77
ret void
}

LLVM IR (-O2):
define void @integrate_buff(i32 %0, i32 %1, double %2, double %3, double %4, double %5, double* nocapture %6, double* nocapture writeonly %7, double* nocapture writeonly %8) {
%10 = sext i32 %1 to i64
%11 = getelementptr inbounds double, double* %7, i64 %10
store double %3, double* %11
%12 = getelementptr inbounds double, double* %8, i64 %10
store double %4, double* %12
%13 = add i32 %1, 1
%14 = icmp slt i32 %13, %0
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = sext i32 %13 to i64
br label %22
17: ; preds = %22, %9
%18 = fneg double %2
%19 = icmp sgt i32 %1, 0
br i1 %19, label %20, label %36
20: ; preds = %17
%21 = zext i32 %1 to i64
br label %37
22: ; preds = %15, %22
%23 = phi i64 [ %16, %15 ], [ %32, %22 ]
%24 = phi i32 [ %1, %15 ], [ %33, %22 ]
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %6, i64 %25
%27 = load double, double* %26
%28 = fsub double %27, %5
%29 = tail call i32 @leapfrog_step(double %2, double %28, double %3, double %4)
%30 = getelementptr inbounds double, double* %7, i64 %23
store double %3, double* %30
%31 = getelementptr inbounds double, double* %8, i64 %23
store double %4, double* %31
%32 = add nsw i64 %23, 1
%33 = trunc i64 %23 to i32
%34 = trunc i64 %32 to i32
%35 = icmp eq i32 %34, %0
br i1 %35, label %17, label %22
36: ; preds = %37, %17
ret void
37: ; preds = %20, %37
%38 = phi i64 [ %21, %20 ], [ %39, %37 ]
%39 = add nsw i64 %38, -1
%40 = getelementptr inbounds double, double* %6, i64 %38
%41 = load double, double* %40
%42 = fsub double %41, %5
%43 = tail call i32 @leapfrog_step(double %18, double %42, double %3, double %4)
%44 = and i64 %39, 4294967295
%45 = getelementptr inbounds double, double* %7, i64 %44
store double %3, double* %45
%46 = getelementptr inbounds double, double* %8, i64 %44
store double %4, double* %46
%47 = icmp ugt i64 %38, 1
br i1 %47, label %37, label %36
}