#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 d_percorrida = 0.0, l_abastecido = 0.0, consumo_total = 0.0,
        km_total = 0.0, litros_total = 0.0;
  while ((d_percorrida != -1.0) && (l_abastecido != -1.0)) {
    printf(
        "informe quantos litros abasteceu(-1 para finalizar o programa): \n");
    scanf("%f", &l_abastecido);
    printf("infome quantos km dirigiu: \n");
    scanf("%f", &d_percorrida);
    if ((d_percorrida > 0.0) && (l_abastecido > 0.0) || (consumo_total > 0.0)) {
      printf("O consumo atual é de: %f \n", d_percorrida / l_abastecido);
      litros_total += l_abastecido;
      km_total += d_percorrida;
    }
  }
  printf("O consumo total é de: %f\n", km_total / litros_total);
}


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)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xor    %eax,%eax
movsd  0xe96(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x19(%rbp)
jne    1182 <main+0x62>
jp     1182 <main+0x62>
jmp    11a2 <main+0x82>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe6d(%rip),%xmm1
ucomisd %xmm1,%xmm0
setne  %al
setp   %cl
or     %cl,%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11b2 <main+0x92>
jmp    126f <main+0x14f>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe83(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe65(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    121a <main+0xfa>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
ja     1230 <main+0x110>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    126a <main+0x14a>
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe25(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1157 <main+0x37>
movss  -0x14(%rbp),%xmm0
divss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe02(%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,0x14(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xee9(%rip),%r14
lea    0xea8(%rip),%rbx
lea    0x10(%rsp),%r15
lea    0xf17(%rip),%r12
lea    0x14(%rsp),%r13
lea    0xe93(%rip),%rbp
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm1
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm1
movss  0x10(%rsp),%xmm0
jbe    1210 <main+0xe0>
ucomiss %xmm2,%xmm0
jbe    1210 <main+0xe0>
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x10(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
movss  0x14(%rsp),%xmm1
movss  0x8(%rsp),%xmm2
addss  %xmm1,%xmm2
movss  %xmm2,0x8(%rsp)
movss  0xde8(%rip),%xmm2
ucomiss %xmm2,%xmm1
jne    121f <main+0xef>
jnp    1231 <main+0x101>
movaps %xmm2,%xmm1
ucomiss %xmm2,%xmm0
jne    1190 <main+0x60>
jp     1190 <main+0x60>
movss  0x8(%rsp),%xmm0
divss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xddb(%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 = [66 x i8] c"informe quantos litros abasteceu(-1 para finalizar o programa): \0A\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [29 x i8] c"infome quantos km dirigiu: \0A\00"
@.str.3 = [28 x i8] c"O consumo atual \C3\A9 de: %f \0A\00"
@.str.4 = [27 x i8] c"O consumo total \C3\A9 de: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = 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
store float 0.000000e+00, float* %6
br label %7
7: ; preds = %45, %0
%8 = load float, float* %2
%9 = fpext float %8 to double
%10 = fcmp une double %9, -1.000000e+00
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load float, float* %3
%13 = fpext float %12 to double
%14 = fcmp une double %13, -1.000000e+00
br label %15
15: ; preds = %11, %7
%16 = phi i1 [ false, %7 ], [ %14, %11 ]
br i1 %16, label %17, label %46
17: ; preds = %15
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%22 = load float, float* %2
%23 = fpext float %22 to double
%24 = fcmp ogt double %23, 0.000000e+00
br i1 %24, label %25, label %29
25: ; preds = %17
%26 = load float, float* %3
%27 = fpext float %26 to double
%28 = fcmp ogt double %27, 0.000000e+00
br i1 %28, label %33, label %29
29: ; preds = %25, %17
%30 = load float, float* %4
%31 = fpext float %30 to double
%32 = fcmp ogt double %31, 0.000000e+00
br i1 %32, label %33, label %45
33: ; preds = %29, %25
%34 = load float, float* %2
%35 = load float, float* %3
%36 = fdiv float %34, %35
%37 = fpext float %36 to double
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), double %37)
%39 = load float, float* %3
%40 = load float, float* %6
%41 = fadd float %40, %39
store float %41, float* %6
%42 = load float, float* %2
%43 = load float, float* %5
%44 = fadd float %43, %42
store float %44, float* %5
br label %45
45: ; preds = %33, %29
br label %7
46: ; preds = %15
%47 = load float, float* %5
%48 = load float, float* %6
%49 = fdiv float %47, %48
%50 = fpext float %49 to double
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %50)
%52 = load i32, i32* %1
ret i32 %52
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%f\00"
@.str.3 = [28 x i8] c"O consumo atual \C3\A9 de: %f \0A\00"
@.str.4 = [27 x i8] c"O consumo total \C3\A9 de: %f\0A\00"
@str = [65 x i8] c"informe quantos litros abasteceu(-1 para finalizar o programa): \00"
@str.5 = [28 x i8] c"infome quantos km dirigiu: \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
br label %5
5: ; preds = %0, %25
%6 = phi float [ %29, %25 ], [ 0.000000e+00, %0 ]
%7 = phi float [ %28, %25 ], [ 0.000000e+00, %0 ]
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 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* %2)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.5, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%12 = load float, float* %1
%13 = fcmp ogt float %12, 0.000000e+00
%14 = load float, float* %2
%15 = fcmp ogt float %14, 0.000000e+00
%16 = select i1 %13, i1 %15, i1 false
br i1 %16, label %17, label %25
17: ; preds = %5
%18 = fdiv float %12, %14
%19 = fpext float %18 to double
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), double %19)
%21 = load float, float* %2
%22 = fadd float %6, %21
%23 = load float, float* %1
%24 = fadd float %7, %23
br label %25
25: ; preds = %5, %17
%26 = phi float [ %21, %17 ], [ %14, %5 ]
%27 = phi float [ %23, %17 ], [ %12, %5 ]
%28 = phi float [ %24, %17 ], [ %7, %5 ]
%29 = phi float [ %22, %17 ], [ %6, %5 ]
%30 = fcmp une float %27, -1.000000e+00
%31 = fcmp une float %26, -1.000000e+00
%32 = select i1 %30, i1 %31, i1 false
br i1 %32, label %5, label %33
33: ; preds = %25
%34 = fdiv float %28, %29
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %35)
ret i32 0
}