#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 *);
int main() {
  int n, i, m;
  float Avg, Sum;
  Sum = 0;
  i = 1;
  scanf("%d", &n);
  do {
    scanf("%d", &m);
    Sum = Sum + m;
    i++;
  } while (i <= n);
  printf("Sum: %.0f\n", Sum);
  Avg = Sum / n;
  printf("Avg: %.2f\n", Avg);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x1,-0xc(%rbp)
lea    0xebb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeab(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x18(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    114e <main+0x2e>
movss  -0x18(%rbp),%xmm0
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
lea    0xe58(%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    0xed1(%rip),%r14
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
xor    %ebp,%ebp
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
movss  %xmm0,0x4(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl 0xc(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x4(%rsp),%xmm0
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jl     1150 <main+0x30>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
xorps  %xmm1,%xmm1
cvtsi2ssl 0x8(%rsp),%xmm1
movss  0x4(%rsp),%xmm0
divss  %xmm1,%xmm0
lea    0xe5f(%rip),%rdi
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"%d\00"
@.str.1 = [11 x i8] c"Sum: %.0f\0A\00"
@.str.2 = [11 x i8] c"Avg: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %6
store i32 1, i32* %3
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %16, %0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%10 = load float, float* %6
%11 = load i32, i32* %4
%12 = sitofp i32 %11 to float
%13 = fadd float %10, %12
store float %13, float* %6
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %16
16: ; preds = %8
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = icmp sle i32 %17, %18
br i1 %19, label %8, label %20
20: ; preds = %16
%21 = load float, float* %6
%22 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), float %21)
%23 = load float, float* %6
%24 = load i32, i32* %2
%25 = sitofp i32 %24 to float
%26 = fdiv float %23, %25
store float %26, float* %5
%27 = load float, float* %5
%28 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %27)
ret i32 0
}

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