#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*/ printf(char *, double, ...);
double calcVelocity(int t, double a, int c) {
  double v;
  printf("\n-- Cart %d before collision:", c);
  printf("\nAccelerated at %.2f m/s^2 for %d seconds.", a, t);
  v = a * t;
  printf("\nVelocity after acceleration: %.2lf m/s", v);
  return v;
}


x86 assembly (clang, -O0):
<calcVelocity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
lea    0xed1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
mov    -0x4(%rbp),%esi
lea    0xed9(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xede(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcVelocity>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %edi,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
lea    0xed5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    %ebx,%esi
mov    $0x1,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xee7(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"\0A-- Cart %d before collision:\00"
@.str.1 = [43 x i8] c"\0AAccelerated at %.2f m/s^2 for %d seconds.\00"
@.str.2 = [40 x i8] c"\0AVelocity after acceleration: %.2lf m/s\00"
define double @calcVelocity(i32 %0, double %1, i32 %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = sitofp i32 %8 to double
%10 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), double %9)
%11 = load double, double* %5
%12 = load i32, i32* %4
%13 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), double %11, i32 %12)
%14 = load double, double* %5
%15 = load i32, i32* %4
%16 = sitofp i32 %15 to double
%17 = fmul double %14, %16
store double %17, double* %7
%18 = load double, double* %7
%19 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), double %18)
%20 = load double, double* %7
ret double %20
}

LLVM IR (-O2):
@.str = [30 x i8] c"\0A-- Cart %d before collision:\00"
@.str.1 = [43 x i8] c"\0AAccelerated at %.2f m/s^2 for %d seconds.\00"
@.str.2 = [40 x i8] c"\0AVelocity after acceleration: %.2lf m/s\00"
define double @calcVelocity(i32 %0, double %1, i32 %2) {
%4 = sitofp i32 %2 to double
%5 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), double %4)
%6 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), double %1, i32 %0)
%7 = sitofp i32 %0 to double
%8 = fmul double %7, %1
%9 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), double %8)
ret double %8
}