#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 */
float FLT_MAX;
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, float *);
int main() {
  float num;
  printf("Insira uma lista de números (para indicar o fim, basta C-D)\n");
  float min = FLT_MAX;
  float max = -FLT_MAX;
  float average = 0;
  int numberOfReads = 0;
  while (scanf("%f", &num) == 1) {
    if (num < min) {
      min = num;
    }
    if (num > max) {
      max = num;
    }
    average = average * numberOfReads + num;
    average /= ++numberOfReads;
  }
  printf("A média é %f, o máximo é %f e o mínimo é %f.\n", average, max, min);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2ea4(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    0x2e94(%rip),%rax
movss  (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xebe(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    1204 <main+0xe4>
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11af <main+0x8f>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    11c8 <main+0xa8>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x14(%rbp),%xmm0
cvtsi2ssl -0x18(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cvtsi2ss %eax,%xmm1
movss  -0x14(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1179 <main+0x59>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe1b(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
lea    0xf08(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e9d(%rip),%rax
movss  (%rax),%xmm1
movaps 0xeaa(%rip),%xmm0
movaps %xmm1,0x10(%rsp)
xorps  %xmm1,%xmm0
movaps %xmm0,0x20(%rsp)
lea    0xea6(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
cmp    $0x1,%eax
jne    120d <main+0xdd>
xorps  %xmm2,%xmm2
xor    %ebp,%ebp
lea    0xe84(%rip),%r14
lea    0x8(%rsp),%rbx
movaps 0x20(%rsp),%xmm1
movaps 0x10(%rsp),%xmm3
nopl   0x0(%rax,%rax,1)
movaps %xmm3,%xmm0
movss  0x8(%rsp),%xmm3
movaps %xmm3,%xmm4
minss  %xmm0,%xmm4
movaps %xmm4,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm3,%xmm0
maxss  %xmm1,%xmm3
movaps %xmm3,0x20(%rsp)
add    $0x1,%ebp
xorps  %xmm1,%xmm1
cvtsi2ss %ebp,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movaps 0x10(%rsp),%xmm3
movss  0xc(%rsp),%xmm2
movaps 0x20(%rsp),%xmm1
cmp    $0x1,%eax
je     11a0 <main+0x70>
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
movaps %xmm3,%xmm2
jmp    1217 <main+0xe7>
movaps 0x20(%rsp),%xmm1
movaps 0x10(%rsp),%xmm2
cvtss2sd %xmm1,%xmm1
cvtss2sd %xmm2,%xmm2
lea    0xded(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [62 x i8] c"Insira uma lista de n\C3\BAmeros (para indicar o fim, basta C-D)\0A\00"
@FLT_MAX = global float 0.000000e+00
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [52 x i8] c"A m\C3\A9dia \C3\A9 %f, o m\C3\A1ximo \C3\A9 %f e o m\C3\ADnimo \C3\A9 %f.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%8 = load float, float* @FLT_MAX
store float %8, float* %3
%9 = load float, float* @FLT_MAX
%10 = fneg float %9
store float %10, float* %4
store float 0.000000e+00, float* %5
store i32 0, i32* %6
br label %11
11: ; preds = %26, %0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %37
14: ; preds = %11
%15 = load float, float* %2
%16 = load float, float* %3
%17 = fcmp olt float %15, %16
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load float, float* %2
store float %19, float* %3
br label %20
20: ; preds = %18, %14
%21 = load float, float* %2
%22 = load float, float* %4
%23 = fcmp ogt float %21, %22
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = load float, float* %2
store float %25, float* %4
br label %26
26: ; preds = %24, %20
%27 = load float, float* %5
%28 = load i32, i32* %6
%29 = sitofp i32 %28 to float
%30 = load float, float* %2
%31 = call float @llvm.fmuladd.f32(float %27, float %29, float %30)
store float %31, float* %5
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
%34 = sitofp i32 %33 to float
%35 = load float, float* %5
%36 = fdiv float %35, %34
store float %36, float* %5
br label %11
37: ; preds = %11
%38 = load float, float* %5
%39 = fpext float %38 to double
%40 = load float, float* %4
%41 = fpext float %40 to double
%42 = load float, float* %3
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), double %39, double %41, double %43)
ret i32 0
}

LLVM IR (-O2):
@FLT_MAX = global float 0.000000e+00
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [52 x i8] c"A m\C3\A9dia \C3\A9 %f, o m\C3\A1ximo \C3\A9 %f e o m\C3\ADnimo \C3\A9 %f.\0A\00"
@str = [61 x i8] c"Insira uma lista de n\C3\BAmeros (para indicar o fim, basta C-D)\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
%4 = load float, float* @FLT_MAX
%5 = fneg float %4
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %27
8: ; preds = %0, %8
%9 = phi i32 [ %20, %8 ], [ 0, %0 ]
%10 = phi float [ %22, %8 ], [ 0.000000e+00, %0 ]
%11 = phi float [ %17, %8 ], [ %5, %0 ]
%12 = phi float [ %15, %8 ], [ %4, %0 ]
%13 = load float, float* %1
%14 = fcmp olt float %13, %12
%15 = select i1 %14, float %13, float %12
%16 = fcmp ogt float %13, %11
%17 = select i1 %16, float %13, float %11
%18 = sitofp i32 %9 to float
%19 = call float @llvm.fmuladd.f32(float %10, float %18, float %13)
%20 = add nuw nsw i32 %9, 1
%21 = sitofp i32 %20 to float
%22 = fdiv float %19, %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%24 = icmp eq i32 %23, 1
br i1 %24, label %8, label %25
25: ; preds = %8
%26 = fpext float %22 to double
br label %27
27: ; preds = %25, %0
%28 = phi float [ %4, %0 ], [ %15, %25 ]
%29 = phi float [ %5, %0 ], [ %17, %25 ]
%30 = phi double [ 0.000000e+00, %0 ], [ %26, %25 ]
%31 = fpext float %29 to double
%32 = fpext float %28 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), double %30, double %31, double %32)
ret i32 0
}