#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 = 0;
  int sum = 0;
  float avg = 0.0;
  int currentNumber = 0;
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &currentNumber);
    sum += currentNumber;
  }
  avg = (float)sum / n;
  printf("Sum: %d\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)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1196 <main+0x76>
lea    0xe8a(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1163 <main+0x43>
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
movss  -0x10(%rbp),%xmm0
lea    0xe46(%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
movl   $0x0,0xc(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xec7(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1190 <main+0x70>
xor    %ebp,%ebp
lea    0xea4(%rip),%r14
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    0x10(%rsp),%ebx
add    $0x1,%ebp
mov    0xc(%rsp),%eax
cmp    %eax,%ebp
jl     1170 <main+0x50>
cvtsi2ss %ebx,%xmm0
jmp    1193 <main+0x73>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm1
movaps %xmm0,%xmm2
divss  %xmm1,%xmm2
movss  %xmm2,0x14(%rsp)
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
lea    0xe55(%rip),%rdi
movss  0x14(%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 = [4 x i8] c"%d\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"Sum: %d\0A\00"
@.str.3 = [11 x i8] c"Avg: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store float 0.000000e+00, float* %4
store i32 0, i32* %5
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %6
br label %8
8: ; preds = %17, %0
%9 = load i32, i32* %6
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%14 = load i32, i32* %5
%15 = load i32, i32* %3
%16 = add nsw i32 %15, %14
store i32 %16, i32* %3
br label %17
17: ; preds = %12
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
br label %8
20: ; preds = %8
%21 = load i32, i32* %3
%22 = sitofp i32 %21 to float
%23 = load i32, i32* %2
%24 = sitofp i32 %23 to float
%25 = fdiv float %22, %24
store float %25, float* %4
%26 = load i32, i32* %3
%27 = sitofp i32 %26 to float
%28 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), float %27)
%29 = load float, float* %4
%30 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %29)
ret i32 0
}

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