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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1180 <main+0x60>
lea    0xea0(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114d <main+0x2d>
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0xc(%rbp),%esi
movss  -0x14(%rbp),%xmm0
lea    0xe61(%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
push   %rax
lea    0xed2(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%eax
test   %eax,%eax
jle    116b <main+0x4b>
xor    %ebp,%ebp
lea    0xeba(%rip),%r14
lea    0x4(%rsp),%r15
xor    %ebx,%ebx
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    0x4(%rsp),%ebx
add    $0x1,%ebp
mov    (%rsp),%eax
cmp    %eax,%ebp
jl     1150 <main+0x30>
jmp    116d <main+0x4d>
xor    %ebx,%ebx
cvtsi2ss %ebx,%xmm0
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
lea    0xe83(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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