#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, float *);
int main(void) {
  float calculateCharges(float oreParcheggio);
  float oreParcheggio;
  float totaleIncassiParcheggio = 0;
  float totaleParcheggio;
  float oreParcheggioTotali = 0;
  float valoreSentinella = 666.0;
  unsigned int numeroInserimento = 1;
  puts("Per ogni cliente inserire le ore di parcheggio e premere invio: ");
  puts("Car \t Hours \t Charge ");
  do {
    scanf("%f", &oreParcheggio);
    if (oreParcheggio != valoreSentinella && oreParcheggio > 0) {
      totaleParcheggio = calculateCharges(oreParcheggio);
      printf("%5u\t%5.2f\t%5.2f\n", numeroInserimento, oreParcheggio,
             totaleParcheggio);
      oreParcheggioTotali += oreParcheggio;
      totaleIncassiParcheggio += totaleParcheggio;
      numeroInserimento++;
    } else if (oreParcheggio != valoreSentinella) {
      puts("E' stato inserito un valore non valido");
    }
  } while (oreParcheggio != valoreSentinella);
  printf("%5s\t%5.2f\t%5.2f\n", "TOTAL", oreParcheggioTotali,
         totaleIncassiParcheggio);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xe99(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xec9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movss  -0x8(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jne    11b5 <main+0x75>
jp     11b5 <main+0x75>
jmp    1224 <main+0xe4>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1224 <main+0xe4>
movss  -0x8(%rbp),%xmm0
call   1050 <calculateCharges@plt>
movss  %xmm0,-0x10(%rbp)
mov    -0x1c(%rbp),%esi
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe6d(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  -0x8(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    124f <main+0x10f>
movss  -0x8(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jne    123e <main+0xfe>
jp     123e <main+0xfe>
jmp    124a <main+0x10a>
lea    0xe2a(%rip),%rdi
call   1030 <puts@plt>
jmp    124f <main+0x10f>
jmp    1254 <main+0x114>
movss  -0x8(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jne    118b <main+0x4b>
jp     118b <main+0x4b>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe14(%rip),%rdi
lea    0xe1e(%rip),%rsi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
lea    0xeee(%rip),%r14
mov    %rsp,%r15
lea    0xee7(%rip),%r12
lea    0xef1(%rip),%r13
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
jmp    1200 <main+0xc0>
cs nopw 0x0(%rax,%rax,1)
call   1050 <calculateCharges@plt>
movaps %xmm0,%xmm1
movss  %xmm0,0xc(%rsp)
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
mov    %r12,%rdi
mov    %ebx,%esi
mov    $0x2,%al
call   1040 <printf@plt>
movss  (%rsp),%xmm0
movss  0x8(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
movss  0x4(%rsp),%xmm1
addss  0xc(%rsp),%xmm1
movss  %xmm1,0x4(%rsp)
add    $0x1,%ebx
movss  0xe07(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1200 <main+0xc0>
jnp    1242 <main+0x102>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
movss  0xded(%rip),%xmm1
movss  (%rsp),%xmm0
ucomiss %xmm1,%xmm0
jne    121f <main+0xdf>
jnp    122c <main+0xec>
ucomiss 0xdde(%rip),%xmm0
ja     11a0 <main+0x60>
ucomiss %xmm1,%xmm0
jne    1233 <main+0xf3>
jnp    1242 <main+0x102>
mov    %r13,%rdi
call   1030 <puts@plt>
movss  (%rsp),%xmm0
jmp    11f1 <main+0xb1>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x4(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe3d(%rip),%rdi
lea    0xe47(%rip),%rsi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [65 x i8] c"Per ogni cliente inserire le ore di parcheggio e premere invio: \00"
@.str.1 = [22 x i8] c"Car \09 Hours \09 Charge \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [17 x i8] c"%5u\09%5.2f\09%5.2f\0A\00"
@.str.4 = [39 x i8] c"E' stato inserito un valore non valido\00"
@.str.5 = [17 x i8] c"%5s\09%5.2f\09%5.2f\0A\00"
@.str.6 = [6 x i8] c"TOTAL\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
store i32 0, i32* %1
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %5
store float 6.660000e+02, float* %6
store i32 1, i32* %7
%8 = call i32 @puts(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %43, %0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%12 = load float, float* %2
%13 = load float, float* %6
%14 = fcmp une float %12, %13
br i1 %14, label %15, label %35
15: ; preds = %10
%16 = load float, float* %2
%17 = fcmp ogt float %16, 0.000000e+00
br i1 %17, label %18, label %35
18: ; preds = %15
%19 = load float, float* %2
%20 = call float @calculateCharges(float %19)
store float %20, float* %4
%21 = load i32, i32* %7
%22 = load float, float* %2
%23 = fpext float %22 to double
%24 = load float, float* %4
%25 = fpext float %24 to double
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %21, double %23, double %25)
%27 = load float, float* %2
%28 = load float, float* %5
%29 = fadd float %28, %27
store float %29, float* %5
%30 = load float, float* %4
%31 = load float, float* %3
%32 = fadd float %31, %30
store float %32, float* %3
%33 = load i32, i32* %7
%34 = add i32 %33, 1
store i32 %34, i32* %7
br label %42
35: ; preds = %15, %10
%36 = load float, float* %2
%37 = load float, float* %6
%38 = fcmp une float %36, %37
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %41
41: ; preds = %39, %35
br label %42
42: ; preds = %41, %18
br label %43
43: ; preds = %42
%44 = load float, float* %2
%45 = load float, float* %6
%46 = fcmp une float %44, %45
br i1 %46, label %10, label %47
47: ; preds = %43
%48 = load float, float* %5
%49 = fpext float %48 to double
%50 = load float, float* %3
%51 = fpext float %50 to double
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), double %49, double %51)
ret i32 0
}

LLVM IR (-O2):
@.str = [65 x i8] c"Per ogni cliente inserire le ore di parcheggio e premere invio: \00"
@.str.1 = [22 x i8] c"Car \09 Hours \09 Charge \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [17 x i8] c"%5u\09%5.2f\09%5.2f\0A\00"
@.str.4 = [39 x i8] c"E' stato inserito un valore non valido\00"
@.str.5 = [17 x i8] c"%5s\09%5.2f\09%5.2f\0A\00"
@.str.6 = [6 x i8] c"TOTAL\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %28, %0
%6 = phi float [ 0.000000e+00, %0 ], [ %30, %28 ]
%7 = phi float [ 0.000000e+00, %0 ], [ %31, %28 ]
%8 = phi i32 [ 1, %0 ], [ %32, %28 ]
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
%10 = load float, float* %1
%11 = fcmp une float %10, 6.660000e+02
%12 = fcmp ogt float %10, 0.000000e+00
%13 = and i1 %11, %12
br i1 %13, label %14, label %24
14: ; preds = %5
%15 = call float @calculateCharges(float %10)
%16 = load float, float* %1
%17 = fpext float %16 to double
%18 = fpext float %15 to double
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %8, double %17, double %18)
%20 = load float, float* %1
%21 = fadd float %6, %20
%22 = fadd float %7, %15
%23 = add i32 %8, 1
br label %28
24: ; preds = %5
br i1 %11, label %25, label %34
25: ; preds = %24
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
%27 = load float, float* %1
br label %28
28: ; preds = %14, %25
%29 = phi float [ %20, %14 ], [ %27, %25 ]
%30 = phi float [ %21, %14 ], [ %6, %25 ]
%31 = phi float [ %22, %14 ], [ %7, %25 ]
%32 = phi i32 [ %23, %14 ], [ %8, %25 ]
%33 = fcmp une float %29, 6.660000e+02
br i1 %33, label %5, label %34
34: ; preds = %24, %28
%35 = phi float [ %31, %28 ], [ %7, %24 ]
%36 = phi float [ %30, %28 ], [ %6, %24 ]
%37 = fpext float %36 to double
%38 = fpext float %35 to double
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), double %37, double %38)
ret i32 0
}