#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 *, float);
scalar_t__ scanf(char *, float *);
int main() {
  int t = 0;
  float sum = 0, n, ave;
  while (scanf("%f", &n)) {
    if (n < 0) {
      break;
    }
    t = t + 1;
    sum = sum + n;
  }
  ave = sum / t;
  printf("%0.2f\n", ave);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
lea    0xebb(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     1187 <main+0x67>
xorps  %xmm0,%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    116a <main+0x4a>
jmp    1187 <main+0x67>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    113e <main+0x1e>
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed9(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
movss  0xebf(%rip),%xmm1
test   %rax,%rax
je     11ac <main+0x8c>
movss  0x8(%rsp),%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm0,%xmm2
ja     11ac <main+0x8c>
xor    %ebp,%ebp
lea    0xeab(%rip),%r14
lea    0x8(%rsp),%rbx
xorps  %xmm1,%xmm1
cs nopw 0x0(%rax,%rax,1)
nop
addss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
add    $0x1,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movss  0xc(%rsp),%xmm1
test   %rax,%rax
je     11a1 <main+0x81>
movss  0x8(%rsp),%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm0,%xmm2
jbe    1170 <main+0x50>
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
divss  %xmm0,%xmm1
lea    0xe58(%rip),%rdi
movaps %xmm1,%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%f\00"
@.str.1 = [7 x i8] c"%0.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
store i32 0, i32* %2
store float 0.000000e+00, float* %3
br label %6
6: ; preds = %13, %0
%7 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %4)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = load float, float* %4
%11 = fcmp olt float %10, 0.000000e+00
br i1 %11, label %12, label %13
12: ; preds = %9
br label %19
13: ; preds = %9
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
%16 = load float, float* %3
%17 = load float, float* %4
%18 = fadd float %16, %17
store float %18, float* %3
br label %6
19: ; preds = %12, %6
%20 = load float, float* %3
%21 = load i32, i32* %2
%22 = sitofp i32 %21 to float
%23 = fdiv float %20, %22
store float %23, float* %5
%24 = load float, float* %5
%25 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
@.str.1 = [7 x i8] c"%0.2f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%4 = icmp eq i64 %3, 0
%5 = load float, float* %1
%6 = fcmp olt float %5, 0.000000e+00
%7 = select i1 %4, i1 true, i1 %6
br i1 %7, label %22, label %8
8: ; preds = %0, %8
%9 = phi float [ %16, %8 ], [ %5, %0 ]
%10 = phi i32 [ %12, %8 ], [ 0, %0 ]
%11 = phi float [ %13, %8 ], [ 0.000000e+00, %0 ]
%12 = add nuw nsw i32 %10, 1
%13 = fadd float %11, %9
%14 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%15 = icmp eq i64 %14, 0
%16 = load float, float* %1
%17 = fcmp olt float %16, 0.000000e+00
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %19, label %8
19: ; preds = %8
%20 = sitofp i32 %12 to float
%21 = fdiv float %13, %20
br label %22
22: ; preds = %19, %0
%23 = phi float [ %21, %19 ], [ 0x7FF8000000000000, %0 ]
%24 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float %23)
ret i32 0
}