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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0x10(%rbp)
cvtsi2ssl -0x10(%rbp),%xmm1
movss  -0x18(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     118b <main+0x6b>
lea    0xe9a(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114f <main+0x2f>
cvtsi2ssl -0x8(%rbp),%xmm0
divss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xed3(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0xc(%rsp),%xmm1
xorps  %xmm0,%xmm0
ucomiss 0xeb3(%rip),%xmm1
jb     119d <main+0x7d>
mov    $0x2,%ebp
lea    0xeac(%rip),%r14
lea    0x14(%rsp),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
movss  0xc(%rsp),%xmm1
add    $0x1,%ebp
add    0x14(%rsp),%ebx
ucomiss %xmm0,%xmm1
jae    1170 <main+0x50>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movaps %xmm0,%xmm2
divss  %xmm1,%xmm2
movss  %xmm2,0x10(%rsp)
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
lea    0xe57(%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"%f\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [10 x i8] c"Sum: %d \0A\00"
@.str.3 = [12 x i8] c"Avg: %.2f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
store i32 0, i32* %2
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %6)
store i32 1, i32* %4
br label %8
8: ; preds = %18, %0
%9 = load i32, i32* %4
%10 = sitofp i32 %9 to float
%11 = load float, float* %6
%12 = fcmp ole float %10, %11
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = add nsw i32 %16, %15
store i32 %17, i32* %2
br label %18
18: ; preds = %13
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %8
21: ; preds = %8
%22 = load i32, i32* %2
%23 = sitofp i32 %22 to float
%24 = load float, float* %6
%25 = fdiv float %23, %24
store float %25, float* %5
%26 = load i32, i32* %2
%27 = sitofp i32 %26 to float
%28 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), float %27)
%29 = load float, float* %5
%30 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), float %29)
%31 = load i32, i32* %1
ret i32 %31
}

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