#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);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int a[20], n;
  float avg, sum = 0.0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum = sum + a[i];
  }
  printf("%f\n", sum);
  avg = sum / n;
  printf("%f", avg);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
xorps  %xmm0,%xmm0
movss  %xmm0,-0x5c(%rbp)
lea    0xec9(%rip),%rdi
lea    -0x54(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    1194 <main+0x74>
movslq -0x60(%rbp),%rax
lea    -0x50(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe97(%rip),%rdi
call   1040 <scanf@plt>
movss  -0x5c(%rbp),%xmm0
movslq -0x60(%rbp),%rax
cvtsi2ssl -0x50(%rbp,%rax,4),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x5c(%rbp)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1147 <main+0x27>
movss  -0x5c(%rbp),%xmm0
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
movss  -0x5c(%rbp),%xmm0
cvtsi2ssl -0x54(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x58(%rbp)
movss  -0x58(%rbp),%xmm0
lea    0xe43(%rip),%rdi
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
lea    0xed0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11a2 <main+0x82>
xorps  %xmm0,%xmm0
lea    0x10(%rsp),%rbx
xor    %r15d,%r15d
lea    0xead(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl (%rbx),%xmm0
movss  0x8(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
movss  0x8(%rsp),%xmm0
add    $0x1,%r15
movslq 0xc(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%r15
jl     1160 <main+0x40>
jmp    11a5 <main+0x85>
xorps  %xmm0,%xmm0
lea    0xe57(%rip),%rdi
movss  %xmm0,0x8(%rsp)
call   1030 <printf@plt>
xorps  %xmm1,%xmm1
cvtsi2ssl 0xc(%rsp),%xmm1
movss  0x8(%rsp),%xmm0
divss  %xmm1,%xmm0
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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