#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);
scalar_t__ scanf(char *, int *);
int main() {
  int num, soma = 0, count = 0;
  while (scanf("%d", &num)) {
    if (num < 0)
      break;
    soma += num;
    count++;
  }
  printf("%d\n%.1f\n", soma, ((float)soma / count));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xebc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     117d <main+0x5d>
cmpl   $0x0,-0x8(%rbp)
jge    1166 <main+0x46>
jmp    117d <main+0x5d>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113d <main+0x1d>
mov    -0xc(%rbp),%esi
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xed2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
xor    %ebx,%ebx
xorps  %xmm1,%xmm1
test   %rax,%rax
je     1188 <main+0x68>
mov    0x4(%rsp),%eax
test   %eax,%eax
js     1188 <main+0x68>
xor    %ebp,%ebp
lea    0xead(%rip),%r14
lea    0x4(%rsp),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebx,%ecx
mov    %eax,%ebx
add    %ecx,%ebx
add    $0x1,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
test   %rax,%rax
je     1181 <main+0x61>
mov    0x4(%rsp),%eax
test   %eax,%eax
jns    1160 <main+0x40>
xorps  %xmm1,%xmm1
cvtsi2ss %ebp,%xmm1
cvtsi2ss %ebx,%xmm0
divss  %xmm1,%xmm0
lea    0xe6c(%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 = [9 x i8] c"%d\0A%.1f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %12, %0
%6 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8
br label %18
12: ; preds = %8
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = add nsw i32 %14, %13
store i32 %15, i32* %3
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
br label %5
18: ; preds = %11, %5
%19 = load i32, i32* %3
%20 = load i32, i32* %3
%21 = sitofp i32 %20 to float
%22 = load i32, i32* %4
%23 = sitofp i32 %22 to float
%24 = fdiv float %21, %23
%25 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %19, float %24)
ret i32 0
}

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