#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, int, int);
scalar_t__ scanf(char *, int *, int *);
int main(void) {
  int price, amount, sum = 0, average = 0, count = 0;
  double temp;
  while (scanf("%d,%d", &price, &amount) != EOF) {
    sum += price * amount;
    average += amount;
    count++;
  }
  average = 1.0 * average / count + 0.5;
  printf("%d\n%d\n", sum, average);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xec5(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    0x2e89(%rip),%rcx
cmp    (%rcx),%rax
je     118c <main+0x6c>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1144 <main+0x24>
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xe6f(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe52(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe50(%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   %r13
push   %r12
push   %rbx
push   %rax
lea    0xed6(%rip),%rdi
lea    0x4(%rsp),%r15
mov    %rsp,%r12
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <scanf@plt>
xor    %ebx,%ebx
mov    0x2e9a(%rip),%r13
xor    %ebp,%ebp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
imul   %eax,%ecx
add    %ecx,%ebx
add    %eax,%r14d
add    $0x1,%ebp
lea    0xe8f(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <scanf@plt>
cmp    0x0(%r13),%rax
jne    1160 <main+0x40>
cvtsi2sd %r14d,%xmm0
cvtsi2sd %ebp,%xmm1
divsd  %xmm1,%xmm0
addsd  0xe61(%rip),%xmm0
cvttsd2si %xmm0,%edx
lea    0xe64(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d,%d\00"
@EOF = global i64 0
@.str.1 = [7 x i8] c"%d\0A%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %8
8: ; preds = %12, %0
%9 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%10 = load i64, i64* @EOF
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %23
12: ; preds = %8
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = mul nsw i32 %13, %14
%16 = load i32, i32* %4
%17 = add nsw i32 %16, %15
store i32 %17, i32* %4
%18 = load i32, i32* %3
%19 = load i32, i32* %5
%20 = add nsw i32 %19, %18
store i32 %20, i32* %5
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %8
23: ; preds = %8
%24 = load i32, i32* %5
%25 = sitofp i32 %24 to double
%26 = fmul double 1.000000e+00, %25
%27 = load i32, i32* %6
%28 = sitofp i32 %27 to double
%29 = fdiv double %26, %28
%30 = fadd double %29, 5.000000e-01
%31 = fptosi double %30 to i32
store i32 %31, i32* %5
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %32, i32 %33)
ret i32 0
}

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