#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 */
double atof(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ get_line(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, double, char, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  char delimiter;
  char value_string[128];
  int count = 0;
  double sum = 0.0;
  double value;
  double average;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s delimiter\n", argv[0]);
    exit(1);
  }
  delimiter = *argv[1];
  while (get_line(value_string, stdin)) {
    if (!*value_string)
      continue;
    count++;
    value = atof(value_string);
    if (count == 1) {
      sum = value;
      printf("%.3lf%c\n", value, delimiter);
      continue;
    }
    sum += atof(value_string);
    average = sum / (double)count;
    printf("%.3lf%c%.3lf\n", value, delimiter, average);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xa4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
cmpl   $0x2,-0x8(%rbp)
je     11ae <main+0x5e>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe61(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
lea    -0xa0(%rbp),%rdi
mov    0x2e1f(%rip),%rax
mov    (%rax),%esi
call   1040 <get_line@plt>
cmp    $0x0,%rax
je     12ac <main+0x15c>
cmpb   $0x0,-0xa0(%rbp)
jne    11ec <main+0x9c>
jmp    11bb <main+0x6b>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
lea    -0xa0(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0xb8(%rbp)
ff
cmpl   $0x1,-0xa4(%rbp)
jne    124b <main+0xfb>
movsd  -0xb8(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb8(%rbp),%xmm0
ff
lea    0xdda(%rip),%rdi
movsbl -0x11(%rbp),%esi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    11bb <main+0x6b>
lea    -0xa0(%rbp),%rdi
call   1030 <atof@plt>
addsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
cvtsi2sdl -0xa4(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0xb8(%rbp),%xmm0
ff
mov    -0x11(%rbp),%al
movsd  -0xc0(%rbp),%xmm1
ff
lea    0xd81(%rip),%rdi
movsbl %al,%esi
mov    $0x2,%al
call   1050 <printf@plt>
jmp    11bb <main+0x6b>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
cmp    $0x2,%edi
jne    1222 <main+0xd2>
mov    0x8(%rsi),%rax
xor    %r13d,%r13d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x2e66(%rip),%rbp
lea    0x10(%rsp),%rbx
movsbl (%rax),%r12d
lea    0xe83(%rip),%r14
lea    0xe85(%rip),%r15
nopl   0x0(%rax)
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     120e <main+0xbe>
cmpb   $0x0,0x10(%rsp)
je     11a0 <main+0x50>
mov    %rbx,%rdi
call   1030 <atof@plt>
test   %r13d,%r13d
je     11f3 <main+0xa3>
add    $0x1,%r13d
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm2,%xmm2
cvtsi2sd %r13d,%xmm2
movsd  %xmm1,0x8(%rsp)
divsd  %xmm2,%xmm1
mov    %r15,%rdi
mov    %r12d,%esi
mov    $0x2,%al
call   1050 <printf@plt>
jmp    11a0 <main+0x50>
mov    %r14,%rdi
mov    %r12d,%esi
mov    $0x1,%al
movsd  %xmm0,0x8(%rsp)
call   1050 <printf@plt>
mov    $0x1,%r13d
jmp    11a0 <main+0x50>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xdcb(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"Usage: %s delimiter\0A\00"
@stdin = global i32 0
@.str.1 = [9 x i8] c"%.3lf%c\0A\00"
@.str.2 = [14 x i8] c"%.3lf%c%.3lf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca [128 x i8]
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store double 0.000000e+00, double* %9
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = load i8, i8* %24
store i8 %25, i8* %6
br label %26
26: ; preds = %48, %43, %35, %21
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%28 = load i32, i32* @stdin
%29 = call i64 @get_line(i8* %27, i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %61
31: ; preds = %26
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%33 = load i8, i8* %32
%34 = icmp ne i8 %33, 0
br i1 %34, label %36, label %35
35: ; preds = %31
br label %26
36: ; preds = %31
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
%39 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%40 = call double @atof(i8* %39)
store double %40, double* %10
%41 = load i32, i32* %8
%42 = icmp eq i32 %41, 1
br i1 %42, label %43, label %48
43: ; preds = %36
%44 = load double, double* %10
store double %44, double* %9
%45 = load double, double* %10
%46 = load i8, i8* %6
%47 = call i32 (i8*, double, i8, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double %45, i8 signext %46)
br label %26
48: ; preds = %36
%49 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%50 = call double @atof(i8* %49)
%51 = load double, double* %9
%52 = fadd double %51, %50
store double %52, double* %9
%53 = load double, double* %9
%54 = load i32, i32* %8
%55 = sitofp i32 %54 to double
%56 = fdiv double %53, %55
store double %56, double* %11
%57 = load double, double* %10
%58 = load i8, i8* %6
%59 = load double, double* %11
%60 = call i32 (i8*, double, i8, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %57, i8 signext %58, double %59)
br label %26
61: ; preds = %26
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Usage: %s delimiter\0A\00"
@stdin = global i32 0
@.str.1 = [9 x i8] c"%.3lf%c\0A\00"
@.str.2 = [14 x i8] c"%.3lf%c%.3lf\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = load i8, i8* %13
br label %15
15: ; preds = %31, %11
%16 = phi double [ 0.000000e+00, %11 ], [ %32, %31 ]
%17 = phi i32 [ 0, %11 ], [ %33, %31 ]
br label %18
18: ; preds = %15, %22
%19 = load i32, i32* @stdin
%20 = call i64 @get_line(i8* %4, i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %39, label %22
22: ; preds = %18
%23 = load i8, i8* %4
%24 = icmp eq i8 %23, 0
br i1 %24, label %18, label %25
25: ; preds = %22
%26 = add nsw i32 %17, 1
%27 = call double @atof(i8* %4)
%28 = icmp eq i32 %17, 0
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = call i32 (i8*, double, i8, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double %27, i8 signext %14)
br label %31
31: ; preds = %29, %34
%32 = phi double [ %35, %34 ], [ %27, %29 ]
%33 = phi i32 [ %26, %34 ], [ 1, %29 ]
br label %15
34: ; preds = %25
%35 = fadd double %16, %27
%36 = sitofp i32 %26 to double
%37 = fdiv double %35, %36
%38 = call i32 (i8*, double, i8, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %27, i8 signext %14, double %37)
br label %31
39: ; preds = %18
ret i32 0
}