#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 i, sum = 0, cow, num;
  float avg;
  do {
    scanf("%d", &cow);
  } while (cow <= 0);
  for (i = 0; i != cow; i++) {
    scanf("\n%d", &num);
    sum = sum + num;
  }
  avg = (float)sum / cow;
  printf("\nSum: %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    0xec4(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jle    1136 <main+0x16>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     118a <main+0x6a>
lea    0xe96(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1157 <main+0x37>
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%esi
movss  -0x18(%rbp),%xmm0
lea    0xe58(%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    0xed3(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmpl   $0x0,(%rsp)
jle    1140 <main+0x20>
xor    %ebp,%ebp
lea    0xea6(%rip),%r14
lea    0x4(%rsp),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    0x4(%rsp),%ebx
add    $0x1,%ebp
cmp    (%rsp),%ebp
jne    1170 <main+0x50>
cvtsi2ss %ebp,%xmm1
cvtsi2ss %ebx,%xmm0
divss  %xmm1,%xmm0
lea    0xe6a(%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 = [4 x i8] c"\0A%d\00"
@.str.2 = [19 x i8] c"\0ASum: %d\0AAvg: %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
store i32 0, i32* %1
store i32 0, i32* %3
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* %4)
br label %9
9: ; preds = %7
%10 = load i32, i32* %4
%11 = icmp sle i32 %10, 0
br i1 %11, label %7, label %12
12: ; preds = %9
store i32 0, i32* %2
br label %13
13: ; preds = %22, %12
%14 = load i32, i32* %2
%15 = load i32, i32* %4
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%19 = load i32, i32* %3
%20 = load i32, i32* %5
%21 = add nsw i32 %19, %20
store i32 %21, i32* %3
br label %22
22: ; preds = %17
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %13
25: ; preds = %13
%26 = load i32, i32* %3
%27 = sitofp i32 %26 to float
%28 = load i32, i32* %4
%29 = sitofp i32 %28 to float
%30 = fdiv float %27, %29
store float %30, float* %6
%31 = load i32, i32* %3
%32 = load float, float* %6
%33 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %31, float %32)
ret i32 0
}

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