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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xebb(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeac(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movss  -0x18(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1150 <main+0x30>
movss  -0x18(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x18(%rbp),%xmm0
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
movss  -0x10(%rbp),%xmm0
lea    0xe5b(%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    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
lea    0xebe(%rip),%r14
lea    0x8(%rsp),%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
movss  %xmm0,0x4(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0x4(%rsp),%xmm0
add    $0x1,%ebp
addss  0x8(%rsp),%xmm0
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
jg     1150 <main+0x30>
cvtsi2ss %eax,%xmm1
movaps %xmm0,%xmm2
divss  %xmm1,%xmm2
movss  %xmm2,0x4(%rsp)
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
lea    0xe73(%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"%d\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [11 x i8] c"Sum: %.0f\0A\00"
@.str.3 = [11 x i8] c"Avg: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
store i32 0, i32* %2
store float 0.000000e+00, float* %6
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %8
8: ; preds = %15, %0
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %5)
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
store i32 %11, i32* %2
%12 = load float, float* %6
%13 = load float, float* %5
%14 = fadd float %12, %13
store float %14, float* %6
br label %15
15: ; preds = %8
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = icmp sgt i32 %16, %17
br i1 %18, label %8, label %19
19: ; preds = %15
%20 = load float, float* %6
%21 = load i32, i32* %3
%22 = sitofp i32 %21 to float
%23 = fdiv float %20, %22
store float %23, float* %4
%24 = load float, float* %6
%25 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float %24)
%26 = load float, float* %4
%27 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), float %26)
ret i32 0
}

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