#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;
  int number;
  int sum;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &number);
    sum = sum + number;
  }
  printf("Sum: %d\n", sum);
  printf("Avg: %.2f\n", (float)sum / n);
  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,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1179 <main+0x59>
lea    0xea7(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1146 <main+0x26>
cvtsi2ssl -0x10(%rbp),%xmm0
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssl -0x10(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
lea    0xe6d(%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    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    116e <main+0x4e>
xor    %ebp,%ebp
lea    0xeb5(%rip),%r14
lea    0x14(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    0x14(%rsp),%ebx
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     1150 <main+0x30>
cvtsi2ss %ebx,%xmm0
jmp    1171 <main+0x51>
xorps  %xmm0,%xmm0
lea    0xe8b(%rip),%rdi
movss  %xmm0,0x10(%rsp)
call   1030 <printf@plt>
cvtsi2ssl 0xc(%rsp),%xmm1
movss  0x10(%rsp),%xmm0
divss  %xmm1,%xmm0
lea    0xe72(%rip),%rdi
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 = [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
store i32 0, i32* %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %5
br label %7
7: ; preds = %16, %0
%8 = load i32, i32* %5
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %19
11: ; preds = %7
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = add nsw i32 %13, %14
store i32 %15, i32* %4
br label %16
16: ; preds = %11
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %7
19: ; preds = %7
%20 = load i32, i32* %4
%21 = sitofp i32 %20 to float
%22 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float %21)
%23 = load i32, i32* %4
%24 = sitofp i32 %23 to float
%25 = load i32, i32* %2
%26 = sitofp i32 %25 to float
%27 = fdiv float %24, %26
%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 = [9 x i8] c"Sum: %d\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 %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 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float %11)
%13 = load i32, i32* %1
%14 = sitofp i32 %13 to float
%15 = fdiv float %11, %14
%16 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %15)
ret i32 0
17: ; preds = %0, %17
%18 = phi i32 [ %23, %17 ], [ 0, %0 ]
%19 = phi i32 [ %22, %17 ], [ undef, %0 ]
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, 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
}