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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1197 <main+0x77>
lea    0xe98(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1155 <main+0x35>
cvtsi2ssl -0x8(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
cvtsi2ssl -0x10(%rbp),%xmm0
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
lea    0xe45(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xecf(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
test   %eax,%eax
jle    119c <main+0x7c>
xorps  %xmm2,%xmm2
xor    %ebp,%ebp
lea    0xeb1(%rip),%r14
lea    0x14(%rsp),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movss  %xmm2,0xc(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
movss  0xc(%rsp),%xmm2
mov    0x14(%rsp),%eax
add    %eax,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  %xmm0,%xmm2
add    $0x1,%ebp
mov    0x10(%rsp),%eax
cmp    %eax,%ebp
jl     1160 <main+0x40>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
jmp    11a2 <main+0x82>
xorps  %xmm0,%xmm0
xorps  %xmm2,%xmm2
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm2
movss  %xmm2,0xc(%rsp)
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
lea    0xe49(%rip),%rdi
movss  0xc(%rsp),%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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