#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 *, float);
int /*<<< orphan*/ scanf(char *, float *);
int calculation_tests() {
  float nota1, nota2, nota3;
  float maior, menor, media, mediatotal, mediamelhor;
  scanf("%f", &nota1);
  scanf("%f", &nota2);
  scanf("%f", &nota3);
  if (nota1 > nota2 && nota1 > nota3) {
    maior = nota1;
    if (nota2 > nota3) {
      media = nota2;
      menor = nota3;
    } else {
      media = nota3;
      menor = nota2;
    }
  }
  if (nota2 > nota1 && nota2 > nota3) {
    maior = nota2;
    if (nota1 > nota3) {
      media = nota1;
      menor = nota3;
    } else {
      media = nota3;
      menor = nota1;
    }
  }
  if (nota3 > nota1 && nota3 > nota2) {
    maior = nota3;
    if (nota2 > nota1) {
      media = nota2;
      menor = nota1;
    } else {
      media = nota1;
      menor = nota2;
    }
  }
  mediamelhor = (media + maior) / 2;
  mediatotal = (menor + media + maior) / 3;
  printf("Media com as duas melhores notas: %.1f\n", mediamelhor);
  printf("Media com as tres notas: %.1f\n", mediatotal);
  printf("Nota mais baixa: %.1f\n", menor);
  printf("Nota mais alta: %.1f\n", maior);
}


x86 assembly (clang, -O0):
<calculation_tests>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xed9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec9(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11c1 <calculation_tests+0xa1>
movss  -0x8(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    11c1 <calculation_tests+0xa1>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    11a8 <calculation_tests+0x88>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    11bc <calculation_tests+0x9c>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    11c1 <calculation_tests+0xa1>
movss  -0xc(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    122a <calculation_tests+0x10a>
movss  -0xc(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    122a <calculation_tests+0x10a>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    1211 <calculation_tests+0xf1>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    1225 <calculation_tests+0x105>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    122a <calculation_tests+0x10a>
movss  -0x10(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1293 <calculation_tests+0x173>
movss  -0x10(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    1293 <calculation_tests+0x173>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    127a <calculation_tests+0x15a>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    128e <calculation_tests+0x16e>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    1293 <calculation_tests+0x173>
movss  -0x1c(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  0xd5f(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x18(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  0xd3b(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x24(%rbp),%xmm0
lea    0xd31(%rip),%rdi
call   1030 <printf@plt>
movss  -0x20(%rbp),%xmm0
lea    0xd48(%rip),%rdi
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
lea    0xd56(%rip),%rdi
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
lea    0xd5c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculation_tests>:
push   %rbx
sub    $0x20,%rsp
lea    0xedc(%rip),%rbx
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
movss  0x1c(%rsp),%xmm4
movss  0x18(%rsp),%xmm3
ucomiss %xmm3,%xmm4
jbe    117a <calculation_tests+0x5a>
movss  0x8(%rsp),%xmm1
ucomiss %xmm1,%xmm4
jbe    117a <calculation_tests+0x5a>
movaps %xmm3,%xmm2
maxss  %xmm1,%xmm2
minss  %xmm3,%xmm1
ucomiss %xmm4,%xmm3
movss  0x8(%rsp),%xmm6
jbe    11ac <calculation_tests+0x8c>
ucomiss %xmm6,%xmm3
movaps %xmm4,%xmm7
movaps %xmm3,%xmm0
movaps %xmm4,%xmm5
jbe    11b5 <calculation_tests+0x95>
movaps %xmm4,%xmm2
maxss  %xmm6,%xmm2
movaps %xmm6,%xmm1
minss  %xmm4,%xmm1
movaps %xmm4,%xmm7
movaps %xmm3,%xmm0
movaps %xmm3,%xmm5
jmp    11b5 <calculation_tests+0x95>
movaps %xmm3,%xmm7
movaps %xmm4,%xmm0
movaps %xmm4,%xmm5
ucomiss %xmm4,%xmm6
seta   %al
ucomiss %xmm3,%xmm6
seta   %cl
test   %cl,%al
jne    11ce <calculation_tests+0xae>
movaps %xmm2,%xmm0
movaps %xmm1,%xmm7
movaps %xmm5,%xmm6
movss  %xmm7,0x10(%rsp)
movss  %xmm6,0x14(%rsp)
addss  %xmm0,%xmm7
addss  %xmm6,%xmm0
mulss  0xe16(%rip),%xmm0
addss  %xmm6,%xmm7
divss  0xe0e(%rip),%xmm7
movss  %xmm7,0xc(%rsp)
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
lea    0xe24(%rip),%rdi
movss  0xc(%rsp),%xmm0
call   1030 <printf@plt>
lea    0xe31(%rip),%rdi
movss  0x10(%rsp),%xmm0
call   1030 <printf@plt>
lea    0xe36(%rip),%rdi
movss  0x14(%rsp),%xmm0
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%f\00"
@.str.1 = [40 x i8] c"Media com as duas melhores notas: %.1f\0A\00"
@.str.2 = [31 x i8] c"Media com as tres notas: %.1f\0A\00"
@.str.3 = [23 x i8] c"Nota mais baixa: %.1f\0A\00"
@.str.4 = [22 x i8] c"Nota mais alta: %.1f\0A\00"
define i32 @calculation_tests() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %2)
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %3)
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %4)
%13 = load float, float* %2
%14 = load float, float* %3
%15 = fcmp ogt float %13, %14
br i1 %15, label %16, label %32
16: ; preds = %0
%17 = load float, float* %2
%18 = load float, float* %4
%19 = fcmp ogt float %17, %18
br i1 %19, label %20, label %32
20: ; preds = %16
%21 = load float, float* %2
store float %21, float* %5
%22 = load float, float* %3
%23 = load float, float* %4
%24 = fcmp ogt float %22, %23
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load float, float* %3
store float %26, float* %7
%27 = load float, float* %4
store float %27, float* %6
br label %31
28: ; preds = %20
%29 = load float, float* %4
store float %29, float* %7
%30 = load float, float* %3
store float %30, float* %6
br label %31
31: ; preds = %28, %25
br label %32
32: ; preds = %31, %16, %0
%33 = load float, float* %3
%34 = load float, float* %2
%35 = fcmp ogt float %33, %34
br i1 %35, label %36, label %52
36: ; preds = %32
%37 = load float, float* %3
%38 = load float, float* %4
%39 = fcmp ogt float %37, %38
br i1 %39, label %40, label %52
40: ; preds = %36
%41 = load float, float* %3
store float %41, float* %5
%42 = load float, float* %2
%43 = load float, float* %4
%44 = fcmp ogt float %42, %43
br i1 %44, label %45, label %48
45: ; preds = %40
%46 = load float, float* %2
store float %46, float* %7
%47 = load float, float* %4
store float %47, float* %6
br label %51
48: ; preds = %40
%49 = load float, float* %4
store float %49, float* %7
%50 = load float, float* %2
store float %50, float* %6
br label %51
51: ; preds = %48, %45
br label %52
52: ; preds = %51, %36, %32
%53 = load float, float* %4
%54 = load float, float* %2
%55 = fcmp ogt float %53, %54
br i1 %55, label %56, label %72
56: ; preds = %52
%57 = load float, float* %4
%58 = load float, float* %3
%59 = fcmp ogt float %57, %58
br i1 %59, label %60, label %72
60: ; preds = %56
%61 = load float, float* %4
store float %61, float* %5
%62 = load float, float* %3
%63 = load float, float* %2
%64 = fcmp ogt float %62, %63
br i1 %64, label %65, label %68
65: ; preds = %60
%66 = load float, float* %3
store float %66, float* %7
%67 = load float, float* %2
store float %67, float* %6
br label %71
68: ; preds = %60
%69 = load float, float* %2
store float %69, float* %7
%70 = load float, float* %3
store float %70, float* %6
br label %71
71: ; preds = %68, %65
br label %72
72: ; preds = %71, %56, %52
%73 = load float, float* %7
%74 = load float, float* %5
%75 = fadd float %73, %74
%76 = fdiv float %75, 2.000000e+00
store float %76, float* %9
%77 = load float, float* %6
%78 = load float, float* %7
%79 = fadd float %77, %78
%80 = load float, float* %5
%81 = fadd float %79, %80
%82 = fdiv float %81, 3.000000e+00
store float %82, float* %8
%83 = load float, float* %9
%84 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), float %83)
%85 = load float, float* %8
%86 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), float %85)
%87 = load float, float* %6
%88 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), float %87)
%89 = load float, float* %5
%90 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), float %89)
%91 = load i32, i32* %1
ret i32 %91
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
@.str.1 = [40 x i8] c"Media com as duas melhores notas: %.1f\0A\00"
@.str.2 = [31 x i8] c"Media com as tres notas: %.1f\0A\00"
@.str.3 = [23 x i8] c"Nota mais baixa: %.1f\0A\00"
@.str.4 = [22 x i8] c"Nota mais alta: %.1f\0A\00"
define i32 @calculation_tests() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %2)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %3)
%10 = load float, float* %1
%11 = load float, float* %2
%12 = fcmp ogt float %10, %11
br i1 %12, label %13, label %20
13: ; preds = %0
%14 = load float, float* %3
%15 = fcmp ogt float %10, %14
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = fcmp ogt float %11, %14
%18 = select i1 %17, float %11, float %14
%19 = select i1 %17, float %14, float %11
br label %20
20: ; preds = %16, %13, %0
%21 = phi float [ undef, %13 ], [ undef, %0 ], [ %18, %16 ]
%22 = phi float [ undef, %13 ], [ undef, %0 ], [ %19, %16 ]
%23 = fcmp ogt float %11, %10
%24 = load float, float* %3
br i1 %23, label %25, label %31
25: ; preds = %20
%26 = fcmp ogt float %11, %24
br i1 %26, label %27, label %31
27: ; preds = %25
%28 = fcmp ogt float %10, %24
%29 = select i1 %28, float %10, float %24
%30 = select i1 %28, float %24, float %10
br label %31
31: ; preds = %20, %27, %25
%32 = phi float [ %10, %27 ], [ %10, %25 ], [ %11, %20 ]
%33 = phi float [ %11, %27 ], [ %11, %25 ], [ %10, %20 ]
%34 = phi float [ %29, %27 ], [ %21, %25 ], [ %21, %20 ]
%35 = phi float [ %30, %27 ], [ %22, %25 ], [ %22, %20 ]
%36 = phi float [ %11, %27 ], [ %10, %25 ], [ %10, %20 ]
%37 = fcmp ogt float %24, %10
%38 = fcmp ogt float %24, %11
%39 = select i1 %37, i1 %38, i1 false
%40 = select i1 %39, float %33, float %34
%41 = select i1 %39, float %32, float %35
%42 = select i1 %39, float %24, float %36
%43 = fadd float %40, %42
%44 = fmul float %43, 5.000000e-01
%45 = fadd float %41, %40
%46 = fadd float %42, %45
%47 = fdiv float %46, 3.000000e+00
%48 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), float %44)
%49 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), float %47)
%50 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), float %41)
%51 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), float %42)
ret i32 undef
}