#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 *);
int main() {
  int n, sum = 0, tmp = 0, i;
  printf("Enter the total number of inputs : ");
  scanf("%d", &n);
  printf("\nEnter the numbers\n");
  for (i = 0; i < n; i++) {
    scanf("%d", &tmp);
    sum += tmp;
  }
  float avg = (float)sum / n;
  printf("\nAverage = %f\n", avg);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a3 <main+0x83>
lea    0xea1(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1170 <main+0x50>
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe75(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movl   $0x0,(%rsp)
lea    0xebb(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecf(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    119f <main+0x6f>
lea    0xeaa(%rip),%r14
mov    %rsp,%r15
xor    %ebx,%ebx
nop
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
add    (%rsp),%ebp
add    $0x1,%ebx
mov    0x4(%rsp),%eax
cmp    %eax,%ebx
jl     1180 <main+0x50>
cvtsi2ss %ebp,%xmm0
jmp    11a2 <main+0x72>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe72(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Enter the total number of inputs : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"\0AEnter the numbers\0A\00"
@.str.3 = [15 x i8] c"\0AAverage = %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 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), i32* %2)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %10
10: ; preds = %19, %0
%11 = load i32, i32* %5
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%16 = load i32, i32* %4
%17 = load i32, i32* %3
%18 = add nsw i32 %17, %16
store i32 %18, i32* %3
br label %19
19: ; preds = %14
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %10
22: ; preds = %10
%23 = load i32, i32* %3
%24 = sitofp i32 %23 to float
%25 = load i32, i32* %2
%26 = sitofp i32 %25 to float
%27 = fdiv float %24, %26
store float %27, float* %6
%28 = load float, float* %6
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %29)
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [36 x i8] c"Enter the total number of inputs : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [15 x i8] c"\0AAverage = %f\0A\00"
@str = [19 x i8] c"\0AEnter the numbers\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 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), i32* %1)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %0, %10
%11 = phi i32 [ %15, %10 ], [ 0, %0 ]
%12 = phi i32 [ %16, %10 ], [ 0, %0 ]
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = add nsw i32 %14, %11
%16 = add nuw nsw i32 %12, 1
%17 = load i32, i32* %1
%18 = icmp slt i32 %16, %17
br i1 %18, label %10, label %19
19: ; preds = %10
%20 = sitofp i32 %15 to float
br label %21
21: ; preds = %19, %0
%22 = phi float [ 0.000000e+00, %0 ], [ %20, %19 ]
%23 = phi i32 [ %8, %0 ], [ %17, %19 ]
%24 = sitofp i32 %23 to float
%25 = fdiv float %22, %24
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %26)
ret i32 0
}