#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*/ advance_vel(double, double *, double);
int /*<<< orphan*/ leapfrog(double *, double *, double *, double);
int /*<<< orphan*/ output(double, double, double, double);
int /*<<< orphan*/ printf(char *, double, double, double);
double sin(double);
void lpf_int(double t, double tmax, double step, double x, double v) {
  int i;
  output(x, v, t, step);
  advance_vel(x, &v, 0.5 * step);
  while (t < tmax) {
    leapfrog(&x, &v, &t, step);
    if (t > 0)
      advance_vel(x, &v, -0.5 * step);
    printf("%f\t%f\t%f\n", t, sin(t), x);
  }
}


x86 assembly (clang, -O0):
<lpf_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
call   1030 <output@plt>
movsd  -0x20(%rbp),%xmm0
movsd  0xe69(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
lea    -0x28(%rbp),%rdi
call   1060 <advance_vel@plt>
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    122e <lpf_int+0xde>
movsd  -0x18(%rbp),%xmm0
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1050 <leapfrog@plt>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11fc <lpf_int+0xac>
movsd  -0x20(%rbp),%xmm0
movsd  0xe1a(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
lea    -0x28(%rbp),%rdi
call   1060 <advance_vel@plt>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1070 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
lea    0xdec(%rip),%rdi
call   1040 <printf@plt>
jmp    11a5 <lpf_int+0x55>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lpf_int>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
movaps %xmm2,%xmm5
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x28(%rsp)
movaps %xmm0,%xmm2
movsd  %xmm0,0x18(%rsp)
movsd  %xmm0,(%rsp)
movaps %xmm3,%xmm0
movsd  %xmm3,0x8(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm4,0x30(%rsp)
movaps %xmm4,%xmm1
movaps %xmm5,%xmm3
call   1030 <output@plt>
movsd  0xe60(%rip),%xmm1
mulsd  0x10(%rsp),%xmm1
lea    0x30(%rsp),%rdi
movsd  0x8(%rsp),%xmm0
call   1060 <advance_vel@plt>
movsd  0x28(%rsp),%xmm0
ucomisd 0x18(%rsp),%xmm0
jbe    126e <lpf_int+0x11e>
movsd  0xe38(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x20(%rsp),%r14
lea    0x30(%rsp),%rbx
mov    %rsp,%r15
lea    0xe28(%rip),%r12
jmp    1230 <lpf_int+0xe0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,0x18(%rsp)
call   1070 <sin@plt>
movapd %xmm0,%xmm1
movsd  0x20(%rsp),%xmm2
mov    %r12,%rdi
movsd  0x18(%rsp),%xmm0
call   1040 <printf@plt>
movsd  0x28(%rsp),%xmm0
ucomisd (%rsp),%xmm0
jbe    126e <lpf_int+0x11e>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
movsd  0x10(%rsp),%xmm0
call   1050 <leapfrog@plt>
movsd  (%rsp),%xmm0
ucomisd 0xdbf(%rip),%xmm0
jbe    1200 <lpf_int+0xb0>
movsd  0x20(%rsp),%xmm0
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm1
call   1060 <advance_vel@plt>
movsd  (%rsp),%xmm0
jmp    1200 <lpf_int+0xb0>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%f\09%f\09%f\0A\00"
define void @lpf_int(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%12 = load double, double* %9
%13 = load double, double* %10
%14 = load double, double* %6
%15 = load double, double* %8
%16 = call i32 @output(double %12, double %13, double %14, double %15)
%17 = load double, double* %9
%18 = load double, double* %8
%19 = fmul double 5.000000e-01, %18
%20 = call i32 @advance_vel(double %17, double* %10, double %19)
br label %21
21: ; preds = %35, %5
%22 = load double, double* %6
%23 = load double, double* %7
%24 = fcmp olt double %22, %23
br i1 %24, label %25, label %41
25: ; preds = %21
%26 = load double, double* %8
%27 = call i32 @leapfrog(double* %9, double* %10, double* %6, double %26)
%28 = load double, double* %6
%29 = fcmp ogt double %28, 0.000000e+00
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = load double, double* %9
%32 = load double, double* %8
%33 = fmul double -5.000000e-01, %32
%34 = call i32 @advance_vel(double %31, double* %10, double %33)
br label %35
35: ; preds = %30, %25
%36 = load double, double* %6
%37 = load double, double* %6
%38 = call double @sin(double %37)
%39 = load double, double* %9
%40 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %36, double %38, double %39)
br label %21
41: ; preds = %21
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%f\09%f\09%f\0A\00"
define void @lpf_int(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %6
store double %3, double* %7
store double %4, double* %8
%9 = tail call i32 @output(double %3, double %4, double %0, double %2)
%10 = fmul double %2, 5.000000e-01
%11 = call i32 @advance_vel(double %3, double* %8, double %10)
%12 = fcmp olt double %0, %1
br i1 %12, label %13, label %30
13: ; preds = %5
%14 = fmul double %2, -5.000000e-01
br label %15
15: ; preds = %13, %23
%16 = call i32 @leapfrog(double* %7, double* %8, double* %6, double %2)
%17 = load double, double* %6
%18 = fcmp ogt double %17, 0.000000e+00
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load double, double* %7
%21 = call i32 @advance_vel(double %20, double* %8, double %14)
%22 = load double, double* %6
br label %23
23: ; preds = %19, %15
%24 = phi double [ %22, %19 ], [ %17, %15 ]
%25 = call double @sin(double %24)
%26 = load double, double* %7
%27 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %24, double %25, double %26)
%28 = load double, double* %6
%29 = fcmp olt double %28, %1
br i1 %29, label %15, label %30
30: ; preds = %23, %5
ret void
}