#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 */
float calculateCharges(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  float hours1, hours2, hours3;
  float charges1, charges2, charges3;
  float totalHours = 0.0, totalCharges = 0.0;
  printf("Enter the hours parked for car 1: ");
  scanf("%f", &hours1);
  charges1 = calculateCharges(hours1);
  totalHours = +hours1;
  totalCharges += charges1;
  printf("Enter the hours parked for car 2: ");
  scanf("%f", &hours2);
  charges2 = calculateCharges(hours2);
  totalHours = +hours2;
  totalCharges += charges2;
  printf("Enter the hours parked for car 3: ");
  scanf("%f", &hours3);
  charges3 = calculateCharges(hours3);
  totalHours = +hours3;
  totalCharges += charges3;
  printf("Car\tHours\tCharge\n");
  printf("1%12.1f%9.2f\n", hours1, charges1);
  printf("2%12.1f%9.2f\n", hours2, charges2);
  printf("3%12.1f%9.2f\n", hours3, charges3);
  printf("TOTAL%8.1f%9.2f\n", totalHours, totalCharges);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movss  -0x8(%rbp),%xmm0
call   1040 <calculateCharges@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe79(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
movss  -0xc(%rbp),%xmm0
call   1040 <calculateCharges@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
addss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe33(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
movss  -0x10(%rbp),%xmm0
call   1040 <calculateCharges@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
addss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe36(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe24(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe12(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe00(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec9(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
movss  0xc(%rsp),%xmm0
call   1050 <calculateCharges@plt>
movss  %xmm0,0x1c(%rsp)
xorps  %xmm1,%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,(%rsp)
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
movss  0x8(%rsp),%xmm0
call   1050 <calculateCharges@plt>
movaps %xmm0,%xmm1
movss  %xmm0,0x14(%rsp)
movss  (%rsp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%rsp)
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
movss  0x4(%rsp),%xmm0
call   1050 <calculateCharges@plt>
movaps %xmm0,%xmm1
movss  %xmm0,0x10(%rsp)
movss  0x4(%rsp),%xmm0
movss  %xmm0,0x18(%rsp)
movss  (%rsp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%rsp)
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x1c(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe3b(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x14(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe27(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x10(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe13(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0x18(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  (%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe00(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Enter the hours parked for car 1: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [35 x i8] c"Enter the hours parked for car 2: \00"
@.str.3 = [35 x i8] c"Enter the hours parked for car 3: \00"
@.str.4 = [18 x i8] c"Car\09Hours\09Charge\0A\00"
@.str.5 = [14 x i8] c"1%12.1f%9.2f\0A\00"
@.str.6 = [14 x i8] c"2%12.1f%9.2f\0A\00"
@.str.7 = [14 x i8] c"3%12.1f%9.2f\0A\00"
@.str.8 = [17 x i8] c"TOTAL%8.1f%9.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %8
store float 0.000000e+00, float* %9
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%12 = load float, float* %2
%13 = call float @calculateCharges(float %12)
store float %13, float* %5
%14 = load float, float* %2
store float %14, float* %8
%15 = load float, float* %5
%16 = load float, float* %9
%17 = fadd float %16, %15
store float %17, float* %9
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%20 = load float, float* %3
%21 = call float @calculateCharges(float %20)
store float %21, float* %6
%22 = load float, float* %3
store float %22, float* %8
%23 = load float, float* %6
%24 = load float, float* %9
%25 = fadd float %24, %23
store float %25, float* %9
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%28 = load float, float* %4
%29 = call float @calculateCharges(float %28)
store float %29, float* %7
%30 = load float, float* %4
store float %30, float* %8
%31 = load float, float* %7
%32 = load float, float* %9
%33 = fadd float %32, %31
store float %33, float* %9
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%35 = load float, float* %2
%36 = fpext float %35 to double
%37 = load float, float* %5
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double %36, double %38)
%40 = load float, float* %3
%41 = fpext float %40 to double
%42 = load float, float* %6
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), double %41, double %43)
%45 = load float, float* %4
%46 = fpext float %45 to double
%47 = load float, float* %7
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), double %46, double %48)
%50 = load float, float* %8
%51 = fpext float %50 to double
%52 = load float, float* %9
%53 = fpext float %52 to double
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), double %51, double %53)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"Enter the hours parked for car 1: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [35 x i8] c"Enter the hours parked for car 2: \00"
@.str.3 = [35 x i8] c"Enter the hours parked for car 3: \00"
@.str.5 = [14 x i8] c"1%12.1f%9.2f\0A\00"
@.str.6 = [14 x i8] c"2%12.1f%9.2f\0A\00"
@.str.7 = [14 x i8] c"3%12.1f%9.2f\0A\00"
@.str.8 = [17 x i8] c"TOTAL%8.1f%9.2f\0A\00"
@str = [17 x i8] c"Car\09Hours\09Charge\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%9 = load float, float* %1
%10 = call float @calculateCharges(float %9)
%11 = fadd float %10, 0.000000e+00
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%14 = load float, float* %2
%15 = call float @calculateCharges(float %14)
%16 = fadd float %11, %15
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%19 = load float, float* %3
%20 = call float @calculateCharges(float %19)
%21 = load float, float* %3
%22 = fadd float %16, %20
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%24 = load float, float* %1
%25 = fpext float %24 to double
%26 = fpext float %10 to double
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double %25, double %26)
%28 = load float, float* %2
%29 = fpext float %28 to double
%30 = fpext float %15 to double
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), double %29, double %30)
%32 = load float, float* %3
%33 = fpext float %32 to double
%34 = fpext float %20 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), double %33, double %34)
%36 = fpext float %21 to double
%37 = fpext float %22 to double
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), double %36, double %37)
ret i32 0
}