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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jl     1136 <main+0x16>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118a <main+0x6a>
lea    0xe96(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1157 <main+0x37>
cvtsi2ssl -0x10(%rbp),%xmm0
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssl -0x10(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
lea    0xe52(%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
sub    $0x18,%rsp
lea    0xecf(%rip),%r14
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1140 <main+0x20>
xor    %ebp,%ebp
lea    0xea5(%rip),%r14
lea    0x14(%rsp),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    0x14(%rsp),%ebx
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     1170 <main+0x50>
cvtsi2ss %ebx,%xmm0
movss  %xmm0,0x10(%rsp)
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssl 0xc(%rsp),%xmm1
movss  0x10(%rsp),%xmm0
divss  %xmm1,%xmm0
lea    0xe57(%rip),%rdi
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"%d\00"
@.str.1 = [9 x i8] c"Sum: %d\0A\00"
@.str.2 = [10 x i8] c"Avg: %.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* %4
br label %7
7: ; preds = %9, %0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %9
9: ; preds = %7
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 1
br i1 %11, label %7, label %12
12: ; preds = %9
store i32 0, i32* %6
br label %13
13: ; preds = %22, %12
%14 = load i32, i32* %6
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%19 = load i32, i32* %4
%20 = load i32, i32* %3
%21 = add nsw i32 %19, %20
store i32 %21, i32* %4
br label %22
22: ; preds = %17
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %13
25: ; preds = %13
%26 = load i32, i32* %4
%27 = sitofp i32 %26 to float
%28 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float %27)
%29 = load i32, i32* %4
%30 = sitofp i32 %29 to float
%31 = load i32, i32* %2
%32 = sitofp i32 %31 to float
%33 = fdiv float %30, %32
store float %33, float* %5
%34 = load float, float* %5
%35 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), float %34)
ret i32 0
}

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