#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, float *);
int main(int argc, char **argv) {
  FILE *fp;
  char line[1024];
  float timeVal;
  float max = 0;
  float min = 0;
  float total = 0;
  float num = 0;
  fp = fopen(argv[1], "r");
  if (!fp) {
    printf("Cannot open file %s\n", argv[1]);
    return 0;
  }
  while (NULL != fgets(line, 1024, fp)) {
    num++;
    sscanf(line, "%f\n", &timeVal);
    if (max == 0 || max < timeVal)
      max = timeVal;
    if (min == 0 || min > timeVal)
      min = timeVal;
    total += timeVal;
  }
  fclose(fp);
  printf("Max: %.6f  Min: %.6f  Avg: %.6f\n", max, min, total / (float)num);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x428(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0x42c(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0x430(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0x434(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe60(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11da <main+0x8a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1320 <main+0x1d0>
jmp    11df <main+0x8f>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     12dd <main+0x18d>
movss  0xdf6(%rip),%xmm0
addss  -0x434(%rbp),%xmm0
ff
movss  %xmm0,-0x434(%rbp)
ff
lea    -0x420(%rbp),%rdi
lea    0xdf3(%rip),%rsi
lea    -0x424(%rbp),%rdx
call   1060 <sscanf@plt>
movss  -0x428(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1253 <main+0x103>
jp     1253 <main+0x103>
jmp    126c <main+0x11c>
movss  -0x428(%rbp),%xmm1
ff
movss  -0x424(%rbp),%xmm0
ff
ucomiss %xmm1,%xmm0
jbe    127c <main+0x12c>
movss  -0x424(%rbp),%xmm0
ff
movss  %xmm0,-0x428(%rbp)
ff
movss  -0x42c(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    129b <main+0x14b>
jp     129b <main+0x14b>
jmp    12b0 <main+0x160>
movss  -0x42c(%rbp),%xmm0
ff
ucomiss -0x424(%rbp),%xmm0
jbe    12c0 <main+0x170>
movss  -0x424(%rbp),%xmm0
ff
movss  %xmm0,-0x42c(%rbp)
ff
movss  -0x424(%rbp),%xmm0
ff
addss  -0x430(%rbp),%xmm0
ff
movss  %xmm0,-0x430(%rbp)
ff
jmp    11df <main+0x8f>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movss  -0x428(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movss  -0x42c(%rbp),%xmm1
ff
cvtss2sd %xmm1,%xmm1
movss  -0x430(%rbp),%xmm2
ff
divss  -0x434(%rbp),%xmm2
ff
cvtss2sd %xmm2,%xmm2
lea    0xd06(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe98(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     128e <main+0x13e>
mov    %rax,%r15
lea    0x30(%rsp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     12a2 <main+0x152>
lea    0xe7c(%rip),%r14
lea    0x30(%rsp),%rbx
lea    0xc(%rsp),%r12
xorps  %xmm1,%xmm1
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
addss  0xe28(%rip),%xmm1
movss  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1060 <sscanf@plt>
movss  0xc(%rsp),%xmm0
movaps %xmm0,%xmm1
movaps 0x10(%rsp),%xmm4
maxss  %xmm4,%xmm1
xorps  %xmm3,%xmm3
cmpeqss %xmm3,%xmm4
movaps %xmm4,%xmm2
andnps %xmm1,%xmm2
andps  %xmm0,%xmm4
orps   %xmm2,%xmm4
movaps %xmm4,0x10(%rsp)
movaps %xmm0,%xmm1
movaps 0x20(%rsp),%xmm4
minss  %xmm4,%xmm1
cmpeqss %xmm3,%xmm4
movaps %xmm4,%xmm2
andnps %xmm1,%xmm2
andps  %xmm0,%xmm4
orps   %xmm2,%xmm4
movaps %xmm4,0x20(%rsp)
movss  0x4(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
movss  0x8(%rsp),%xmm1
test   %rax,%rax
jne    11d0 <main+0x80>
movaps 0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
movaps 0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x20(%rsp)
movss  0x4(%rsp),%xmm0
jmp    12ba <main+0x16a>
mov    0x8(%rbx),%rsi
lea    0xd6d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12f3 <main+0x1a3>
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
movsd  %xmm1,0x10(%rsp)
xorps  %xmm1,%xmm1
movsd  %xmm1,0x20(%rsp)
xorps  %xmm1,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,0x4(%rsp)
mov    %r15,%rdi
call   1030 <fclose@plt>
movss  0x4(%rsp),%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
lea    0xd3f(%rip),%rdi
movsd  0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
mov    $0x3,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x438,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [21 x i8] c"Cannot open file %s\0A\00"
@.str.2 = [4 x i8] c"%f\0A\00"
@.str.3 = [33 x i8] c"Max: %.6f Min: %.6f Avg: %.6f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [1024 x i8]
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store float 0.000000e+00, float* %9
store float 0.000000e+00, float* %10
store float 0.000000e+00, float* %11
store float 0.000000e+00, float* %12
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = icmp ne i32* %17, null
br i1 %18, label %24, label %19
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %22)
store i32 0, i32* %3
br label %68
24: ; preds = %2
br label %25
25: ; preds = %52, %24
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%27 = load i32*, i32** %6
%28 = call i32* @fgets(i8* %26, i32 1024, i32* %27)
%29 = icmp ne i32* null, %28
br i1 %29, label %30, label %56
30: ; preds = %25
%31 = load float, float* %12
%32 = fadd float %31, 1.000000e+00
store float %32, float* %12
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%34 = call i32 @sscanf(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %8)
%35 = load float, float* %9
%36 = fcmp oeq float %35, 0.000000e+00
br i1 %36, label %41, label %37
37: ; preds = %30
%38 = load float, float* %9
%39 = load float, float* %8
%40 = fcmp olt float %38, %39
br i1 %40, label %41, label %43
41: ; preds = %37, %30
%42 = load float, float* %8
store float %42, float* %9
br label %43
43: ; preds = %41, %37
%44 = load float, float* %10
%45 = fcmp oeq float %44, 0.000000e+00
br i1 %45, label %50, label %46
46: ; preds = %43
%47 = load float, float* %10
%48 = load float, float* %8
%49 = fcmp ogt float %47, %48
br i1 %49, label %50, label %52
50: ; preds = %46, %43
%51 = load float, float* %8
store float %51, float* %10
br label %52
52: ; preds = %50, %46
%53 = load float, float* %8
%54 = load float, float* %11
%55 = fadd float %54, %53
store float %55, float* %11
br label %25
56: ; preds = %25
%57 = load i32*, i32** %6
%58 = call i32 @fclose(i32* %57)
%59 = load float, float* %9
%60 = fpext float %59 to double
%61 = load float, float* %10
%62 = fpext float %61 to double
%63 = load float, float* %11
%64 = load float, float* %12
%65 = fdiv float %63, %64
%66 = fpext float %65 to double
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), double %60, double %62, double %66)
br label %68
68: ; preds = %56, %19
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [21 x i8] c"Cannot open file %s\0A\00"
@.str.2 = [4 x i8] c"%f\0A\00"
@.str.3 = [33 x i8] c"Max: %.6f Min: %.6f Avg: %.6f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca float
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = bitcast float* %4 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = call i32* @fgets(i8* %5, i32 1024, i32* %9)
%13 = icmp eq i32* %12, null
br i1 %13, label %39, label %17
14: ; preds = %2
%15 = load i8*, i8** %7
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %48
17: ; preds = %11, %17
%18 = phi float [ %22, %17 ], [ 0.000000e+00, %11 ]
%19 = phi float [ %33, %17 ], [ 0.000000e+00, %11 ]
%20 = phi float [ %32, %17 ], [ 0.000000e+00, %11 ]
%21 = phi float [ %28, %17 ], [ 0.000000e+00, %11 ]
%22 = fadd float %18, 1.000000e+00
%23 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), float* %4)
%24 = fcmp oeq float %21, 0.000000e+00
%25 = load float, float* %4
%26 = fcmp olt float %21, %25
%27 = select i1 %24, i1 true, i1 %26
%28 = select i1 %27, float %25, float %21
%29 = fcmp oeq float %20, 0.000000e+00
%30 = fcmp ogt float %20, %25
%31 = select i1 %29, i1 true, i1 %30
%32 = select i1 %31, float %25, float %20
%33 = fadd float %19, %25
%34 = call i32* @fgets(i8* %5, i32 1024, i32* %9)
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %17
36: ; preds = %17
%37 = fpext float %28 to double
%38 = fpext float %32 to double
br label %39
39: ; preds = %36, %11
%40 = phi double [ 0.000000e+00, %11 ], [ %37, %36 ]
%41 = phi double [ 0.000000e+00, %11 ], [ %38, %36 ]
%42 = phi float [ 0.000000e+00, %11 ], [ %33, %36 ]
%43 = phi float [ 0.000000e+00, %11 ], [ %22, %36 ]
%44 = call i32 @fclose(i32* %9)
%45 = fdiv float %42, %43
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), double %40, double %41, double %46)
br label %48
48: ; preds = %39, %14
ret i32 0
}