#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*/ _IONBF;
int /*<<< orphan*/ printf(char *, float);
int /*<<< orphan*/ scanf(char *, float *);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int main(void) {
  setvbuf(stdout, NULL, _IONBF, 0);
  int counter;
  float sum, avg, number = 0;
  while (number != 9999) {
    sum = sum + number;
    printf("Enter Number [%d]:", counter);
    scanf("%f", &number);
    counter++;
  }
  avg = sum / (counter - 1);
  printf("The average is :%.2f", avg);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1040 <setvbuf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  0xe8f(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1185 <main+0x55>
jp     1185 <main+0x55>
jmp    11c3 <main+0x93>
movss  -0xc(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1164 <main+0x34>
movss  -0xc(%rbp),%xmm0
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
lea    0xe33(%rip),%rdi
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   %rbx
sub    $0x18,%rsp
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
mov    0x2e9e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1040 <setvbuf@plt>
movl   $0x0,0xc(%rsp)
xorps  %xmm1,%xmm1
lea    0xe9d(%rip),%r14
lea    0xea9(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addss  %xmm1,%xmm0
movss  %xmm0,0x14(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
mov    %r14,%rdi
movss  %xmm0,0x10(%rsp)
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm0
add    $0x1,%ebp
movss  0xc(%rsp),%xmm1
ucomiss 0xe40(%rip),%xmm1
jne    1180 <main+0x50>
jp     1180 <main+0x50>
divss  0x10(%rsp),%xmm0
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@_IONBF = global i32 0
@.str = [19 x i8] c"Enter Number [%d]:\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [21 x i8] c"The average is :%.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
%6 = load i32, i32* @stdout
%7 = load i32, i32* @_IONBF
%8 = call i32 @setvbuf(i32 %6, i32* null, i32 %7, i32 0)
store float 0.000000e+00, float* %5
br label %9
9: ; preds = %12, %0
%10 = load float, float* %5
%11 = fcmp une float %10, 9.999000e+03
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = load float, float* %3
%14 = load float, float* %5
%15 = fadd float %13, %14
store float %15, float* %3
%16 = load i32, i32* %2
%17 = sitofp i32 %16 to float
%18 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), float %17)
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %5)
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %9
22: ; preds = %9
%23 = load float, float* %3
%24 = load i32, i32* %2
%25 = sub nsw i32 %24, 1
%26 = sitofp i32 %25 to float
%27 = fdiv float %23, %26
store float %27, float* %4
%28 = load float, float* %4
%29 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), float %28)
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@_IONBF = global i32 0
@.str = [19 x i8] c"Enter Number [%d]:\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [21 x i8] c"The average is :%.2f\00"
define i32 @main() {
%1 = alloca float
%2 = load i32, i32* @stdout
%3 = load i32, i32* @_IONBF
%4 = tail call i32 @setvbuf(i32 %2, i32* null, i32 %3, i32 0)
%5 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
br label %6
6: ; preds = %0, %6
%7 = phi i32 [ undef, %0 ], [ %14, %6 ]
%8 = phi float [ undef, %0 ], [ %10, %6 ]
%9 = phi float [ 0.000000e+00, %0 ], [ %15, %6 ]
%10 = fadd float %9, %8
%11 = sitofp i32 %7 to float
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), float %11)
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%14 = add nsw i32 %7, 1
%15 = load float, float* %1
%16 = fcmp une float %15, 9.999000e+03
br i1 %16, label %6, label %17
17: ; preds = %6
%18 = fdiv float %10, %11
%19 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), float %18)
ret i32 0
}