#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 *, ...);
int main() {
  int n, i;
  float num[100], sum = 0.0, average;
  printf("Enter the numbers of data: ");
  scanf("%d", &n);
  while (n > 100 || n <= 0) {
    printf("Error! number should in range of (1 to 100).\n");
    printf("Enter the number again: ");
    scanf("%d", &n);
  }
  for (i = 0; i < n; ++i) {
    printf("%d. Enter number: ", i + 1);
    scanf("%f", &num[i]);
    sum += num[i];
  }
  average = sum / n;
  printf("Average = %.2f", average);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1a4(%rbp)
ff
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x64,-0x8(%rbp)
mov    %al,-0x1a9(%rbp)
jg     117c <main+0x5c>
cmpl   $0x0,-0x8(%rbp)
setle  %al
mov    %al,-0x1a9(%rbp)
mov    -0x1a9(%rbp),%al
test   $0x1,%al
jne    118f <main+0x6f>
jmp    11c2 <main+0xa2>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6a(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    115d <main+0x3d>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1234 <main+0x114>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xc(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movslq -0xc(%rbp),%rax
movss  -0x1a0(%rbp,%rax,4),%xmm0
ff ff
addss  -0x1a4(%rbp),%xmm0
ff
movss  %xmm0,-0x1a4(%rbp)
ff
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c9 <main+0xa9>
movss  -0x1a4(%rbp),%xmm0
ff
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1a8(%rbp)
ff
movss  -0x1a8(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xe1c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec9(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
add    $0xffffff9b,%eax
cmp    $0xffffff9b,%eax
ja     11bb <main+0x8b>
lea    0xeeb(%rip),%r14
lea    0xea6(%rip),%r15
lea    0xe9c(%rip),%r12
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
add    $0xffffff9b,%eax
cmp    $0xffffff9c,%eax
jb     1190 <main+0x60>
xorps  %xmm1,%xmm1
lea    0x10(%rsp),%r12
lea    0xe6e(%rip),%r14
lea    0xe7a(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  %xmm1,0xc(%rsp)
add    $0x1,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm1
addss  (%r12),%xmm1
movslq 0x8(%rsp),%rax
add    $0x4,%r12
cmp    %rax,%rbx
jl     11e0 <main+0xb0>
cvtsi2ss %eax,%xmm0
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe1b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Enter the numbers of data: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [46 x i8] c"Error! number should in range of (1 to 100).\0A\00"
@.str.3 = [25 x i8] c"Enter the number again: \00"
@.str.4 = [19 x i8] c"%d. Enter number: \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [15 x i8] c"Average = %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x float]
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 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), i32* %2)
br label %9
9: ; preds = %17, %0
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 100
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp sle i32 %13, 0
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ true, %9 ], [ %14, %12 ]
br i1 %16, label %17, label %21
17: ; preds = %15
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %9
21: ; preds = %15
store i32 0, i32* %3
br label %22
22: ; preds = %40, %21
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %43
26: ; preds = %22
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [100 x float], [100 x float]* %4, i64 0, i64 %31
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %32)
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [100 x float], [100 x float]* %4, i64 0, i64 %35
%37 = load float, float* %36
%38 = load float, float* %5
%39 = fadd float %38, %37
store float %39, float* %5
br label %40
40: ; preds = %26
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %22
43: ; preds = %22
%44 = load float, float* %5
%45 = load i32, i32* %2
%46 = sitofp i32 %45 to float
%47 = fdiv float %44, %46
store float %47, float* %6
%48 = load float, float* %6
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), double %49)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Enter the numbers of data: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [25 x i8] c"Enter the number again: \00"
@.str.4 = [19 x i8] c"%d. Enter number: \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [15 x i8] c"Average = %.2f\00"
@str = [45 x i8] c"Error! number should in range of (1 to 100).\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x float]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [100 x float]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 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), i32* %1)
%7 = load i32, i32* %1
%8 = add i32 %7, -101
%9 = icmp ult i32 %8, -100
br i1 %9, label %10, label %17
10: ; preds = %0, %10
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
%15 = add i32 %14, -101
%16 = icmp ult i32 %15, -100
br i1 %16, label %10, label %17
17: ; preds = %10, %0
br label %18
18: ; preds = %17, %18
%19 = phi i64 [ %21, %18 ], [ 0, %17 ]
%20 = phi float [ %27, %18 ], [ 0.000000e+00, %17 ]
%21 = add nuw nsw i64 %19, 1
%22 = trunc i64 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [100 x float], [100 x float]* %2, i64 0, i64 %19
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %24)
%26 = load float, float* %24
%27 = fadd float %20, %26
%28 = load i32, i32* %1
%29 = sext i32 %28 to i64
%30 = icmp slt i64 %21, %29
br i1 %30, label %18, label %31
31: ; preds = %18
%32 = sitofp i32 %28 to float
%33 = fdiv float %27, %32
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), double %34)
ret i32 0
}