#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 litros = 0, km, tLitros = 0, tKm = 0;
  while (litros != -1) {
    printf("Informe quantos litros abasteceu (-1 para terminar): ");
    scanf("%f", &litros);
    if (litros != -1) {
      printf("Informe quantos km dirigiu: ");
      scanf("%f", &km);
      printf("O consumo atual e de %.6f km/l", km / litros);
      tLitros += litros;
      tKm += km;
    }
    printf("\n\n");
  }
  printf("O consumo geral foi de %.6f km/l", tKm / tLitros);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  0xeac(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1168 <main+0x48>
jp     1168 <main+0x48>
jmp    1212 <main+0xf2>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
movss  0xe6d(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    11a7 <main+0x87>
jp     11a7 <main+0x87>
jmp    11ff <main+0xdf>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0xc(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe80(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1147 <main+0x27>
movss  -0x14(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe55(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%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,0x8(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
lea    0xeae(%rip),%r14
lea    0xedd(%rip),%rbx
lea    0x8(%rsp),%r15
lea    0x14(%rsp),%r13
lea    0xeec(%rip),%rbp
lea    0xf25(%rip),%r12
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
jmp    11a1 <main+0x71>
mov    %r12,%rdi
call   1030 <puts@plt>
movss  0x8(%rsp),%xmm0
movss  0xe6a(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    11a1 <main+0x71>
jnp    1223 <main+0xf3>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm0
ucomiss 0xe3d(%rip),%xmm0
jne    11c7 <main+0x97>
jnp    1180 <main+0x50>
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm0
divss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
addss  0x8(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x10(%rsp),%xmm0
addss  0x14(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
jmp    1180 <main+0x50>
movss  0x10(%rsp),%xmm0
divss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3f(%rip),%rdi
mov    $0x1,%al
call   1040 <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 = [54 x i8] c"Informe quantos litros abasteceu (-1 para terminar): \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [29 x i8] c"Informe quantos km dirigiu: \00"
@.str.3 = [31 x i8] c"O consumo atual e de %.6f km/l\00"
@.str.4 = [3 x i8] c"\0A\0A\00"
@.str.5 = [33 x i8] c"O consumo geral foi de %.6f km/l\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %2
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
br label %6
6: ; preds = %28, %0
%7 = load float, float* %2
%8 = fcmp une float %7, -1.000000e+00
br i1 %8, label %9, label %30
9: ; preds = %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 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 = fcmp une float %12, -1.000000e+00
br i1 %13, label %14, label %28
14: ; preds = %9
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%17 = load float, float* %3
%18 = load float, float* %2
%19 = fdiv float %17, %18
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), double %20)
%22 = load float, float* %2
%23 = load float, float* %4
%24 = fadd float %23, %22
store float %24, float* %4
%25 = load float, float* %3
%26 = load float, float* %5
%27 = fadd float %26, %25
store float %27, float* %5
br label %28
28: ; preds = %14, %9
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %6
30: ; preds = %6
%31 = load float, float* %5
%32 = load float, float* %4
%33 = fdiv float %31, %32
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), double %34)
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@.str = [54 x i8] c"Informe quantos litros abasteceu (-1 para terminar): \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [29 x i8] c"Informe quantos km dirigiu: \00"
@.str.3 = [31 x i8] c"O consumo atual e de %.6f km/l\00"
@.str.5 = [33 x i8] c"O consumo geral foi de %.6f km/l\00"
@str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
%4 = bitcast float* %2 to i8*
br label %5
5: ; preds = %0, %24
%6 = phi float [ 0.000000e+00, %0 ], [ %26, %24 ]
%7 = phi float [ 0.000000e+00, %0 ], [ %25, %24 ]
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, 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 %24
12: ; preds = %5
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%15 = load float, float* %2
%16 = load float, float* %1
%17 = fdiv float %15, %16
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), double %18)
%20 = load float, float* %1
%21 = fadd float %7, %20
%22 = load float, float* %2
%23 = fadd float %6, %22
br label %24
24: ; preds = %12, %5
%25 = phi float [ %21, %12 ], [ %7, %5 ]
%26 = phi float [ %23, %12 ], [ %6, %5 ]
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%28 = load float, float* %1
%29 = fcmp une float %28, -1.000000e+00
br i1 %29, label %5, label %30
30: ; preds = %24
%31 = fdiv float %26, %25
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), double %32)
ret i32 0
}