#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*/ bubble_sort(double *, int);
double histograma(int *, double *, int);
int /*<<< orphan*/ histograma_vertical(double, int *);
int /*<<< orphan*/ media_acima_media(double, double *, int);
int /*<<< orphan*/ popular_aux(int *, double *, int);
int /*<<< orphan*/ printf(char *, double, ...);
scalar_t__ scanf(char *, double *);
int main() {
  int n = 0;
  double t[20000], med, min = 100, max = -100, soma = 0;
  ;
  while (n < 20000 && scanf("%lf", &t[n]) > 0) {
    if (t[n] > max)
      max = t[n];
    else if (t[n] < min)
      min = t[n];
    soma += t[n++];
  }
  med = soma / n;
  printf("med = %.3lf, min = %.3lf, max = %.3lf\n", med, min, max);
  bubble_sort(t, n);
  printf("Média das temperaturas acima da média: %.3lf\n",
         media_acima_media(med, t, n));
  int aux[20];
  popular_aux(aux, t, n);
  double max_aux = histograma(aux, t, n);
  histograma_vertical(max_aux, aux);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x27190,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x27120(%rbp)
ff
movsd  0xe5f(%rip),%xmm0
movsd  %xmm0,-0x27128(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x27130(%rbp)
ff
xor    %eax,%eax
cmpl   $0x4e20,-0x8(%rbp)
mov    %al,-0x27189(%rbp)
jge    11f4 <main+0x84>
movslq -0x8(%rbp),%rax
lea    -0x27110(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe2e(%rip),%rdi
call   1080 <scanf@plt>
cmp    $0x0,%rax
setg   %al
mov    %al,-0x27189(%rbp)
mov    -0x27189(%rbp),%al
test   $0x1,%al
jne    1207 <main+0x97>
jmp    12a0 <main+0x130>
movslq -0x8(%rbp),%rax
movsd  -0x27110(%rbp,%rax,8),%xmm0
fd ff
ucomisd -0x27128(%rbp),%xmm0
ff
jbe    123c <main+0xcc>
movslq -0x8(%rbp),%rax
movsd  -0x27110(%rbp,%rax,8),%xmm0
fd ff
movsd  %xmm0,-0x27128(%rbp)
ff
jmp    1275 <main+0x105>
movslq -0x8(%rbp),%rax
movsd  -0x27110(%rbp,%rax,8),%xmm1
fd ff
movsd  -0x27120(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jbe    1270 <main+0x100>
movslq -0x8(%rbp),%rax
movsd  -0x27110(%rbp,%rax,8),%xmm0
fd ff
movsd  %xmm0,-0x27120(%rbp)
ff
jmp    1275 <main+0x105>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
cltq
movsd  -0x27110(%rbp,%rax,8),%xmm0
fd ff
addsd  -0x27130(%rbp),%xmm0
ff
movsd  %xmm0,-0x27130(%rbp)
ff
jmp    11b4 <main+0x44>
movsd  -0x27130(%rbp),%xmm0
ff
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x27118(%rbp)
ff
movsd  -0x27118(%rbp),%xmm0
ff
movsd  -0x27120(%rbp),%xmm1
ff
movsd  -0x27128(%rbp),%xmm2
ff
lea    0xd3c(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
lea    -0x27110(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1090 <bubble_sort@plt>
movsd  -0x27118(%rbp),%xmm0
ff
lea    -0x27110(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1070 <media_acima_media@plt>
cvtsi2sd %eax,%xmm0
lea    0xd2b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    -0x27180(%rbp),%rdi
lea    -0x27110(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1040 <popular_aux@plt>
lea    -0x27180(%rbp),%rdi
lea    -0x27110(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1050 <histograma@plt>
movsd  %xmm0,-0x27188(%rbp)
ff
movsd  -0x27188(%rbp),%xmm0
ff
lea    -0x27180(%rbp),%rdi
call   1060 <histograma_vertical@plt>
xor    %eax,%eax
add    $0x27190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x27170,%rsp
movsd  0xe7c(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xe76(%rip),%xmm2
xorpd  %xmm0,%xmm0
lea    0x70(%rsp),%rbx
xor    %r14d,%r14d
lea    0xe6b(%rip),%r15
jmp    11cf <main+0x5f>
nopw   0x0(%rax,%rax,1)
movapd %xmm1,%xmm2
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0xffffffffffffffff,%r14
add    $0x8,%rbx
cmp    $0xffffffffffffb1e0,%r14
je     120f <main+0x9f>
movsd  %xmm2,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
test   %rax,%rax
jle    1217 <main+0xa7>
movsd  (%rbx),%xmm1
movsd  0x18(%rsp),%xmm2
ucomisd %xmm2,%xmm1
ja     11b0 <main+0x40>
movsd  0x10(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b4 <main+0x44>
movsd  %xmm1,0x10(%rsp)
jmp    11b4 <main+0x44>
mov    $0x4e20,%r14d
jmp    1226 <main+0xb6>
neg    %r14d
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm2
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xdd5(%rip),%rdi
movsd  0x10(%rsp),%xmm1
mov    $0x3,%al
call   1030 <printf@plt>
lea    0x70(%rsp),%r15
mov    %r15,%rdi
mov    %r14d,%esi
call   1090 <bubble_sort@plt>
movsd  0x8(%rsp),%xmm0
mov    %r15,%rdi
mov    %r14d,%esi
call   1070 <media_acima_media@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xdc0(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1040 <popular_aux@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1050 <histograma@plt>
mov    %rbx,%rdi
call   1060 <histograma_vertical@plt>
xor    %eax,%eax
add    $0x27170,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [39 x i8] c"med = %.3lf, min = %.3lf, max = %.3lf\0A\00"
@.str.2 = [48 x i8] c"M\C3\A9dia das temperaturas acima da m\C3\A9dia: %.3lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [20000 x double]
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca [20 x i32]
%9 = alloca double
store i32 0, i32* %1
store i32 0, i32* %2
store double 1.000000e+02, double* %5
store double -1.000000e+02, double* %6
store double 0.000000e+00, double* %7
br label %10
10: ; preds = %46, %0
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 20000
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [20000 x double], [20000 x double]* %3, i64 0, i64 %15
%17 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %16)
%18 = icmp sgt i64 %17, 0
br label %19
19: ; preds = %13, %10
%20 = phi i1 [ false, %10 ], [ %18, %13 ]
br i1 %20, label %21, label %54
21: ; preds = %19
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [20000 x double], [20000 x double]* %3, i64 0, i64 %23
%25 = load double, double* %24
%26 = load double, double* %6
%27 = fcmp ogt double %25, %26
br i1 %27, label %28, label %33
28: ; preds = %21
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [20000 x double], [20000 x double]* %3, i64 0, i64 %30
%32 = load double, double* %31
store double %32, double* %6
br label %46
33: ; preds = %21
%34 = load i32, i32* %2
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [20000 x double], [20000 x double]* %3, i64 0, i64 %35
%37 = load double, double* %36
%38 = load double, double* %5
%39 = fcmp olt double %37, %38
br i1 %39, label %40, label %45
40: ; preds = %33
%41 = load i32, i32* %2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [20000 x double], [20000 x double]* %3, i64 0, i64 %42
%44 = load double, double* %43
store double %44, double* %5
br label %45
45: ; preds = %40, %33
br label %46
46: ; preds = %45, %28
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
store i32 %48, i32* %2
%49 = sext i32 %47 to i64
%50 = getelementptr inbounds [20000 x double], [20000 x double]* %3, i64 0, i64 %49
%51 = load double, double* %50
%52 = load double, double* %7
%53 = fadd double %52, %51
store double %53, double* %7
br label %10
54: ; preds = %19
%55 = load double, double* %7
%56 = load i32, i32* %2
%57 = sitofp i32 %56 to double
%58 = fdiv double %55, %57
store double %58, double* %4
%59 = load double, double* %4
%60 = load double, double* %5
%61 = load double, double* %6
%62 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), double %59, double %60, double %61)
%63 = getelementptr inbounds [20000 x double], [20000 x double]* %3, i64 0, i64 0
%64 = load i32, i32* %2
%65 = call i32 @bubble_sort(double* %63, i32 %64)
%66 = load double, double* %4
%67 = getelementptr inbounds [20000 x double], [20000 x double]* %3, i64 0, i64 0
%68 = load i32, i32* %2
%69 = call i32 @media_acima_media(double %66, double* %67, i32 %68)
%70 = sitofp i32 %69 to double
%71 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), double %70)
%72 = getelementptr inbounds [20 x i32], [20 x i32]* %8, i64 0, i64 0
%73 = getelementptr inbounds [20000 x double], [20000 x double]* %3, i64 0, i64 0
%74 = load i32, i32* %2
%75 = call i32 @popular_aux(i32* %72, double* %73, i32 %74)
%76 = getelementptr inbounds [20 x i32], [20 x i32]* %8, i64 0, i64 0
%77 = getelementptr inbounds [20000 x double], [20000 x double]* %3, i64 0, i64 0
%78 = load i32, i32* %2
%79 = call double @histograma(i32* %76, double* %77, i32 %78)
store double %79, double* %9
%80 = load double, double* %9
%81 = getelementptr inbounds [20 x i32], [20 x i32]* %8, i64 0, i64 0
%82 = call i32 @histograma_vertical(double %80, i32* %81)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [39 x i8] c"med = %.3lf, min = %.3lf, max = %.3lf\0A\00"
@.str.2 = [48 x i8] c"M\C3\A9dia das temperaturas acima da m\C3\A9dia: %.3lf\0A\00"
define i32 @main() {
%1 = alloca [20000 x double]
%2 = alloca [20 x i32]
%3 = bitcast [20000 x double]* %1 to i8*
br label %4
4: ; preds = %0, %18
%5 = phi i64 [ 0, %0 ], [ %21, %18 ]
%6 = phi double [ 0.000000e+00, %0 ], [ %22, %18 ]
%7 = phi double [ -1.000000e+02, %0 ], [ %20, %18 ]
%8 = phi double [ 1.000000e+02, %0 ], [ %19, %18 ]
%9 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %5
%10 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %9)
%11 = icmp sgt i64 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %4
%13 = load double, double* %9
%14 = fcmp ogt double %13, %7
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = fcmp olt double %13, %8
br i1 %16, label %17, label %18
17: ; preds = %15
br label %18
18: ; preds = %12, %15, %17
%19 = phi double [ %13, %17 ], [ %8, %15 ], [ %8, %12 ]
%20 = phi double [ %7, %17 ], [ %7, %15 ], [ %13, %12 ]
%21 = add nuw nsw i64 %5, 1
%22 = fadd double %6, %13
%23 = icmp eq i64 %21, 20000
br i1 %23, label %26, label %4
24: ; preds = %4
%25 = trunc i64 %5 to i32
br label %26
26: ; preds = %18, %24
%27 = phi double [ %8, %24 ], [ %19, %18 ]
%28 = phi double [ %7, %24 ], [ %20, %18 ]
%29 = phi double [ %6, %24 ], [ %22, %18 ]
%30 = phi i32 [ %25, %24 ], [ 20000, %18 ]
%31 = sitofp i32 %30 to double
%32 = fdiv double %29, %31
%33 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), double %32, double %27, double %28)
%34 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 0
%35 = call i32 @bubble_sort(double* %34, i32 %30)
%36 = call i32 @media_acima_media(double %32, double* %34, i32 %30)
%37 = sitofp i32 %36 to double
%38 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), double %37)
%39 = bitcast [20 x i32]* %2 to i8*
%40 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%41 = call i32 @popular_aux(i32* %40, double* %34, i32 %30)
%42 = call double @histograma(i32* %40, double* %34, i32 %30)
%43 = call i32 @histograma_vertical(double %42, i32* %40)
ret i32 0
}