#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, u;
  float avg = 0, sum = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &u);
    sum = sum + u;
    avg = avg + u;
  }
  avg = avg / n;
  printf("Sum: %.0f\n", sum);
  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,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a6 <main+0x86>
lea    0xe97(%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)
movss  -0x14(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1156 <main+0x36>
movss  -0x14(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x18(%rbp),%xmm0
lea    0xe3e(%rip),%rdi
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
lea    0xe38(%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),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    119f <main+0x7f>
xor    %ebp,%ebp
xorps  %xmm0,%xmm0
lea    0xeb3(%rip),%r14
lea    0xc(%rsp),%rbx
xorps  %xmm1,%xmm1
cs nopw 0x0(%rax,%rax,1)
nop
movss  %xmm0,0x8(%rsp)
movss  %xmm1,(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movss  0x8(%rsp),%xmm0
movss  (%rsp),%xmm1
xorps  %xmm2,%xmm2
cvtsi2ssl 0xc(%rsp),%xmm2
addss  %xmm2,%xmm0
addss  %xmm2,%xmm1
add    $0x1,%ebp
mov    0x4(%rsp),%eax
cmp    %eax,%ebp
jl     1160 <main+0x40>
jmp    11a5 <main+0x85>
xorps  %xmm1,%xmm1
xorps  %xmm0,%xmm0
xorps  %xmm2,%xmm2
cvtsi2ss %eax,%xmm2
divss  %xmm2,%xmm1
movss  %xmm1,(%rsp)
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
lea    0xe46(%rip),%rdi
movss  (%rsp),%xmm0
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* %5
store float 0.000000e+00, float* %6
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %8
8: ; preds = %22, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %25
12: ; preds = %8
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%14 = load float, float* %6
%15 = load i32, i32* %4
%16 = sitofp i32 %15 to float
%17 = fadd float %14, %16
store float %17, float* %6
%18 = load float, float* %5
%19 = load i32, i32* %4
%20 = sitofp i32 %19 to float
%21 = fadd float %18, %20
store float %21, float* %5
br label %22
22: ; preds = %12
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %8
25: ; preds = %8
%26 = load float, float* %5
%27 = load i32, i32* %2
%28 = sitofp i32 %27 to float
%29 = fdiv float %26, %28
store float %29, float* %5
%30 = load float, float* %6
%31 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), float %30)
%32 = load float, float* %5
%33 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %32)
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)
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %0, %8
%9 = phi float [ %15, %8 ], [ 0.000000e+00, %0 ]
%10 = phi float [ %16, %8 ], [ 0.000000e+00, %0 ]
%11 = phi i32 [ %17, %8 ], [ 0, %0 ]
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = sitofp i32 %13 to float
%15 = fadd float %9, %14
%16 = fadd float %10, %14
%17 = add nuw nsw i32 %11, 1
%18 = load i32, i32* %1
%19 = icmp slt i32 %17, %18
br i1 %19, label %8, label %20
20: ; preds = %8, %0
%21 = phi float [ 0.000000e+00, %0 ], [ %16, %8 ]
%22 = phi float [ 0.000000e+00, %0 ], [ %15, %8 ]
%23 = phi i32 [ %6, %0 ], [ %18, %8 ]
%24 = sitofp i32 %23 to float
%25 = fdiv float %21, %24
%26 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), float %22)
%27 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %25)
ret i32 0
}