#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*/ RK4_step(double, double, double *, double *);
int /*<<< orphan*/ leapfrog_step(double, double, double *, double *);
int /*<<< orphan*/ printf(char *, double, double, double, double, double);
int main() {
  double x_RK4, x_LF;
  double v_RK4, v_LF;
  double t;
  double T = 1E5;
  double delta_t = 1E-1;
  int n_step = (int)(T / delta_t);
  double x_step = 0.0;
  double v_step = 0.0;
  int i;
  t = 0.0;
  x_RK4 = 1.0;
  v_RK4 = 0.0;
  x_LF = 1.0;
  v_LF = 0.0;
  for (i = 0; i < n_step; i++) {
    printf("%f %.15e %.15e %.15e %.15e \n", t, x_RK4, v_RK4, x_LF, v_LF);
    RK4_step(delta_t, t, &x_RK4, &v_RK4);
    leapfrog_step(delta_t, t, &x_LF, &v_LF);
    t += delta_t;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xeb4(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x44(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe76(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe61(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    122f <main+0xff>
movsd  -0x30(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm4
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x40(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
lea    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <RK4_step@plt>
movsd  -0x40(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
lea    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <leapfrog_step@plt>
movsd  -0x40(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11b3 <main+0x83>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movabs $0x3ff0000000000000,%rax
mov    %rax,0x20(%rsp)
movq   $0x0,0x10(%rsp)
mov    %rax,0x18(%rsp)
movq   $0x0,0x8(%rsp)
movsd  0xe94(%rip),%xmm3
xorps  %xmm4,%xmm4
mov    $0xf423f,%ebp
lea    0xe95(%rip),%r14
lea    0x20(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0x18(%rsp),%r13
lea    0x8(%rsp),%rbx
xorps  %xmm2,%xmm2
movaps %xmm3,%xmm1
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
xchg   %ax,%ax
mov    %r14,%rdi
movsd  (%rsp),%xmm0
call   1030 <printf@plt>
movsd  0xe53(%rip),%xmm0
movsd  (%rsp),%xmm1
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <RK4_step@plt>
movsd  0xe3b(%rip),%xmm0
movsd  (%rsp),%xmm1
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <leapfrog_step@plt>
sub    $0x1,%ebp
jb     120e <main+0xde>
movsd  (%rsp),%xmm0
addsd  0xe19(%rip),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x20(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
movsd  0x8(%rsp),%xmm4
jmp    11a0 <main+0x70>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"%f %.15e %.15e %.15e %.15e \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca i32
store i32 0, i32* %1
store double 1.000000e+05, double* %7
store double 1.000000e-01, double* %8
%13 = load double, double* %7
%14 = load double, double* %8
%15 = fdiv double %13, %14
%16 = fptosi double %15 to i32
store i32 %16, i32* %9
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %6
store double 1.000000e+00, double* %2
store double 0.000000e+00, double* %4
store double 1.000000e+00, double* %3
store double 0.000000e+00, double* %5
store i32 0, i32* %12
br label %17
17: ; preds = %37, %0
%18 = load i32, i32* %12
%19 = load i32, i32* %9
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %40
21: ; preds = %17
%22 = load double, double* %6
%23 = load double, double* %2
%24 = load double, double* %4
%25 = load double, double* %3
%26 = load double, double* %5
%27 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %22, double %23, double %24, double %25, double %26)
%28 = load double, double* %8
%29 = load double, double* %6
%30 = call i32 @RK4_step(double %28, double %29, double* %2, double* %4)
%31 = load double, double* %8
%32 = load double, double* %6
%33 = call i32 @leapfrog_step(double %31, double %32, double* %3, double* %5)
%34 = load double, double* %8
%35 = load double, double* %6
%36 = fadd double %35, %34
store double %36, double* %6
br label %37
37: ; preds = %21
%38 = load i32, i32* %12
%39 = add nsw i32 %38, 1
store i32 %39, i32* %12
br label %17
40: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"%f %.15e %.15e %.15e %.15e \0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %1 to i8*
%6 = bitcast double* %2 to i8*
%7 = bitcast double* %3 to i8*
%8 = bitcast double* %4 to i8*
store double 1.000000e+00, double* %1
store double 0.000000e+00, double* %3
store double 1.000000e+00, double* %2
store double 0.000000e+00, double* %4
br label %9
9: ; preds = %21, %0
%10 = phi double [ 0.000000e+00, %0 ], [ %26, %21 ]
%11 = phi double [ 1.000000e+00, %0 ], [ %25, %21 ]
%12 = phi double [ 0.000000e+00, %0 ], [ %24, %21 ]
%13 = phi double [ 1.000000e+00, %0 ], [ %23, %21 ]
%14 = phi i32 [ 0, %0 ], [ %19, %21 ]
%15 = phi double [ 0.000000e+00, %0 ], [ %22, %21 ]
%16 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %15, double %13, double %12, double %11, double %10)
%17 = call i32 @RK4_step(double 1.000000e-01, double %15, double* %1, double* %3)
%18 = call i32 @leapfrog_step(double 1.000000e-01, double %15, double* %2, double* %4)
%19 = add nuw nsw i32 %14, 1
%20 = icmp eq i32 %19, 1000000
br i1 %20, label %27, label %21
21: ; preds = %9
%22 = fadd double %15, 1.000000e-01
%23 = load double, double* %1
%24 = load double, double* %3
%25 = load double, double* %2
%26 = load double, double* %4
br label %9
27: ; preds = %9
ret i32 0
}