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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xec2(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    118e <main+0x6e>
lea    0xe98(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x18(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114e <main+0x2e>
movss  -0x18(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x18(%rbp),%xmm0
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
movss  -0xc(%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
call   1040 <scanf@plt>
movss  0x8(%rsp),%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm2
jbe    1192 <main+0x72>
xorps  %xmm0,%xmm0
mov    $0x1,%ebp
lea    0xeaa(%rip),%r14
lea    0xc(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
movss  %xmm0,0x4(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movss  0x4(%rsp),%xmm0
addss  0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %ebp,%xmm1
movss  0x8(%rsp),%xmm2
add    $0x1,%ebp
ucomiss %xmm1,%xmm2
ja     1160 <main+0x40>
movaps %xmm0,%xmm1
divss  %xmm2,%xmm1
movss  %xmm1,0x4(%rsp)
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe5c(%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 = [11 x i8] c"Sum: %.0f\0A\00"
@.str.2 = [10 x i8] c"Avg: %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %6
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %4)
store i32 0, i32* %2
br label %8
8: ; preds = %18, %0
%9 = load i32, i32* %2
%10 = sitofp i32 %9 to float
%11 = load float, float* %4
%12 = fcmp olt float %10, %11
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %5)
%15 = load float, float* %6
%16 = load float, float* %5
%17 = fadd float %15, %16
store float %17, float* %6
br label %18
18: ; preds = %13
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
br label %8
21: ; preds = %8
%22 = load float, float* %6
%23 = load float, float* %4
%24 = fdiv float %22, %23
store float %24, float* %3
%25 = load float, float* %6
%26 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), float %25)
%27 = load float, float* %3
%28 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), float %27)
ret i32 0
}

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