#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 *);
void 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    $0x20,%rsp
lea    0xed9(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb9(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x4(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11c1 <calculation_tests+0xa1>
movss  -0x4(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11c1 <calculation_tests+0xa1>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11a8 <calculation_tests+0x88>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11bc <calculation_tests+0x9c>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11c1 <calculation_tests+0xa1>
movss  -0x8(%rbp),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    122a <calculation_tests+0x10a>
movss  -0x8(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    122a <calculation_tests+0x10a>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    1211 <calculation_tests+0xf1>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1225 <calculation_tests+0x105>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    122a <calculation_tests+0x10a>
movss  -0xc(%rbp),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    1293 <calculation_tests+0x173>
movss  -0xc(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1293 <calculation_tests+0x173>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    127a <calculation_tests+0x15a>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    128e <calculation_tests+0x16e>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1293 <calculation_tests+0x173>
movss  -0x18(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  0xd5f(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  0xd3b(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x20(%rbp),%xmm0
lea    0xd31(%rip),%rdi
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
lea    0xd48(%rip),%rdi
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
lea    0xd56(%rip),%rdi
call   1030 <printf@plt>
movss  -0x10(%rbp),%xmm0
lea    0xd5c(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%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 void @calculation_tests() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%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 = load float, float* %1
%13 = load float, float* %2
%14 = fcmp ogt float %12, %13
br i1 %14, label %15, label %31
15: ; preds = %0
%16 = load float, float* %1
%17 = load float, float* %3
%18 = fcmp ogt float %16, %17
br i1 %18, label %19, label %31
19: ; preds = %15
%20 = load float, float* %1
store float %20, float* %4
%21 = load float, float* %2
%22 = load float, float* %3
%23 = fcmp ogt float %21, %22
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load float, float* %2
store float %25, float* %6
%26 = load float, float* %3
store float %26, float* %5
br label %30
27: ; preds = %19
%28 = load float, float* %3
store float %28, float* %6
%29 = load float, float* %2
store float %29, float* %5
br label %30
30: ; preds = %27, %24
br label %31
31: ; preds = %30, %15, %0
%32 = load float, float* %2
%33 = load float, float* %1
%34 = fcmp ogt float %32, %33
br i1 %34, label %35, label %51
35: ; preds = %31
%36 = load float, float* %2
%37 = load float, float* %3
%38 = fcmp ogt float %36, %37
br i1 %38, label %39, label %51
39: ; preds = %35
%40 = load float, float* %2
store float %40, float* %4
%41 = load float, float* %1
%42 = load float, float* %3
%43 = fcmp ogt float %41, %42
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = load float, float* %1
store float %45, float* %6
%46 = load float, float* %3
store float %46, float* %5
br label %50
47: ; preds = %39
%48 = load float, float* %3
store float %48, float* %6
%49 = load float, float* %1
store float %49, float* %5
br label %50
50: ; preds = %47, %44
br label %51
51: ; preds = %50, %35, %31
%52 = load float, float* %3
%53 = load float, float* %1
%54 = fcmp ogt float %52, %53
br i1 %54, label %55, label %71
55: ; preds = %51
%56 = load float, float* %3
%57 = load float, float* %2
%58 = fcmp ogt float %56, %57
br i1 %58, label %59, label %71
59: ; preds = %55
%60 = load float, float* %3
store float %60, float* %4
%61 = load float, float* %2
%62 = load float, float* %1
%63 = fcmp ogt float %61, %62
br i1 %63, label %64, label %67
64: ; preds = %59
%65 = load float, float* %2
store float %65, float* %6
%66 = load float, float* %1
store float %66, float* %5
br label %70
67: ; preds = %59
%68 = load float, float* %1
store float %68, float* %6
%69 = load float, float* %2
store float %69, float* %5
br label %70
70: ; preds = %67, %64
br label %71
71: ; preds = %70, %55, %51
%72 = load float, float* %6
%73 = load float, float* %4
%74 = fadd float %72, %73
%75 = fdiv float %74, 2.000000e+00
store float %75, float* %8
%76 = load float, float* %5
%77 = load float, float* %6
%78 = fadd float %76, %77
%79 = load float, float* %4
%80 = fadd float %78, %79
%81 = fdiv float %80, 3.000000e+00
store float %81, float* %7
%82 = load float, float* %8
%83 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), float %82)
%84 = load float, float* %7
%85 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), float %84)
%86 = load float, float* %5
%87 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), float %86)
%88 = load float, float* %4
%89 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), float %88)
ret void
}

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 void @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 void
}