#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, a, broi = 0;
  float avg = 0, sum = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a);
    sum = sum + a;
    broi = broi + 1;
  }
  avg = sum / broi;
  printf("Sum: %.f\n", sum);
  printf("Avg: %.2f\n", avg);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11a3 <main+0x83>
lea    0xe90(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x1c(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <main+0x3d>
movss  -0x1c(%rbp),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x1c(%rbp),%xmm0
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%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    0x8(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    1196 <main+0x76>
xor    %ebp,%ebp
xorps  %xmm0,%xmm0
lea    0xeb4(%rip),%r14
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  %xmm0,0x4(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movss  0x4(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0xc(%rsp),%xmm1
addss  %xmm1,%xmm0
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jl     1160 <main+0x40>
xorps  %xmm1,%xmm1
cvtsi2ss %ebp,%xmm1
jmp    119c <main+0x7c>
xorps  %xmm1,%xmm1
xorps  %xmm0,%xmm0
movaps %xmm0,%xmm2
divss  %xmm1,%xmm2
movss  %xmm2,0x4(%rsp)
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
lea    0xe51(%rip),%rdi
movss  0x4(%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 = [10 x i8] c"Sum: %.f\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 i32
%6 = alloca float
%7 = alloca float
store i32 0, i32* %1
store i32 0, i32* %5
store float 0.000000e+00, float* %6
store float 0.000000e+00, float* %7
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %9
9: ; preds = %21, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%15 = load float, float* %7
%16 = load i32, i32* %4
%17 = sitofp i32 %16 to float
%18 = fadd float %15, %17
store float %18, float* %7
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %21
21: ; preds = %13
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %9
24: ; preds = %9
%25 = load float, float* %7
%26 = load i32, i32* %5
%27 = sitofp i32 %26 to float
%28 = fdiv float %25, %27
store float %28, float* %6
%29 = load float, float* %7
%30 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), float %29)
%31 = load float, float* %6
%32 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %31)
%33 = load i32, i32* %1
ret i32 %33
}

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