#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 main() {
  int i, a;
  float avg, n, sum;
  scanf("%f", &n);
  sum = 0;
  i = 1;
  do {
    scanf("%d", &a);
    sum = sum + a;
    i++;
  } while (i <= n);
  avg = sum / n;
  printf("Sum: %.0f\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)
lea    0xeca(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xeac(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x18(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jae    1150 <main+0x30>
movss  -0x18(%rbp),%xmm0
divss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x18(%rbp),%xmm0
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
movss  -0x10(%rbp),%xmm0
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%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
xor    %eax,%eax
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
mov    $0x2,%ebp
lea    0xeb9(%rip),%r14
lea    0xc(%rsp),%rbx
nop
movss  %xmm0,0x4(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0x4(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0xc(%rsp),%xmm1
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %ebp,%xmm1
movss  0x8(%rsp),%xmm2
add    $0x1,%ebp
ucomiss %xmm1,%xmm2
jae    1150 <main+0x30>
movaps %xmm0,%xmm1
divss  %xmm2,%xmm1
movss  %xmm1,0x4(%rsp)
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
lea    0xe66(%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"%f\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"Sum: %.0f\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 float
%6 = alloca float
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %5)
store float 0.000000e+00, float* %6
store i32 1, i32* %2
br label %8
8: ; preds = %16, %0
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = load float, float* %6
%11 = load i32, i32* %3
%12 = sitofp i32 %11 to float
%13 = fadd float %10, %12
store float %13, float* %6
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %16
16: ; preds = %8
%17 = load i32, i32* %2
%18 = sitofp i32 %17 to float
%19 = load float, float* %5
%20 = fcmp ole float %18, %19
br i1 %20, label %8, label %21
21: ; preds = %16
%22 = load float, float* %6
%23 = load float, float* %5
%24 = fdiv float %22, %23
store float %24, float* %4
%25 = load float, float* %6
%26 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %25)
%27 = load float, float* %4
%28 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %27)
ret i32 0
}

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