#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ advance_vel(double, double *, double);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, double,
                           double);
int /*<<< orphan*/ leapfrog(double *, double *, double *, double);
int /*<<< orphan*/ printf(char *, double, double, double);
double sin(double);
void lpf_int(char *fout, double t, double tmax, double step, double x,
             double v) {
  int i;
  FILE *file;
  file = fopen(fout, "w");
  if (t > 0)
    advance_vel(x, &v, -0.5 * step);
  printf("%f\t%e\t%e\n", t, sin(t), x);
  fprintf(file, "%f\t%e\t%e\n", t, sin(t), x);
  advance_vel(x, &v, 0.5 * step);
  while (t < tmax) {
    leapfrog(&x, &v, &t, step);
    printf("%f\t%e\t%e\n", t, sin(t), x);
    fprintf(file, "%f\t%e\t%e\n", t, sin(t), x);
  }
}


x86 assembly (clang, -O0):
<lpf_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11c6 <lpf_int+0x66>
movsd  -0x28(%rbp),%xmm0
movsd  0xe48(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
lea    -0x30(%rbp),%rdi
call   1050 <advance_vel@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <sin@plt>
mov    -0x50(%rbp),%rdi
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
lea    0xdeb(%rip),%rsi
call   1060 <fprintf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  0xdcf(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
lea    -0x30(%rbp),%rdi
call   1050 <advance_vel@plt>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12dc <lpf_int+0x17c>
movsd  -0x20(%rbp),%xmm0
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1040 <leapfrog@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
lea    0xd79(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <sin@plt>
mov    -0x68(%rbp),%rdi
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
lea    0xd40(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1247 <lpf_int+0xe7>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lpf_int>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
movsd  %xmm2,0x28(%rsp)
movsd  %xmm1,0x38(%rsp)
movsd  %xmm0,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm3,0x18(%rsp)
movsd  %xmm4,0x30(%rsp)
lea    0xe72(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r13
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    11d4 <lpf_int+0x74>
movsd  0xe42(%rip),%xmm1
mulsd  0x28(%rsp),%xmm1
lea    0x30(%rsp),%rdi
movsd  0x20(%rsp),%xmm0
call   1050 <advance_vel@plt>
movsd  0x8(%rsp),%xmm0
call   1070 <sin@plt>
movaps %xmm0,%xmm1
movsd  0x18(%rsp),%xmm2
lea    0xe23(%rip),%rbx
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <printf@plt>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
call   1070 <sin@plt>
movaps %xmm0,%xmm1
movsd  0x18(%rsp),%xmm2
movsd  %xmm2,0x8(%rsp)
mov    %r13,%rdi
mov    %rbx,%rsi
movsd  0x20(%rsp),%xmm0
call   1060 <fprintf@plt>
movsd  0xdd2(%rip),%xmm1
mulsd  0x28(%rsp),%xmm1
lea    0x30(%rsp),%rdi
movsd  0x8(%rsp),%xmm0
call   1050 <advance_vel@plt>
movsd  0x38(%rsp),%xmm0
ucomisd 0x10(%rsp),%xmm0
jbe    12f6 <lpf_int+0x196>
lea    0x18(%rsp),%r14
lea    0x30(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xd9e(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
movsd  0x28(%rsp),%xmm0
call   1040 <leapfrog@plt>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1070 <sin@plt>
movaps %xmm0,%xmm1
movsd  0x18(%rsp),%xmm2
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <printf@plt>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1070 <sin@plt>
movapd %xmm0,%xmm1
movsd  0x18(%rsp),%xmm2
mov    %r13,%rdi
mov    %rbx,%rsi
movsd  0x8(%rsp),%xmm0
call   1060 <fprintf@plt>
movsd  0x38(%rsp),%xmm0
ucomisd 0x10(%rsp),%xmm0
ja     1280 <lpf_int+0x120>
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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