#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, i, sum;
  float avr;
  scanf("%d", &n);
  scanf("%d", &a);
  sum = a;
  i = 1;
  do {
    scanf("%d", &a);
    sum = sum + a;
    i++;
  } while (i < n);
  avr = (float)sum / n;
  printf("\nSum: %d", sum);
  printf("\nAvg: %.2f", avr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec0(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xea3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     115c <main+0x3c>
cvtsi2ssl -0x14(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm0
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
lea    0xe4f(%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    0xed5(%rip),%r14
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0xc(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    $0x1,%ebx
mov    0xc(%rsp),%ebp
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    0xc(%rsp),%ebp
add    $0x1,%ebx
mov    0x14(%rsp),%eax
cmp    %eax,%ebx
jl     1160 <main+0x40>
cvtsi2ss %ebp,%xmm0
cvtsi2ss %eax,%xmm1
movaps %xmm0,%xmm2
divss  %xmm1,%xmm2
movss  %xmm2,0x10(%rsp)
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
lea    0xe67(%rip),%rdi
movss  0x10(%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"\0ASum: %d\00"
@.str.2 = [11 x i8] c"\0AAvg: %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
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)
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
store i32 %9, i32* %5
store i32 1, i32* %4
br label %10
10: ; preds = %17, %0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %5
%13 = load i32, i32* %3
%14 = add nsw i32 %12, %13
store i32 %14, i32* %5
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %17
17: ; preds = %10
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %10, label %21
21: ; preds = %17
%22 = load i32, i32* %5
%23 = sitofp i32 %22 to float
%24 = load i32, i32* %2
%25 = sitofp i32 %24 to float
%26 = fdiv float %23, %25
store float %26, float* %6
%27 = load i32, i32* %5
%28 = sitofp i32 %27 to float
%29 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float %28)
%30 = load float, float* %6
%31 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %30)
ret i32 0
}

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