#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 */
double calcFinVel(int, int, double, double);
double calcForce(int, double);
double calcKE(int, double);
int /*<<< orphan*/ calcSpringComp(int, double, int);
double calcVelocity(int, double, int);
double getCartAccel(int);
int getCartMass(int);
int getCartTime(int);
int getSpringConstant();
int main() {
  int k = 0;
  int mass1 = 0;
  int mass2 = 0;
  int time1 = 0;
  int time2 = 0;
  double acc1 = 0.0;
  double acc2 = 0.0;
  double vel1 = 0.0;
  double vel2 = 0.0;
  double f1 = 0.0;
  double f2 = 0.0;
  double ke1 = 0.0;
  double ke2 = 0.0;
  double afco_vel = 0.0;
  double ke_spr = 0.0;
  k = getSpringConstant();
  mass1 = getCartMass(1);
  acc1 = getCartAccel(1);
  time1 = getCartTime(1);
  mass2 = getCartMass(2);
  acc2 = getCartAccel(2);
  time2 = getCartTime(2);
  vel1 = calcVelocity(time1, acc1, 1);
  f1 = calcForce(mass1, acc1);
  ke1 = calcKE(mass1, vel1);
  vel2 = calcVelocity(time2, acc2, 2);
  f2 = calcForce(mass2, acc2);
  ke2 = calcKE(mass2, vel2);
  afco_vel = calcFinVel(mass1, mass2, vel1, vel2);
  calcSpringComp((mass1 + mass2), afco_vel, k);
  ke_spr = calcKE((mass1 + mass2), afco_vel);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    $0x0,%al
call   1080 <getSpringConstant@plt>
mov    %eax,-0x8(%rbp)
mov    $0x1,%edi
call   1090 <getCartMass@plt>
mov    %eax,-0xc(%rbp)
mov    $0x1,%edi
call   10b0 <getCartAccel@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x1,%edi
call   1060 <getCartTime@plt>
mov    %eax,-0x14(%rbp)
mov    $0x2,%edi
call   1090 <getCartMass@plt>
mov    %eax,-0x10(%rbp)
mov    $0x2,%edi
call   10b0 <getCartAccel@plt>
movsd  %xmm0,-0x28(%rbp)
mov    $0x2,%edi
call   1060 <getCartTime@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
mov    $0x1,%esi
call   1070 <calcVelocity@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0xc(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
call   1050 <calcForce@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0xc(%rbp),%edi
movsd  -0x30(%rbp),%xmm0
call   10a0 <calcKE@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -0x18(%rbp),%edi
movsd  -0x28(%rbp),%xmm0
mov    $0x2,%esi
call   1070 <calcVelocity@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%edi
movsd  -0x28(%rbp),%xmm0
call   1050 <calcForce@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%edi
movsd  -0x38(%rbp),%xmm0
call   10a0 <calcKE@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1040 <calcFinVel@plt>
movsd  %xmm0,-0x60(%rbp)
mov    -0xc(%rbp),%edi
add    -0x10(%rbp),%edi
movsd  -0x60(%rbp),%xmm0
mov    -0x8(%rbp),%esi
call   1030 <calcSpringComp@plt>
mov    -0xc(%rbp),%edi
add    -0x10(%rbp),%edi
movsd  -0x60(%rbp),%xmm0
call   10a0 <calcKE@plt>
movsd  %xmm0,-0x68(%rbp)
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
xor    %eax,%eax
call   1080 <getSpringConstant@plt>
mov    %eax,%r14d
mov    $0x1,%edi
call   1090 <getCartMass@plt>
mov    %eax,%ebp
mov    $0x1,%edi
call   10b0 <getCartAccel@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%edi
call   1060 <getCartTime@plt>
mov    %eax,%r15d
mov    $0x2,%edi
call   1090 <getCartMass@plt>
mov    %eax,%ebx
mov    $0x2,%edi
call   10b0 <getCartAccel@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x2,%edi
call   1060 <getCartTime@plt>
mov    %eax,%r12d
mov    %r15d,%edi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%esi
call   1070 <calcVelocity@plt>
movsd  %xmm0,0x18(%rsp)
mov    %ebp,%edi
movsd  0x8(%rsp),%xmm0
call   1050 <calcForce@plt>
mov    %ebp,%edi
movsd  0x18(%rsp),%xmm0
call   10a0 <calcKE@plt>
mov    %r12d,%edi
movsd  0x10(%rsp),%xmm0
mov    $0x2,%esi
call   1070 <calcVelocity@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
movsd  0x10(%rsp),%xmm0
call   1050 <calcForce@plt>
mov    %ebx,%edi
movsd  0x8(%rsp),%xmm0
call   10a0 <calcKE@plt>
mov    %ebp,%edi
mov    %ebx,%esi
movsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1040 <calcFinVel@plt>
movsd  %xmm0,0x10(%rsp)
add    %ebp,%ebx
mov    %ebx,%edi
mov    %r14d,%esi
call   1030 <calcSpringComp@plt>
mov    %ebx,%edi
movsd  0x10(%rsp),%xmm0
call   10a0 <calcKE@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %12
store double 0.000000e+00, double* %13
store double 0.000000e+00, double* %14
store double 0.000000e+00, double* %15
store double 0.000000e+00, double* %16
%17 = call i32 (...) @getSpringConstant()
store i32 %17, i32* %2
%18 = call i32 @getCartMass(i32 1)
store i32 %18, i32* %3
%19 = call double @getCartAccel(i32 1)
store double %19, double* %7
%20 = call i32 @getCartTime(i32 1)
store i32 %20, i32* %5
%21 = call i32 @getCartMass(i32 2)
store i32 %21, i32* %4
%22 = call double @getCartAccel(i32 2)
store double %22, double* %8
%23 = call i32 @getCartTime(i32 2)
store i32 %23, i32* %6
%24 = load i32, i32* %5
%25 = load double, double* %7
%26 = call double @calcVelocity(i32 %24, double %25, i32 1)
store double %26, double* %9
%27 = load i32, i32* %3
%28 = load double, double* %7
%29 = call double @calcForce(i32 %27, double %28)
store double %29, double* %11
%30 = load i32, i32* %3
%31 = load double, double* %9
%32 = call double @calcKE(i32 %30, double %31)
store double %32, double* %13
%33 = load i32, i32* %6
%34 = load double, double* %8
%35 = call double @calcVelocity(i32 %33, double %34, i32 2)
store double %35, double* %10
%36 = load i32, i32* %4
%37 = load double, double* %8
%38 = call double @calcForce(i32 %36, double %37)
store double %38, double* %12
%39 = load i32, i32* %4
%40 = load double, double* %10
%41 = call double @calcKE(i32 %39, double %40)
store double %41, double* %14
%42 = load i32, i32* %3
%43 = load i32, i32* %4
%44 = load double, double* %9
%45 = load double, double* %10
%46 = call double @calcFinVel(i32 %42, i32 %43, double %44, double %45)
store double %46, double* %15
%47 = load i32, i32* %3
%48 = load i32, i32* %4
%49 = add nsw i32 %47, %48
%50 = load double, double* %15
%51 = load i32, i32* %2
%52 = call i32 @calcSpringComp(i32 %49, double %50, i32 %51)
%53 = load i32, i32* %3
%54 = load i32, i32* %4
%55 = add nsw i32 %53, %54
%56 = load double, double* %15
%57 = call double @calcKE(i32 %55, double %56)
store double %57, double* %16
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @getSpringConstant()
%2 = tail call i32 @getCartMass(i32 1)
%3 = tail call double @getCartAccel(i32 1)
%4 = tail call i32 @getCartTime(i32 1)
%5 = tail call i32 @getCartMass(i32 2)
%6 = tail call double @getCartAccel(i32 2)
%7 = tail call i32 @getCartTime(i32 2)
%8 = tail call double @calcVelocity(i32 %4, double %3, i32 1)
%9 = tail call double @calcForce(i32 %2, double %3)
%10 = tail call double @calcKE(i32 %2, double %8)
%11 = tail call double @calcVelocity(i32 %7, double %6, i32 2)
%12 = tail call double @calcForce(i32 %5, double %6)
%13 = tail call double @calcKE(i32 %5, double %11)
%14 = tail call double @calcFinVel(i32 %2, i32 %5, double %8, double %11)
%15 = add nsw i32 %5, %2
%16 = tail call i32 @calcSpringComp(i32 %15, double %14, i32 %1)
%17 = tail call double @calcKE(i32 %15, double %14)
ret i32 0
}