#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 gallons;
  float miles;
  float summ = 0;
  float j = 0;
  float sumg = 0;
  printf("Enter the gallons used (-1 to end): ");
  scanf("%f", &gallons);
  printf("Enter the miles driven: ");
  scanf("%f", &miles);
  while (gallons != (-1)) {
    printf("The miles / gallon for this tank was %f\n\n", miles / gallons);
    summ += miles;
    sumg += gallons;
    printf("Enter the gallons used (-1 to end): ");
    scanf("%f", &gallons);
    if (gallons != -1) {
      printf("Enter the miles driven: ");
      scanf("%f", &miles);
    }
  }
  printf("The overall average miles/gallon was %f\n", summ / sumg);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
movss  0xe70(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    11a4 <main+0x84>
jp     11a4 <main+0x84>
jmp    1240 <main+0x120>
movss  -0xc(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe8c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe36(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
movss  0xdf7(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    121d <main+0xfd>
jp     121d <main+0xfd>
jmp    123b <main+0x11b>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf7(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1183 <main+0x63>
movss  -0x10(%rbp),%xmm0
divss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe1a(%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
lea    0xed7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeee(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xedd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
movss  0x8(%rsp),%xmm0
ucomiss 0xe90(%rip),%xmm0
jne    1180 <main+0x60>
jnp    1265 <main+0x145>
xorps  %xmm1,%xmm1
movss  %xmm1,0x10(%rsp)
lea    0xebd(%rip),%r14
lea    0xe75(%rip),%r15
lea    0xe93(%rip),%rbx
lea    0x8(%rsp),%r12
lea    0xe8a(%rip),%r13
lea    0x14(%rsp),%rbp
xorps  %xmm1,%xmm1
movss  %xmm1,0xc(%rsp)
nopl   0x0(%rax,%rax,1)
movss  0x14(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  0xc(%rsp),%xmm0
addss  0x14(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x10(%rsp),%xmm0
addss  0x8(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
movss  0x8(%rsp),%xmm0
ucomiss 0xde7(%rip),%xmm0
jne    1225 <main+0x105>
jnp    1253 <main+0x133>
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <scanf@plt>
movss  0x8(%rsp),%xmm0
ucomiss 0xdc1(%rip),%xmm0
jne    11c0 <main+0xa0>
jp     11c0 <main+0xa0>
movss  0xc(%rsp),%xmm0
divss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
jmp    126d <main+0x14d>
movsd  0xd93(%rip),%xmm0
lea    0xe03(%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 = [37 x i8] c"Enter the gallons used (-1 to end): \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [25 x i8] c"Enter the miles driven: \00"
@.str.3 = [42 x i8] c"The miles / gallon for this tank was %f\0A\0A\00"
@.str.4 = [41 x i8] c"The overall average miles/gallon was %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* %4
store float 0.000000e+00, float* %5
store float 0.000000e+00, float* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 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* %2)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
br label %11
11: ; preds = %33, %0
%12 = load float, float* %2
%13 = fcmp une float %12, -1.000000e+00
br i1 %13, label %14, label %34
14: ; preds = %11
%15 = load float, float* %3
%16 = load float, float* %2
%17 = fdiv float %15, %16
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), double %18)
%20 = load float, float* %3
%21 = load float, float* %4
%22 = fadd float %21, %20
store float %22, float* %4
%23 = load float, float* %2
%24 = load float, float* %6
%25 = fadd float %24, %23
store float %25, float* %6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%28 = load float, float* %2
%29 = fcmp une float %28, -1.000000e+00
br i1 %29, label %30, label %33
30: ; preds = %14
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
br label %33
33: ; preds = %30, %14
br label %11
34: ; preds = %11
%35 = load float, float* %4
%36 = load float, float* %6
%37 = fdiv float %35, %36
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), double %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"Enter the gallons used (-1 to end): \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [25 x i8] c"Enter the miles driven: \00"
@.str.3 = [42 x i8] c"The miles / gallon for this tank was %f\0A\0A\00"
@.str.4 = [41 x i8] c"The overall average miles/gallon was %f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 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* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%9 = load float, float* %1
%10 = fcmp une float %9, -1.000000e+00
br i1 %10, label %11, label %35
11: ; preds = %0, %27
%12 = phi float [ %30, %27 ], [ %9, %0 ]
%13 = phi float [ %22, %27 ], [ 0.000000e+00, %0 ]
%14 = phi float [ %20, %27 ], [ 0.000000e+00, %0 ]
%15 = load float, float* %2
%16 = fdiv float %15, %12
%17 = fpext float %16 to double
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), double %17)
%19 = load float, float* %2
%20 = fadd float %14, %19
%21 = load float, float* %1
%22 = fadd float %13, %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @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 une float %25, -1.000000e+00
br i1 %26, label %27, label %32
27: ; preds = %11
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%30 = load float, float* %1
%31 = fcmp une float %30, -1.000000e+00
br i1 %31, label %11, label %32
32: ; preds = %11, %27
%33 = fdiv float %20, %22
%34 = fpext float %33 to double
br label %35
35: ; preds = %32, %0
%36 = phi double [ %34, %32 ], [ 0x7FF8000000000000, %0 ]
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), double %36)
ret i32 0
}