#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 *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  float distance, i, mph, time, traveledHalfHour;
  mph = 0;
  time = 0;
  distance = 0;
  traveledHalfHour = 0;
  printf("\nThis program calculates the distance traveled and displays the "
         "distance reached at every half hour until the end of the trip.\n");
  printf("\nPlease enter the average speed (in mph) --> ");
  scanf("%f", &mph);
  printf("\nNow, enter the time traveled (in hours) --> ");
  scanf("%f", &time);
  distance = (mph * time);
  printf("\nYou entered, %.2f mph.\nYou entered, %.2f hours.\nFor a total "
         "distance traveled of %.2f miles.\n",
         mph, time, distance);
  traveledHalfHour = distance / (2 * (distance / mph));
  i = traveledHalfHour;
  while (i <= distance) {
    printf("\nDistance traveled in half hour: %.2f", i);
    i = i + traveledHalfHour;
  }
  printf("\n\nTotal distance traveled at %.2f mph, \nover the course of %.2f "
         "hours was %.2f miles.\n",
         mph, time, distance);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf40(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xf33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf22(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x10(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x8(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xf19(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm2
divss  -0x10(%rbp),%xmm2
movss  0xe18(%rip),%xmm1
mulss  %xmm2,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     123d <main+0x11d>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xf20(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11ff <main+0xdf>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x8(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xf09(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movl   $0x0,0x4(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xfef(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec8(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0x4(%rsp),%xmm2
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm2,%xmm0
mulss  %xmm1,%xmm2
movss  %xmm2,0x10(%rsp)
cvtss2sd %xmm1,%xmm1
cvtss2sd %xmm2,%xmm2
lea    0xea8(%rip),%rdi
movsd  %xmm2,0x18(%rsp)
mov    $0x3,%al
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
movss  0x10(%rsp),%xmm3
movaps %xmm3,%xmm1
divss  %xmm0,%xmm1
addss  %xmm1,%xmm1
movaps %xmm3,%xmm2
divss  %xmm1,%xmm2
movaps %xmm3,%xmm1
movss  %xmm2,0xc(%rsp)
ucomiss %xmm2,%xmm3
jb     1237 <main+0x107>
lea    0xec7(%rip),%rbx
movss  0xc(%rsp),%xmm0
nopl   (%rax)
movss  %xmm0,0x14(%rsp)
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
addss  0xc(%rsp),%xmm0
ucomiss %xmm0,%xmm1
jae    1200 <main+0xd0>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe98(%rip),%rdi
movsd  0x18(%rsp),%xmm2
mov    $0x3,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [128 x i8] c"\0AThis program calculates the distance traveled and displays the distance reached at every half hour until the end of the trip.\0A\00"
@.str.1 = [46 x i8] c"\0APlease enter the average speed (in mph) --> \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [46 x i8] c"\0ANow, enter the time traveled (in hours) --> \00"
@.str.4 = [95 x i8] c"\0AYou entered, %.2f mph.\0AYou entered, %.2f hours.\0AFor a total distance traveled of %.2f miles.\0A\00"
@.str.5 = [38 x i8] c"\0ADistance traveled in half hour: %.2f\00"
@.str.6 = [87 x i8] c"\0A\0ATotal distance traveled at %.2f mph, \0Aover the course of %.2f hours was %.2f miles.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
store float 0.000000e+00, float* %2
store float 0.000000e+00, float* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %4)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %5)
%12 = load float, float* %4
%13 = load float, float* %5
%14 = fmul float %12, %13
store float %14, float* %2
%15 = load float, float* %4
%16 = fpext float %15 to double
%17 = load float, float* %5
%18 = fpext float %17 to double
%19 = load float, float* %2
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([95 x i8], [95 x i8]* @.str.4, i64 0, i64 0), double %16, double %18, double %20)
%22 = load float, float* %2
%23 = load float, float* %2
%24 = load float, float* %4
%25 = fdiv float %23, %24
%26 = fmul float 2.000000e+00, %25
%27 = fdiv float %22, %26
store float %27, float* %6
%28 = load float, float* %6
store float %28, float* %3
br label %29
29: ; preds = %33, %0
%30 = load float, float* %3
%31 = load float, float* %2
%32 = fcmp ole float %30, %31
br i1 %32, label %33, label %40
33: ; preds = %29
%34 = load float, float* %3
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), double %35)
%37 = load float, float* %3
%38 = load float, float* %6
%39 = fadd float %37, %38
store float %39, float* %3
br label %29
40: ; preds = %29
%41 = load float, float* %4
%42 = fpext float %41 to double
%43 = load float, float* %5
%44 = fpext float %43 to double
%45 = load float, float* %2
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.6, i64 0, i64 0), double %42, double %44, double %46)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [46 x i8] c"\0APlease enter the average speed (in mph) --> \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [46 x i8] c"\0ANow, enter the time traveled (in hours) --> \00"
@.str.4 = [95 x i8] c"\0AYou entered, %.2f mph.\0AYou entered, %.2f hours.\0AFor a total distance traveled of %.2f miles.\0A\00"
@.str.5 = [38 x i8] c"\0ADistance traveled in half hour: %.2f\00"
@.str.6 = [87 x i8] c"\0A\0ATotal distance traveled at %.2f mph, \0Aover the course of %.2f hours was %.2f miles.\0A\00"
@str = [127 x i8] c"\0AThis program calculates the distance traveled and displays the distance reached at every half hour until the end of the trip.\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
%4 = bitcast float* %2 to i8*
store float 0.000000e+00, float* %1
store float 0.000000e+00, float* %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([127 x i8], [127 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%10 = load float, float* %1
%11 = load float, float* %2
%12 = fmul float %10, %11
%13 = fpext float %10 to double
%14 = fpext float %11 to double
%15 = fpext float %12 to double
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([95 x i8], [95 x i8]* @.str.4, i64 0, i64 0), double %13, double %14, double %15)
%17 = load float, float* %1
%18 = fdiv float %12, %17
%19 = fmul float %18, 2.000000e+00
%20 = fdiv float %12, %19
%21 = fcmp ugt float %20, %12
br i1 %21, label %30, label %22
22: ; preds = %0, %22
%23 = phi float [ %26, %22 ], [ %20, %0 ]
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), double %24)
%26 = fadd float %20, %23
%27 = fcmp ugt float %26, %12
br i1 %27, label %28, label %22
28: ; preds = %22
%29 = load float, float* %1
br label %30
30: ; preds = %28, %0
%31 = phi float [ %29, %28 ], [ %17, %0 ]
%32 = fpext float %31 to double
%33 = load float, float* %2
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([87 x i8], [87 x i8]* @.str.6, i64 0, i64 0), double %32, double %34, double %15)
ret i32 0
}