#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 *, double);
scalar_t__ scanf(char *, double *);
int main() {
  double sal, avg;
  double sum = 0.0;
  int m = 0;
  while (scanf("%lf", &sal) != EOF) {
    sum += sal;
    m++;
  }
  avg = sum / m;
  printf("$%.2f\n", avg);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xebb(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e93(%rip),%rcx
cmp    (%rcx),%rax
je     117b <main+0x5b>
movsd  -0x10(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113e <main+0x1e>
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xed7(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x2ea6(%rip),%r15
cmp    (%r15),%rax
jne    1151 <main+0x31>
movsd  0xeb1(%rip),%xmm0
jmp    119d <main+0x7d>
xorpd  %xmm0,%xmm0
xor    %ebp,%ebp
lea    0xeaa(%rip),%r14
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
add    $0x1,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movsd  0x10(%rsp),%xmm0
cmp    (%r15),%rax
jne    1170 <main+0x50>
cvtsi2sd %ebp,%xmm1
divsd  %xmm1,%xmm0
lea    0xe68(%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 = [4 x i8] c"%lf\00"
@EOF = global i64 0
@.str.1 = [7 x i8] c"$%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store i32 0, i32* %1
store double 0.000000e+00, double* %4
store i32 0, i32* %5
br label %6
6: ; preds = %10, %0
%7 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %2)
%8 = load i64, i64* @EOF
%9 = icmp ne i64 %7, %8
br i1 %9, label %10, label %16
10: ; preds = %6
%11 = load double, double* %2
%12 = load double, double* %4
%13 = fadd double %12, %11
store double %13, double* %4
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
store i32 %15, i32* %5
br label %6
16: ; preds = %6
%17 = load double, double* %4
%18 = load i32, i32* %5
%19 = sitofp i32 %18 to double
%20 = fdiv double %17, %19
store double %20, double* %3
%21 = load double, double* %3
%22 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %21)
%23 = load i32, i32* %1
ret i32 %23
}

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