#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, float);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num;
  scanf("%d", &num);
  int nmb;
  float sum = 0;
  for (int i = 1; i <= num; i++) {
    scanf("%d", &nmb);
    sum = sum + nmb;
  }
  float avg;
  avg = sum / num;
  printf("Sum: %.f\n Avg: %.2f", sum, 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    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     118b <main+0x6b>
lea    0xe9f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x10(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114e <main+0x2e>
movss  -0x10(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
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    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
xorps  %xmm0,%xmm0
test   %eax,%eax
jle    118f <main+0x6f>
xor    %ebp,%ebp
lea    0xeb3(%rip),%r14
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movss  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0xc(%rsp),%xmm1
addss  %xmm1,%xmm0
mov    0x4(%rsp),%eax
add    $0x1,%ebp
cmp    %eax,%ebp
jl     1160 <main+0x40>
cvtsi2ss %eax,%xmm2
movaps %xmm0,%xmm1
divss  %xmm2,%xmm1
lea    0xe62(%rip),%rdi
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"%d\00"
@.str.1 = [20 x i8] c"Sum: %.f\0A Avg: %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%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)
store float 0.000000e+00, float* %4
store i32 1, i32* %5
br label %8
8: ; preds = %18, %0
%9 = load i32, i32* %5
%10 = load i32, i32* %2
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %21
12: ; preds = %8
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%14 = load float, float* %4
%15 = load i32, i32* %3
%16 = sitofp i32 %15 to float
%17 = fadd float %14, %16
store float %17, float* %4
br label %18
18: ; preds = %12
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %8
21: ; preds = %8
%22 = load float, float* %4
%23 = load i32, i32* %2
%24 = sitofp i32 %23 to float
%25 = fdiv float %22, %24
store float %25, float* %6
%26 = load float, float* %4
%27 = load float, float* %6
%28 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), float %26, float %27)
ret i32 0
}

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