#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 *, ...);
main() {
  float gMil = 0, gas = 0;
  int distance = 0, dTravel = 0;
  while (1) {
    printf("Enter gas mileage (-1, to end): ");
    scanf("%f", &gMil);
    if (gMil == -1)
      break;
    gas += gMil;
    printf("Enter the distance traveled: ");
    scanf("%d", &dTravel);
    distance += dTravel;
    printf("Fuel consumption for this refueling: %.4f\n",
           (float)dTravel / gMil);
  }
  printf("\n\nFuel consumption: %.4f", (float)distance / gas);
  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)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
movss  0xe86(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    118e <main+0x6e>
jp     118e <main+0x6e>
jmp    11e7 <main+0xc7>
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe94(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    114d <main+0x2d>
cvtsi2ssl -0x10(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe78(%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)
lea    0xec7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0xc(%rsp),%xmm0
ucomiss 0xe9c(%rip),%xmm0
jne    117d <main+0x5d>
jp     117d <main+0x5d>
movsd  0xe88(%rip),%xmm0
jmp    1239 <main+0x119>
xorps  %xmm1,%xmm1
lea    0x10(%rsp),%r12
lea    0xec5(%rip),%r13
lea    0xe79(%rip),%rbx
lea    0xe93(%rip),%rbp
lea    0xc(%rsp),%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
addss  %xmm0,%xmm1
movss  %xmm1,0x14(%rsp)
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe7f(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
add    %eax,%r15d
divss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0x14(%rsp),%xmm1
movss  0xc(%rsp),%xmm0
ucomiss 0xde3(%rip),%xmm0
jne    11b0 <main+0x90>
jp     11b0 <main+0x90>
xorps  %xmm0,%xmm0
cvtsi2ss %r15d,%xmm0
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3c(%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 = [33 x i8] c"Enter gas mileage (-1, to end): \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [30 x i8] c"Enter the distance traveled: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [43 x i8] c"Fuel consumption for this refueling: %.4f\0A\00"
@.str.5 = [25 x i8] c"\0A\0AFuel consumption: %.4f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store float 0.000000e+00, float* %2
store float 0.000000e+00, float* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %0, %12
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%9 = load float, float* %2
%10 = fcmp oeq float %9, -1.000000e+00
br i1 %10, label %11, label %12
11: ; preds = %6
br label %27
12: ; preds = %6
%13 = load float, float* %2
%14 = load float, float* %3
%15 = fadd float %14, %13
store float %15, float* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%18 = load i32, i32* %5
%19 = load i32, i32* %4
%20 = add nsw i32 %19, %18
store i32 %20, i32* %4
%21 = load i32, i32* %5
%22 = sitofp i32 %21 to float
%23 = load float, float* %2
%24 = fdiv float %22, %23
%25 = fpext float %24 to double
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), double %25)
br label %6
27: ; preds = %11
%28 = load i32, i32* %4
%29 = sitofp i32 %28 to float
%30 = load float, float* %3
%31 = fdiv float %29, %30
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), double %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Enter gas mileage (-1, to end): \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [30 x i8] c"Enter the distance traveled: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [43 x i8] c"Fuel consumption for this refueling: %.4f\0A\00"
@.str.5 = [25 x i8] c"\0A\0AFuel consumption: %.4f\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
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%7 = load float, float* %1
%8 = fcmp oeq float %7, -1.000000e+00
br i1 %8, label %31, label %9
9: ; preds = %0, %9
%10 = phi float [ %25, %9 ], [ %7, %0 ]
%11 = phi i32 [ %17, %9 ], [ 0, %0 ]
%12 = phi float [ %13, %9 ], [ 0.000000e+00, %0 ]
%13 = fadd float %12, %10
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
%17 = add nsw i32 %16, %11
%18 = sitofp i32 %16 to float
%19 = load float, float* %1
%20 = fdiv float %18, %19
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), double %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%25 = load float, float* %1
%26 = fcmp oeq float %25, -1.000000e+00
br i1 %26, label %27, label %9
27: ; preds = %9
%28 = sitofp i32 %17 to float
%29 = fdiv float %28, %13
%30 = fpext float %29 to double
br label %31
31: ; preds = %27, %0
%32 = phi double [ %30, %27 ], [ 0x7FF8000000000000, %0 ]
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), double %32)
ret i32 0
}