#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 calculateCharges(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *, float *, float *);
void main(void) {
  float customers[3];
  int i;
  float sumCharge = 0;
  float sumHours = 0;
  printf("%s\n", "Please input the hours the customers park their car:");
  scanf("%f %f %f", &customers[0], &customers[1], &customers[2]);
  printf("Car\tHours\tCharge\n");
  for (i = 1; i <= 3; i++) {
    printf("%d\t", i);
    printf("%.1f\t", customers[i - 1]);
    printf("%.2f\n", calculateCharges(customers[i - 1]));
    sumHours += customers[i - 1];
    sumCharge += calculateCharges(customers[i - 1]);
  }
  printf("TOTAL\t%.1f\t%.2f\n", sumHours, sumCharge);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xeb1(%rip),%rdi
lea    0xeae(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xc(%rbp),%rsi
lea    -0xc(%rbp),%rdx
add    $0x4,%rdx
lea    -0xc(%rbp),%rcx
add    $0x8,%rcx
lea    0xec1(%rip),%rdi
call   1050 <scanf@plt>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jg     1240 <main+0x110>
mov    -0x10(%rbp),%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cltq
movss  -0xc(%rbp,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe92(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cltq
movss  -0xc(%rbp,%rax,4),%xmm0
call   1040 <calculateCharges@plt>
lea    0xe82(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cltq
movss  -0xc(%rbp,%rax,4),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cltq
movss  -0xc(%rbp,%rax,4),%xmm0
call   1040 <calculateCharges@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1192 <main+0x62>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe05(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0xecf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
lea    0xebb(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe9f(%rip),%r15
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
call   1050 <calculateCharges@plt>
lea    0xe94(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
call   1050 <calculateCharges@plt>
xorps  %xmm1,%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x10(%rsp),%xmm0
call   1050 <calculateCharges@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x10(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
call   1050 <calculateCharges@plt>
addsd  0x18(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
mov    %r14,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x14(%rsp),%xmm0
call   1050 <calculateCharges@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x14(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
call   1050 <calculateCharges@plt>
addsd  0x18(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd73(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [53 x i8] c"Please input the hours the customers park their car:\00"
@.str.2 = [9 x i8] c"%f %f %f\00"
@.str.3 = [18 x i8] c"Car\09Hours\09Charge\0A\00"
@.str.4 = [4 x i8] c"%d\09\00"
@.str.5 = [6 x i8] c"%.1f\09\00"
@.str.6 = [6 x i8] c"%.2f\0A\00"
@.str.7 = [17 x i8] c"TOTAL\09%.1f\09%.2f\0A\00"
define void @main() {
%1 = alloca [3 x float]
%2 = alloca i32
%3 = alloca float
%4 = alloca float
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 0
%7 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 1
%8 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 2
%9 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), float* %6, float* %7, float* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %2
br label %11
11: ; preds = %48, %0
%12 = load i32, i32* %2
%13 = icmp sle i32 %12, 3
br i1 %13, label %14, label %51
14: ; preds = %11
%15 = load i32, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %2
%18 = sub nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 %19
%21 = load float, float* %20
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), double %22)
%24 = load i32, i32* %2
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 %26
%28 = load float, float* %27
%29 = call double @calculateCharges(float %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), double %29)
%31 = load i32, i32* %2
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 %33
%35 = load float, float* %34
%36 = load float, float* %4
%37 = fadd float %36, %35
store float %37, float* %4
%38 = load i32, i32* %2
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 %40
%42 = load float, float* %41
%43 = call double @calculateCharges(float %42)
%44 = load float, float* %3
%45 = fpext float %44 to double
%46 = fadd double %45, %43
%47 = fptrunc double %46 to float
store float %47, float* %3
br label %48
48: ; preds = %14
%49 = load i32, i32* %2
%50 = add nsw i32 %49, 1
store i32 %50, i32* %2
br label %11
51: ; preds = %11
%52 = load float, float* %4
%53 = fpext float %52 to double
%54 = load float, float* %3
%55 = fpext float %54 to double
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), double %53, double %55)
ret void
}

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