#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 *, ...);
int main(void) {
  float galloniConsumati = 0;
  unsigned int migliaPercorse = 0;
  float migliaPerGallone = 0;
  int valoreSentinella = -1;
  float subGalloniConsumati = 0;
  unsigned int subMigliaPercorse = 0;
  while (galloniConsumati != valoreSentinella) {
    printf("%s", "Prego inserire i galloni di carburante utilizzati (-1 per "
                 "terminare): ");
    scanf("%f", &galloniConsumati);
    if (galloniConsumati != valoreSentinella) {
      printf("%s", "\nPrego inserire le miglia di guida: ");
      scanf("%d", &migliaPercorse);
      migliaPerGallone = (migliaPercorse / galloniConsumati);
      printf("\nLe miglie/galloni per questo camion sono state %f",
             migliaPerGallone);
      subMigliaPercorse += migliaPercorse;
      subGalloniConsumati += galloniConsumati;
    }
  }
  printf("\n\nLa media totale di miglia/gallore e': %f\n",
         (subMigliaPercorse / subGalloniConsumati));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jne    117a <main+0x5a>
jp     117a <main+0x5a>
jmp    1230 <main+0x110>
lea    0xe7f(%rip),%rdi
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0c(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jne    11bf <main+0x9f>
jp     11bf <main+0x9f>
jmp    122b <main+0x10b>
lea    0xe3a(%rip),%rdi
lea    0xe7d(%rip),%rsi
xor    %eax,%eax
mov    %al,-0x1d(%rbp)
call   1030 <printf@plt>
mov    -0x1d(%rbp),%al
lea    0xe8e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
cvtsi2ss %rax,%xmm0
divss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe66(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movss  -0x8(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    115c <main+0x3c>
mov    -0x1c(%rbp),%eax
cvtsi2ss %rax,%xmm0
divss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x10(%rsp)
xorps  %xmm1,%xmm1
lea    0xebc(%rip),%rbx
lea    0xc(%rsp),%r12
lea    0xf1f(%rip),%rbp
lea    0x10(%rsp),%r14
lea    0xf16(%rip),%r15
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  %xmm1,0x14(%rsp)
mov    %rbx,%rdi
lea    0xe87(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf18(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0xc(%rsp),%xmm0
ucomiss 0xe5b(%rip),%xmm0
jne    11a9 <main+0x89>
jnp    1211 <main+0xf1>
mov    %rbx,%rdi
lea    0xe9b(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
divss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  0xc(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
addss  %xmm0,%xmm1
add    0x10(%rsp),%r13d
ucomiss 0xdfd(%rip),%xmm0
jne    1170 <main+0x50>
jp     1170 <main+0x50>
jmp    1217 <main+0xf7>
movss  0x14(%rsp),%xmm1
mov    %r13d,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe78(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [71 x i8] c"Prego inserire i galloni di carburante utilizzati (-1 per terminare): \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [37 x i8] c"\0APrego inserire le miglia di guida: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [51 x i8] c"\0ALe miglie/galloni per questo camion sono state %f\00"
@.str.6 = [44 x i8] c"\0A\0ALa media totale di miglia/gallore e': %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca i32
%4 = alloca float
%5 = alloca i32
%6 = alloca float
%7 = alloca i32
store i32 0, i32* %1
store float 0.000000e+00, float* %2
store i32 0, i32* %3
store float 0.000000e+00, float* %4
store i32 -1, i32* %5
store float 0.000000e+00, float* %6
store i32 0, i32* %7
br label %8
8: ; preds = %36, %0
%9 = load float, float* %2
%10 = load i32, i32* %5
%11 = sitofp i32 %10 to float
%12 = fcmp une float %9, %11
br i1 %12, label %13, label %37
13: ; preds = %8
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%16 = load float, float* %2
%17 = load i32, i32* %5
%18 = sitofp i32 %17 to float
%19 = fcmp une float %16, %18
br i1 %19, label %20, label %36
20: ; preds = %13
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%23 = load i32, i32* %3
%24 = uitofp i32 %23 to float
%25 = load float, float* %2
%26 = fdiv float %24, %25
store float %26, float* %4
%27 = load float, float* %4
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), double %28)
%30 = load i32, i32* %3
%31 = load i32, i32* %7
%32 = add i32 %31, %30
store i32 %32, i32* %7
%33 = load float, float* %2
%34 = load float, float* %6
%35 = fadd float %34, %33
store float %35, float* %6
br label %36
36: ; preds = %20, %13
br label %8
37: ; preds = %8
%38 = load i32, i32* %7
%39 = uitofp i32 %38 to float
%40 = load float, float* %6
%41 = fdiv float %39, %40
%42 = fpext float %41 to double
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), double %42)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [71 x i8] c"Prego inserire i galloni di carburante utilizzati (-1 per terminare): \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [37 x i8] c"\0APrego inserire le miglia di guida: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [51 x i8] c"\0ALe miglie/galloni per questo camion sono state %f\00"
@.str.6 = [44 x i8] c"\0A\0ALa media totale di miglia/gallore e': %f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca i32
%3 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
br label %5
5: ; preds = %0, %12
%6 = phi i32 [ 0, %0 ], [ %22, %12 ]
%7 = phi float [ 0.000000e+00, %0 ], [ %24, %12 ]
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @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, -1.000000e+00
br i1 %11, label %12, label %26
12: ; preds = %5
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %2
%16 = uitofp i32 %15 to float
%17 = load float, float* %1
%18 = fdiv float %16, %17
%19 = fpext float %18 to double
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), double %19)
%21 = load i32, i32* %2
%22 = add i32 %21, %6
%23 = load float, float* %1
%24 = fadd float %7, %23
%25 = fcmp une float %23, -1.000000e+00
br i1 %25, label %5, label %26
26: ; preds = %5, %12
%27 = phi i32 [ %22, %12 ], [ %6, %5 ]
%28 = phi float [ %24, %12 ], [ %7, %5 ]
%29 = uitofp i32 %27 to float
%30 = fdiv float %29, %28
%31 = fpext float %30 to double
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), double %31)
ret i32 0
}