#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 *, float *, ...);
int main(int argc, char const *argv[]) {
  float nota1, nota2, nota3, nota4;
  scanf("%f %f %f %f", &nota1, &nota2, &nota3, &nota4);
  float media = (nota1 * 2.0 + nota2 * 3.0 + nota3 * 4.0 + nota4 * 1.0) /
                (2.0 + 3.0 + 4.0 + 1.0);
  printf("Media: %.1f\n", media);
  if (media >= 7.0) {
    printf("Aluno aprovado.\n");
  } else if (media < 5.0) {
    printf("Aluno reprovado.\n");
  } else {
    printf("Aluno em exame.\n");
    float notaExame;
    scanf("%f", &notaExame);
    printf("Nota do exame: %.1f\n", notaExame);
    media = (media + notaExame) / 2;
    if (media >= 5.0) {
      printf("Aluno aprovado.\n");
    } else {
      printf("Aluno reprovado.\n");
    }
    printf("Media final: %.1f\n", media);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeef(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
lea    -0x20(%rbp),%r8
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xeaa(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe85(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe60(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe73(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe23(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11fa <main+0xda>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d2 <main+0x1b2>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe15(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1228 <main+0x108>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12cd <main+0x1ad>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf8(%rip),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe21(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x24(%rbp),%xmm0
addss  -0x28(%rbp),%xmm0
movss  0xdb7(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd95(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     12a8 <main+0x188>
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b6 <main+0x196>
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdc8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12d2 <main+0x1b2>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xee9(%rip),%rdi
lea    0x24(%rsp),%rsi
lea    0x20(%rsp),%rdx
lea    0x1c(%rsp),%rcx
lea    0x18(%rsp),%r8
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x24(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x20(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  0xe8e(%rip),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movss  0x1c(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  0xe7c(%rip),%xmm1
addsd  %xmm0,%xmm1
movss  0x18(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
divsd  0xe6a(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xe75(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x10(%rsp),%xmm1
ucomiss 0xe49(%rip),%xmm1
jae    11ef <main+0xbf>
movss  0xe43(%rip),%xmm0
ucomiss %xmm1,%xmm0
jbe    1200 <main+0xd0>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
jmp    128a <main+0x15a>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
jmp    128a <main+0x15a>
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe1a(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe0d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x10(%rsp),%xmm0
addss  0xc(%rsp),%xmm0
mulss  0xdd5(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
ucomiss 0xdbd(%rip),%xmm0
lea    0xe0f(%rip),%rax
lea    0xe19(%rip),%rdi
cmovb  %rax,%rdi
call   1030 <puts@plt>
lea    0xdd5(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%f %f %f %f\00"
@.str.1 = [13 x i8] c"Media: %.1f\0A\00"
@.str.2 = [17 x i8] c"Aluno aprovado.\0A\00"
@.str.3 = [18 x i8] c"Aluno reprovado.\0A\00"
@.str.4 = [17 x i8] c"Aluno em exame.\0A\00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [21 x i8] c"Nota do exame: %.1f\0A\00"
@.str.7 = [19 x i8] c"Media final: %.1f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float* %6, float* %7, float* %8, float* %9)
%13 = load float, float* %6
%14 = fpext float %13 to double
%15 = load float, float* %7
%16 = fpext float %15 to double
%17 = fmul double %16, 3.000000e+00
%18 = call double @llvm.fmuladd.f64(double %14, double 2.000000e+00, double %17)
%19 = load float, float* %8
%20 = fpext float %19 to double
%21 = call double @llvm.fmuladd.f64(double %20, double 4.000000e+00, double %18)
%22 = load float, float* %9
%23 = fpext float %22 to double
%24 = call double @llvm.fmuladd.f64(double %23, double 1.000000e+00, double %21)
%25 = fdiv double %24, 1.000000e+01
%26 = fptrunc double %25 to float
store float %26, float* %10
%27 = load float, float* %10
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %28)
%30 = load float, float* %10
%31 = fpext float %30 to double
%32 = fcmp oge double %31, 7.000000e+00
br i1 %32, label %33, label %35
33: ; preds = %2
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %63
35: ; preds = %2
%36 = load float, float* %10
%37 = fpext float %36 to double
%38 = fcmp olt double %37, 5.000000e+00
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %62
41: ; preds = %35
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%43 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %11)
%44 = load float, float* %11
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), double %45)
%47 = load float, float* %10
%48 = load float, float* %11
%49 = fadd float %47, %48
%50 = fdiv float %49, 2.000000e+00
store float %50, float* %10
%51 = load float, float* %10
%52 = fpext float %51 to double
%53 = fcmp oge double %52, 5.000000e+00
br i1 %53, label %54, label %56
54: ; preds = %41
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %58
56: ; preds = %41
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %58
58: ; preds = %56, %54
%59 = load float, float* %10
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), double %60)
br label %62
62: ; preds = %58, %39
br label %63
63: ; preds = %62, %33
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"%f %f %f %f\00"
@.str.1 = [13 x i8] c"Media: %.1f\0A\00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [21 x i8] c"Nota do exame: %.1f\0A\00"
@.str.7 = [19 x i8] c"Media final: %.1f\0A\00"
@str = [16 x i8] c"Aluno em exame.\00"
@str.10 = [17 x i8] c"Aluno reprovado.\00"
@str.11 = [16 x i8] c"Aluno aprovado.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = bitcast float* %3 to i8*
%9 = bitcast float* %4 to i8*
%10 = bitcast float* %5 to i8*
%11 = bitcast float* %6 to i8*
%12 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float* %3, float* %4, float* %5, float* %6)
%13 = load float, float* %3
%14 = fpext float %13 to double
%15 = load float, float* %4
%16 = fpext float %15 to double
%17 = fmul double %16, 3.000000e+00
%18 = call double @llvm.fmuladd.f64(double %14, double 2.000000e+00, double %17)
%19 = load float, float* %5
%20 = fpext float %19 to double
%21 = call double @llvm.fmuladd.f64(double %20, double 4.000000e+00, double %18)
%22 = load float, float* %6
%23 = fpext float %22 to double
%24 = fadd double %21, %23
%25 = fdiv double %24, 1.000000e+01
%26 = fptrunc double %25 to float
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %27)
%29 = fcmp ult float %26, 7.000000e+00
br i1 %29, label %32, label %30
30: ; preds = %2
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0))
br label %51
32: ; preds = %2
%33 = fcmp olt float %26, 5.000000e+00
br i1 %33, label %34, label %36
34: ; preds = %32
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.10, i64 0, i64 0))
br label %51
36: ; preds = %32
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%38 = bitcast float* %7 to i8*
%39 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %7)
%40 = load float, float* %7
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), double %41)
%43 = load float, float* %7
%44 = fadd float %43, %26
%45 = fmul float %44, 5.000000e-01
%46 = fpext float %45 to double
%47 = fcmp ult float %45, 5.000000e+00
%48 = select i1 %47, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0)
%49 = call i32 @puts(i8* dereferenceable(1) %48)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), double %46)
br label %51
51: ; preds = %34, %36, %30
ret i32 0
}