#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, long double *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *stdin;
int main(int argc, char *argv[]) {
  FILE *f;
  long double sum = 0, x = 0, n = -1;
  if (!(f = argc <= 1 ? stdin : fopen(argv[1], "r"))) {
    printf("Unable to open stream for reading.\n");
    return 1;
  }
  while (!feof(f)) {
    sum += x;
    n++;
    fscanf(f, "%Lf", &x);
  }
  printf("%.10Lg\n", sum / n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
fldz
fld    %st(0)
fstpt  -0x30(%rbp)
fstpt  -0x40(%rbp)
fld1
fchs
fstpt  -0x50(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     1184 <main+0x44>
mov    0x2e70(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    119c <main+0x5c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11c8 <main+0x88>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    123b <main+0xfb>
jmp    11cd <main+0x8d>
mov    -0x18(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11eb <main+0xab>
jmp    1219 <main+0xd9>
fldt   -0x40(%rbp)
fldt   -0x30(%rbp)
faddp  %st,%st(1)
fstpt  -0x30(%rbp)
fldt   -0x50(%rbp)
fld1
faddp  %st,%st(1)
fstpt  -0x50(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe1b(%rip),%rsi
lea    -0x40(%rbp),%rdx
call   1040 <fscanf@plt>
jmp    11cd <main+0x8d>
fldt   -0x30(%rbp)
fldt   -0x50(%rbp)
fdivrp %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xdfd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
fldz
fld    %st(0)
fstpt  0x40(%rsp)
cmp    $0x1,%edi
fstpt  0x1c(%rsp)
jg     1207 <main+0xb7>
mov    0x2e73(%rip),%rax
mov    (%rax),%rbx
test   %rbx,%rbx
je     1223 <main+0xd3>
mov    %rbx,%rdi
call   1060 <feof@plt>
fldt   0x1c(%rsp)
fld    %st(0)
fchs
test   %eax,%eax
jne    11f0 <main+0xa0>
fstp   %st(0)
fld1
fld    %st(0)
fstpt  0x28(%rsp)
fchs
lea    0xe5a(%rip),%r14
lea    0x40(%rsp),%r15
nopl   (%rax)
fldt   0x40(%rsp)
faddp  %st,%st(2)
fxch   %st(1)
fstpt  0x1c(%rsp)
fldt   0x28(%rsp)
faddp  %st,%st(1)
fstpt  0x34(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
fldt   0x34(%rsp)
fldt   0x1c(%rsp)
test   %eax,%eax
fxch   %st(1)
je     11b0 <main+0x60>
fdivrp %st,%st(1)
fldz
fxch   %st(1)
fstp   %st(1)
fstpt  (%rsp)
lea    0xe0a(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1234 <main+0xe4>
mov    0x8(%rsi),%rdi
lea    0xdee(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rbx,%rbx
jne    1181 <main+0x31>
lea    0xde4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@.str.1 = [36 x i8] c"Unable to open stream for reading.\0A\00"
@.str.2 = [4 x i8] c"%Lf\00"
@.str.3 = [8 x i8] c"%.10Lg\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca x86_fp80
%8 = alloca x86_fp80
%9 = alloca x86_fp80
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store x86_fp80 0xK00000000000000000000, x86_fp80* %7
store x86_fp80 0xK00000000000000000000, x86_fp80* %8
store x86_fp80 0xKBFFF8000000000000000, x86_fp80* %9
%10 = load i32, i32* %4
%11 = icmp sle i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i32*, i32** @stdin
br label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %14, %12
%20 = phi i32* [ %13, %12 ], [ %18, %14 ]
store i32* %20, i32** %6
%21 = icmp ne i32* %20, null
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %43
24: ; preds = %19
br label %25
25: ; preds = %30, %24
%26 = load i32*, i32** %6
%27 = call i32 @feof(i32* %26)
%28 = icmp ne i32 %27, 0
%29 = xor i1 %28, true
br i1 %29, label %30, label %38
30: ; preds = %25
%31 = load x86_fp80, x86_fp80* %8
%32 = load x86_fp80, x86_fp80* %7
%33 = fadd x86_fp80 %32, %31
store x86_fp80 %33, x86_fp80* %7
%34 = load x86_fp80, x86_fp80* %9
%35 = fadd x86_fp80 %34, 0xK3FFF8000000000000000
store x86_fp80 %35, x86_fp80* %9
%36 = load i32*, i32** %6
%37 = call i32 @fscanf(i32* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), x86_fp80* %8)
br label %25
38: ; preds = %25
%39 = load x86_fp80, x86_fp80* %7
%40 = load x86_fp80, x86_fp80* %9
%41 = fdiv x86_fp80 %39, %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), x86_fp80 %41)
store i32 0, i32* %3
br label %43
43: ; preds = %38, %22
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%Lf\00"
@.str.3 = [8 x i8] c"%.10Lg\0A\00"
@str = [35 x i8] c"Unable to open stream for reading.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca x86_fp80
%4 = bitcast x86_fp80* %3 to i8*
store x86_fp80 0xK00000000000000000000, x86_fp80* %3
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = load i32*, i32** @stdin
br label %12
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %8, %6
%13 = phi i32* [ %7, %6 ], [ %11, %8 ]
%14 = icmp eq i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = call i32 @feof(i32* %13)
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %31
18: ; preds = %12
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %34
20: ; preds = %15, %20
%21 = phi x86_fp80 [ %25, %20 ], [ 0xKBFFF8000000000000000, %15 ]
%22 = phi x86_fp80 [ %24, %20 ], [ 0xK00000000000000000000, %15 ]
%23 = load x86_fp80, x86_fp80* %3
%24 = fadd x86_fp80 %22, %23
%25 = fadd x86_fp80 %21, 0xK3FFF8000000000000000
%26 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), x86_fp80* %3)
%27 = call i32 @feof(i32* %13)
%28 = icmp eq i32 %27, 0
br i1 %28, label %20, label %29
29: ; preds = %20
%30 = fdiv x86_fp80 %24, %25
br label %31
31: ; preds = %29, %15
%32 = phi x86_fp80 [ %30, %29 ], [ 0xK80000000000000000000, %15 ]
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), x86_fp80 %32)
br label %34
34: ; preds = %31, %18
%35 = phi i32 [ 0, %31 ], [ 1, %18 ]
ret i32 %35
}