#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 /*<<< orphan*/ scanf(char *, ...);
int main() {
  float pim, ava, prova, at, md, nota_exame, mf;
  int exame;
  printf("Nota do PIM: ");
  scanf("%f", &pim);
  printf("Nota do AVA: ");
  scanf("%f", &ava);
  printf("Nota da PROVA: ");
  scanf("%f", &prova);
  at = ((pim * 9) + (ava * 1)) / 10;
  md = ((prova * 3) + (at * 1)) / 4;
  printf("Sua média é: %3.2f \n", md);
  if (md >= 5.75) {
    printf("APROVADO! \n");
  } else if (md < 5.75) {
    printf("Deseja calcular exame? \n");
    printf("Para sim digite [1] \n");
    printf("Para não digite [2] \n");
    scanf("%i", &exame);
    switch (exame) {
    case 1:
      printf("Qual foi a nota do exame: ");
      scanf("%f", &nota_exame);
      mf = (md + nota_exame) / 2;
      printf("Sua média é: %3.2f \n", mf);
      if (mf >= 5) {
        printf("APROVADO! \n");
      } else {
        printf("REPROVADO! \n");
      }
      break;
    case 2:
      printf("REPROVADO! \n");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
movss  0xe74(%rip),%xmm1
mulss  -0xc(%rbp),%xmm1
movss  0xe6f(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  0xe5b(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
movss  0xe41(%rip),%xmm1
mulss  -0x14(%rbp),%xmm1
movss  0xe30(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  0xe1c(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xde3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     123a <main+0x11a>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1362 <main+0x242>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdb5(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    135d <main+0x23d>
lea    0xe1a(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x29(%rbp)
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xe1f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xe26(%rip),%rdi
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xe2e(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x1,%eax
je     12bc <main+0x19c>
jmp    12ab <main+0x18b>
mov    -0x28(%rbp),%eax
sub    $0x2,%eax
je     134a <main+0x22a>
jmp    1358 <main+0x238>
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd61(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x18(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  0xd32(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd4c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x20(%rbp),%xmm0
movss  0xd01(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     1337 <main+0x217>
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1345 <main+0x225>
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1358 <main+0x238>
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    135d <main+0x23d>
jmp    1362 <main+0x242>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xee0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee0(%rip),%rbx
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x1c(%rsp),%xmm0
mulss  0xe5f(%rip),%xmm0
addss  0x18(%rsp),%xmm0
divss  0xe55(%rip),%xmm0
movss  0x14(%rsp),%xmm1
mulss  0xe4b(%rip),%xmm1
addss  %xmm0,%xmm1
mulss  0xe43(%rip),%xmm1
movss  %xmm1,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe6e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x8(%rsp),%xmm1
ucomiss 0xe1f(%rip),%xmm1
jae    12bf <main+0x18f>
movss  0xe11(%rip),%xmm0
ucomiss %xmm1,%xmm0
jbe    12cb <main+0x19b>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
lea    0xe2f(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
je     12d3 <main+0x1a3>
cmp    $0x1,%eax
jne    12cb <main+0x19b>
lea    0xe0d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdc4(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm0
addss  0x10(%rsp),%xmm0
mulss  0xd8e(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xdb4(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x8(%rsp),%xmm0
ucomiss 0xd6d(%rip),%xmm0
lea    0xe11(%rip),%rax
lea    0xe16(%rip),%rdi
cmovb  %rax,%rdi
jmp    12c6 <main+0x196>
lea    0xe09(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
lea    0xde9(%rip),%rdi
jmp    12c6 <main+0x196>

LLVM IR (-O0):
@.str = [14 x i8] c"Nota do PIM: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [14 x i8] c"Nota do AVA: \00"
@.str.3 = [16 x i8] c"Nota da PROVA: \00"
@.str.4 = [23 x i8] c"Sua m\C3\A9dia \C3\A9: %3.2f \0A\00"
@.str.5 = [12 x i8] c"APROVADO! \0A\00"
@.str.6 = [25 x i8] c"Deseja calcular exame? \0A\00"
@.str.7 = [22 x i8] c"Para sim digite [1] \0A\00"
@.str.8 = [23 x i8] c"Para n\C3\A3o digite [2] \0A\00"
@.str.9 = [3 x i8] c"%i\00"
@.str.10 = [27 x i8] c"Qual foi a nota do exame: \00"
@.str.11 = [13 x i8] c"REPROVADO! \0A\00"
define i32 @main() {
%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 i32
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%16 = load float, float* %2
%17 = load float, float* %3
%18 = fmul float %17, 1.000000e+00
%19 = call float @llvm.fmuladd.f32(float %16, float 9.000000e+00, float %18)
%20 = fdiv float %19, 1.000000e+01
store float %20, float* %5
%21 = load float, float* %4
%22 = load float, float* %5
%23 = fmul float %22, 1.000000e+00
%24 = call float @llvm.fmuladd.f32(float %21, float 3.000000e+00, float %23)
%25 = fdiv float %24, 4.000000e+00
store float %25, float* %6
%26 = load float, float* %6
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), double %27)
%29 = load float, float* %6
%30 = fpext float %29 to double
%31 = fcmp oge double %30, 5.750000e+00
br i1 %31, label %32, label %34
32: ; preds = %0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %65
34: ; preds = %0
%35 = load float, float* %6
%36 = fpext float %35 to double
%37 = fcmp olt double %36, 5.750000e+00
br i1 %37, label %38, label %64
38: ; preds = %34
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%42 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %9)
%43 = load i32, i32* %9
switch i32 %43, label %63 [
i32 1, label %44
i32 2, label %61
]
44: ; preds = %38
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%46 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %7)
%47 = load float, float* %6
%48 = load float, float* %7
%49 = fadd float %47, %48
%50 = fdiv float %49, 2.000000e+00
store float %50, float* %8
%51 = load float, float* %8
%52 = fpext float %51 to double
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), double %52)
%54 = load float, float* %8
%55 = fcmp oge float %54, 5.000000e+00
br i1 %55, label %56, label %58
56: ; preds = %44
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %60
58: ; preds = %44
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
br label %60
60: ; preds = %58, %56
br label %63
61: ; preds = %38
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
br label %63
63: ; preds = %38, %61, %60
br label %64
64: ; preds = %63, %34
br label %65
65: ; preds = %64, %32
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"Nota do PIM: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [14 x i8] c"Nota do AVA: \00"
@.str.3 = [16 x i8] c"Nota da PROVA: \00"
@.str.4 = [23 x i8] c"Sua m\C3\A9dia \C3\A9: %3.2f \0A\00"
@.str.9 = [3 x i8] c"%i\00"
@.str.10 = [27 x i8] c"Qual foi a nota do exame: \00"
@str = [24 x i8] c"Deseja calcular exame? \00"
@str.12 = [21 x i8] c"Para sim digite [1] \00"
@str.13 = [22 x i8] c"Para n\C3\A3o digite [2] \00"
@str.15 = [12 x i8] c"REPROVADO! \00"
@str.17 = [11 x i8] c"APROVADO! \00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = bitcast float* %1 to i8*
%7 = bitcast float* %2 to i8*
%8 = bitcast float* %3 to i8*
%9 = bitcast float* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%17 = load float, float* %1
%18 = load float, float* %2
%19 = call float @llvm.fmuladd.f32(float %17, float 9.000000e+00, float %18)
%20 = fdiv float %19, 1.000000e+01
%21 = load float, float* %3
%22 = call float @llvm.fmuladd.f32(float %21, float 3.000000e+00, float %20)
%23 = fmul float %22, 2.500000e-01
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), double %24)
%26 = fcmp ult float %23, 5.750000e+00
br i1 %26, label %27, label %45
27: ; preds = %0
%28 = fcmp olt float %23, 5.750000e+00
br i1 %28, label %29, label %48
29: ; preds = %27
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.12, i64 0, i64 0))
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.13, i64 0, i64 0))
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %5)
%34 = load i32, i32* %5
switch i32 %34, label %48 [
i32 1, label %35
i32 2, label %45
]
35: ; preds = %29
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%37 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%38 = load float, float* %4
%39 = fadd float %23, %38
%40 = fmul float %39, 5.000000e-01
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), double %41)
%43 = fcmp ult float %40, 5.000000e+00
%44 = select i1 %43, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str.15, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0)
br label %45
45: ; preds = %29, %35, %0
%46 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0), %0 ], [ %44, %35 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.15, i64 0, i64 0), %29 ]
%47 = call i32 @puts(i8* dereferenceable(1) %46)
br label %48
48: ; preds = %45, %27, %29
ret i32 0
}