#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 */
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, float *);
int main() {
  int count = 0;
  float comp, min, max, sum = 0;
  for (; scanf("%f", &comp) == 1; count++) {
    if (count == 0)
      min = max = comp;
    else {
      if (min > comp)
        min = comp;
      if (max < comp)
        max = comp;
    }
    sum += comp;
  }
  if (count == 0)
    printf("ERR: Empty file or invalid input\n");
  else
    printf("ELEMENTS: %d\nMIN:\t%f\nMAX:\t%f\nAVG:\t%f\n", count, min, max,
           sum / count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xebb(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11cd <main+0xad>
cmpl   $0x0,-0x8(%rbp)
jne    1175 <main+0x55>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  %xmm0,-0x10(%rbp)
jmp    11b0 <main+0x90>
movss  -0x10(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    118e <main+0x6e>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x14(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11ab <main+0x8b>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11b0 <main+0x90>
movss  -0xc(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113e <main+0x1e>
cmpl   $0x0,-0x8(%rbp)
jne    11ea <main+0xca>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121f <main+0xff>
mov    -0x8(%rbp),%esi
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x18(%rbp),%xmm2
cvtsi2ssl -0x8(%rbp),%xmm3
divss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe0d(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1202 <main+0xd2>
movss  0x4(%rsp),%xmm1
movss  %xmm1,0x8(%rsp)
xorps  %xmm0,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%rsp)
lea    0xe8e(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm1
mov    $0x1,%ebx
cmp    $0x1,%eax
jne    1210 <main+0xe0>
mov    $0x1,%ebx
lea    0xe64(%rip),%r14
lea    0x4(%rsp),%r15
movaps %xmm1,%xmm0
movss  (%rsp),%xmm3
nopl   0x0(%rax)
movss  0x4(%rsp),%xmm2
movaps %xmm2,%xmm4
minss  %xmm0,%xmm4
movss  %xmm4,0x8(%rsp)
addss  %xmm2,%xmm3
movss  %xmm3,(%rsp)
maxss  %xmm1,%xmm2
movss  %xmm2,0xc(%rsp)
add    $0x1,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm5
movss  0xc(%rsp),%xmm4
movss  (%rsp),%xmm3
movaps %xmm4,%xmm1
movaps %xmm5,%xmm0
cmp    $0x1,%eax
je     11b0 <main+0x80>
jmp    121b <main+0xeb>
lea    0xe20(%rip),%rdi
call   1030 <puts@plt>
jmp    124b <main+0x11b>
movaps %xmm1,%xmm5
movaps %xmm1,%xmm4
movss  (%rsp),%xmm3
xorps  %xmm2,%xmm2
cvtsi2ss %ebx,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm5,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm4,%xmm1
divss  %xmm2,%xmm3
xorps  %xmm2,%xmm2
cvtss2sd %xmm3,%xmm2
lea    0xdc1(%rip),%rdi
mov    %ebx,%esi
mov    $0x3,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%f\00"
@.str.1 = [34 x i8] c"ERR: Empty file or invalid input\0A\00"
@.str.2 = [38 x i8] c"ELEMENTS: %d\0AMIN:\09%f\0AMAX:\09%f\0AAVG:\09%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
store i32 0, i32* %2
store float 0.000000e+00, float* %6
br label %7
7: ; preds = %32, %0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %3)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %35
10: ; preds = %7
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = load float, float* %3
store float %14, float* %5
store float %14, float* %4
br label %28
15: ; preds = %10
%16 = load float, float* %4
%17 = load float, float* %3
%18 = fcmp ogt float %16, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load float, float* %3
store float %20, float* %4
br label %21
21: ; preds = %19, %15
%22 = load float, float* %5
%23 = load float, float* %3
%24 = fcmp olt float %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = load float, float* %3
store float %26, float* %5
br label %27
27: ; preds = %25, %21
br label %28
28: ; preds = %27, %13
%29 = load float, float* %3
%30 = load float, float* %6
%31 = fadd float %30, %29
store float %31, float* %6
br label %32
32: ; preds = %28
%33 = load i32, i32* %2
%34 = add nsw i32 %33, 1
store i32 %34, i32* %2
br label %7
35: ; preds = %7
%36 = load i32, i32* %2
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %52
40: ; preds = %35
%41 = load i32, i32* %2
%42 = load float, float* %4
%43 = fpext float %42 to double
%44 = load float, float* %5
%45 = fpext float %44 to double
%46 = load float, float* %6
%47 = load i32, i32* %2
%48 = sitofp i32 %47 to float
%49 = fdiv float %46, %48
%50 = fpext float %49 to double
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %41, double %43, double %45, double %50)
br label %52
52: ; preds = %40, %38
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
@.str.2 = [38 x i8] c"ELEMENTS: %d\0AMIN:\09%f\0AMAX:\09%f\0AAVG:\09%f\0A\00"
@str = [33 x i8] c"ERR: Empty file or invalid input\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %24
5: ; preds = %0
%6 = load float, float* %1
%7 = fadd float %6, 0.000000e+00
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %26
10: ; preds = %5, %10
%11 = phi float [ %20, %10 ], [ %7, %5 ]
%12 = phi float [ %19, %10 ], [ %6, %5 ]
%13 = phi float [ %17, %10 ], [ %6, %5 ]
%14 = phi i32 [ %21, %10 ], [ 1, %5 ]
%15 = load float, float* %1
%16 = fcmp ogt float %13, %15
%17 = select i1 %16, float %15, float %13
%18 = fcmp olt float %12, %15
%19 = select i1 %18, float %15, float %12
%20 = fadd float %11, %15
%21 = add nuw nsw i32 %14, 1
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%23 = icmp eq i32 %22, 1
br i1 %23, label %10, label %26
24: ; preds = %0
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %37
26: ; preds = %10, %5
%27 = phi i32 [ 1, %5 ], [ %21, %10 ]
%28 = phi float [ %6, %5 ], [ %17, %10 ]
%29 = phi float [ %6, %5 ], [ %19, %10 ]
%30 = phi float [ %7, %5 ], [ %20, %10 ]
%31 = fpext float %28 to double
%32 = fpext float %29 to double
%33 = sitofp i32 %27 to float
%34 = fdiv float %30, %33
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %27, double %31, double %32, double %35)
br label %37
37: ; preds = %26, %24
ret i32 0
}