#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*/ file_header(int /*<<< orphan*/ *);
float file_next(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
double sqrt(float);
void file_read(FILE *file) {
  float time1;
  float time2;
  float diff;
  float mean;
  float var;
  float delta;
  int num;
  num = 0;
  var = 0.0f;
  mean = 0.0f;
  file_header(file);
  while (1) {
    time1 = file_next(file);
    if (time1 < 0)
      break;
    time2 = file_next(file);
    if (time2 < 0)
      break;
    diff = time2 - time1;
    num++;
    delta = diff - mean;
    mean += delta / num;
    var += delta * (diff - mean);
    printf("%f\n", diff);
  }
  printf("\n\n");
  printf("Mean:     %f\n", mean);
  printf("Std. Dev: %f\n", sqrt(var / (num - 1)));
}


x86 assembly (clang, -O0):
<file_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <file_header@plt>
mov    -0x8(%rbp),%rdi
call   1040 <file_next@plt>
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    118c <file_read+0x4c>
jmp    1228 <file_read+0xe8>
mov    -0x8(%rbp),%rdi
call   1040 <file_next@plt>
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    11ac <file_read+0x6c>
jmp    1228 <file_read+0xe8>
movss  -0x10(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movss  -0x14(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtsi2ssl -0x24(%rbp),%xmm1
divss  %xmm1,%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x20(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
subss  -0x18(%rbp),%xmm2
movss  -0x1c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdf1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    116c <file_read+0x2c>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdbd(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
call   1060 <sqrt@plt>
lea    0xda5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_read>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1060 <file_header@plt>
mov    %rbx,%rdi
call   1050 <file_next@plt>
movaps %xmm0,%xmm2
xor    %ebp,%ebp
xorps  %xmm1,%xmm1
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
ucomiss %xmm2,%xmm1
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
ja     1237 <file_read+0xe7>
xor    %ebp,%ebp
lea    0xe7a(%rip),%r14
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
movss  %xmm2,0xc(%rsp)
mov    %rbx,%rdi
call   1050 <file_next@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     1237 <file_read+0xe7>
add    $0x1,%ebp
xorps  %xmm1,%xmm1
cvtsi2ss %ebp,%xmm1
subss  0xc(%rsp),%xmm0
movaps %xmm0,%xmm2
movss  0x4(%rsp),%xmm4
subss  %xmm4,%xmm2
movaps %xmm2,%xmm3
divss  %xmm1,%xmm3
addss  %xmm3,%xmm4
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movss  %xmm4,0x4(%rsp)
subss  %xmm4,%xmm0
mulss  %xmm2,%xmm0
movss  0x8(%rsp),%xmm2
addss  %xmm0,%xmm2
movss  %xmm2,0x8(%rsp)
mov    %r14,%rdi
movaps %xmm1,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <file_next@plt>
movaps %xmm0,%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm2,%xmm0
jbe    11b0 <file_read+0x60>
lea    0xdd2(%rip),%rdi
call   1030 <puts@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb0(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0xffffffff,%ebp
xorps  %xmm1,%xmm1
cvtsi2ss %ebp,%xmm1
movss  0x8(%rsp),%xmm0
divss  %xmm1,%xmm0
call   1070 <sqrt@plt>
lea    0xd97(%rip),%rdi
mov    $0x1,%al
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%f\0A\00"
@.str.1 = [3 x i8] c"\0A\0A\00"
@.str.2 = [14 x i8] c"Mean: %f\0A\00"
@.str.3 = [14 x i8] c"Std. Dev: %f\0A\00"
define void @file_read(i32* %0) {
%2 = alloca i32*
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %9
store float 0.000000e+00, float* %7
store float 0.000000e+00, float* %6
%10 = load i32*, i32** %2
%11 = call i32 @file_header(i32* %10)
br label %12
12: ; preds = %1, %24
%13 = load i32*, i32** %2
%14 = call float @file_next(i32* %13)
store float %14, float* %3
%15 = load float, float* %3
%16 = fcmp olt float %15, 0.000000e+00
br i1 %16, label %17, label %18
17: ; preds = %12
br label %48
18: ; preds = %12
%19 = load i32*, i32** %2
%20 = call float @file_next(i32* %19)
store float %20, float* %4
%21 = load float, float* %4
%22 = fcmp olt float %21, 0.000000e+00
br i1 %22, label %23, label %24
23: ; preds = %18
br label %48
24: ; preds = %18
%25 = load float, float* %4
%26 = load float, float* %3
%27 = fsub float %25, %26
store float %27, float* %5
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
store i32 %29, i32* %9
%30 = load float, float* %5
%31 = load float, float* %6
%32 = fsub float %30, %31
store float %32, float* %8
%33 = load float, float* %8
%34 = load i32, i32* %9
%35 = sitofp i32 %34 to float
%36 = fdiv float %33, %35
%37 = load float, float* %6
%38 = fadd float %37, %36
store float %38, float* %6
%39 = load float, float* %8
%40 = load float, float* %5
%41 = load float, float* %6
%42 = fsub float %40, %41
%43 = load float, float* %7
%44 = call float @llvm.fmuladd.f32(float %39, float %42, float %43)
store float %44, float* %7
%45 = load float, float* %5
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %46)
br label %12
48: ; preds = %23, %17
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%50 = load float, float* %6
%51 = fpext float %50 to double
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %51)
%53 = load float, float* %7
%54 = load i32, i32* %9
%55 = sub nsw i32 %54, 1
%56 = sitofp i32 %55 to float
%57 = fdiv float %53, %56
%58 = call double @sqrt(float %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %58)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%f\0A\00"
@.str.2 = [14 x i8] c"Mean: %f\0A\00"
@.str.3 = [14 x i8] c"Std. Dev: %f\0A\00"
@str = [2 x i8] c"\0A\00"
define void @file_read(i32* %0) {
%2 = tail call i32 @file_header(i32* %0)
%3 = tail call float @file_next(i32* %0)
%4 = fcmp olt float %3, 0.000000e+00
br i1 %4, label %25, label %5
5: ; preds = %1, %12
%6 = phi float [ %23, %12 ], [ %3, %1 ]
%7 = phi i32 [ %14, %12 ], [ 0, %1 ]
%8 = phi float [ %18, %12 ], [ 0.000000e+00, %1 ]
%9 = phi float [ %20, %12 ], [ 0.000000e+00, %1 ]
%10 = tail call float @file_next(i32* %0)
%11 = fcmp olt float %10, 0.000000e+00
br i1 %11, label %25, label %12
12: ; preds = %5
%13 = fsub float %10, %6
%14 = add nuw nsw i32 %7, 1
%15 = fsub float %13, %8
%16 = sitofp i32 %14 to float
%17 = fdiv float %15, %16
%18 = fadd float %8, %17
%19 = fsub float %13, %18
%20 = tail call float @llvm.fmuladd.f32(float %15, float %19, float %9)
%21 = fpext float %13 to double
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %21)
%23 = tail call float @file_next(i32* %0)
%24 = fcmp olt float %23, 0.000000e+00
br i1 %24, label %25, label %5
25: ; preds = %12, %5, %1
%26 = phi float [ 0.000000e+00, %1 ], [ %9, %5 ], [ %20, %12 ]
%27 = phi float [ 0.000000e+00, %1 ], [ %8, %5 ], [ %18, %12 ]
%28 = phi i32 [ 0, %1 ], [ %7, %5 ], [ %14, %12 ]
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%30 = fpext float %27 to double
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %30)
%32 = add nsw i32 %28, -1
%33 = sitofp i32 %32 to float
%34 = fdiv float %26, %33
%35 = tail call double @sqrt(float %34)
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %35)
ret void
}