#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(void) {
  float distancia_km = 0, litros_combustivel = 0;
  float distancia_acumulada = 0, litros_acumulados = 0;
  while (1) {
    printf("Informe quantos litros de combustível foi abastecido:\n");
    scanf("%f", &litros_combustivel);
    if (litros_combustivel == -1)
      break;
    litros_acumulados += litros_combustivel;
    printf("Informe quantos km foram rodados:\n");
    scanf("%f", &distancia_km);
    distancia_acumulada += distancia_km;
    printf("O consumo atual é de %f km/l\n\n",
           distancia_km / litros_combustivel);
  }
  printf("O consumo geral foi de %f km/l.",
         distancia_acumulada / litros_acumulados);
}


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,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0xc(%rbp),%xmm0
movss  0xe86(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    118e <main+0x6e>
jp     118e <main+0x6e>
jmp    11eb <main+0xcb>
movss  -0xc(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe83(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    114f <main+0x2f>
movss  -0x10(%rbp),%xmm0
divss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe82(%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,0x10(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xefa(%rip),%rdi
call   1030 <puts@plt>
lea    0xeab(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm0
ucomiss 0xe90(%rip),%xmm0
jne    1189 <main+0x59>
jp     1189 <main+0x59>
movsd  0xe7c(%rip),%xmm0
jmp    123f <main+0x10f>
xorps  %xmm1,%xmm1
lea    0xef3(%rip),%r14
lea    0xe72(%rip),%rbx
lea    0x10(%rsp),%r15
lea    0xe69(%rip),%r12
lea    0xea2(%rip),%r13
lea    0x8(%rsp),%rbp
xorps  %xmm2,%xmm2
movss  %xmm2,0xc(%rsp)
nopl   0x0(%rax,%rax,1)
addss  %xmm0,%xmm1
movss  %xmm1,0x14(%rsp)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
movss  0x10(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
divss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm1
movss  0x8(%rsp),%xmm0
ucomiss 0xddb(%rip),%xmm0
jne    11c0 <main+0x90>
jp     11c0 <main+0x90>
movss  0xc(%rsp),%xmm0
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde9(%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 = [56 x i8] c"Informe quantos litros de combust\C3\ADvel foi abastecido:\0A\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [35 x i8] c"Informe quantos km foram rodados:\0A\00"
@.str.3 = [32 x i8] c"O consumo atual \C3\A9 de %f km/l\0A\0A\00"
@.str.4 = [32 x i8] c"O consumo geral foi de %f 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* %3
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
br label %6
6: ; preds = %0, %12
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 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* %3)
%9 = load float, float* %3
%10 = fcmp oeq float %9, -1.000000e+00
br i1 %10, label %11, label %12
11: ; preds = %6
br label %26
12: ; preds = %6
%13 = load float, float* %3
%14 = load float, float* %5
%15 = fadd float %14, %13
store float %15, float* %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%18 = load float, float* %2
%19 = load float, float* %4
%20 = fadd float %19, %18
store float %20, float* %4
%21 = load float, float* %2
%22 = load float, float* %3
%23 = fdiv float %21, %22
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), double %24)
br label %6
26: ; preds = %11
%27 = load float, float* %4
%28 = load float, float* %5
%29 = fdiv float %27, %28
%30 = fpext float %29 to double
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), double %30)
%32 = load i32, i32* %1
ret i32 %32
}

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