#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() {
  float n1, n2, n3, n4;
  scanf("%f %f %f %f", &n1, &n2, &n3, &n4);
  double avg = (n1 * 2 + n2 * 3 + n3 * 4 + n4) / (2 + 3 + 4 + 1);
  printf("Media: %.1f\n", avg);
  if (avg >= 7.0)
    printf("Aluno aprovado.\n");
  else if (avg < 5.0)
    printf("Aluno reprovado.\n");
  else {
    printf("Aluno em exame.\n");
    float lst;
    scanf("%f", &lst);
    printf("Nota do exame: %.1f\n", lst);
    avg = (avg + lst) / 2;
    if (avg >= 5.0)
      printf("Aluno aparovado.\n");
    else
      printf("Aluno reprovado.\n");
    printf("Media final: %.1f\n", avg);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeee(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm1
movss  0xec6(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
addss  %xmm1,%xmm1
addss  %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
movss  0xea8(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
addss  -0x14(%rbp),%xmm0
movss  0xe8f(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xe8e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  0xe4a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11d3 <main+0xb3>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a3 <main+0x183>
movsd  0xe2d(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11f9 <main+0xd9>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129e <main+0x17e>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe1f(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe48(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  0xdc6(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xda8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     127d <main+0x15d>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128b <main+0x16b>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe01(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12a3 <main+0x183>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xeed(%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
movss  0x20(%rsp),%xmm1
mulss  0xe96(%rip),%xmm1
addss  %xmm0,%xmm0
movss  0x1c(%rsp),%xmm2
mulss  0xe88(%rip),%xmm2
addss  %xmm1,%xmm0
addss  %xmm0,%xmm2
addss  0x18(%rsp),%xmm2
divss  0xe76(%rip),%xmm2
movss  %xmm2,0x14(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
lea    0xe8e(%rip),%rdi
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x14(%rsp),%xmm1
ucomiss 0xe4c(%rip),%xmm1
jae    11e0 <main+0xb0>
movss  0xe46(%rip),%xmm0
ucomiss %xmm1,%xmm0
jbe    11f1 <main+0xc1>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
jmp    127d <main+0x14d>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
jmp    127d <main+0x14d>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
lea    0xe2d(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe20(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xdd4(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
ucomisd 0xdce(%rip),%xmm1
lea    0xe31(%rip),%rax
lea    0xe19(%rip),%rdi
cmovb  %rax,%rdi
call   1030 <puts@plt>
lea    0xde6(%rip),%rdi
movsd  0x8(%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 = [18 x i8] c"Aluno aparovado.\0A\00"
@.str.8 = [19 x i8] c"Media final: %.1f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca double
%7 = alloca float
store i32 0, i32* %1
%8 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float* %2, float* %3, float* %4, float* %5)
%9 = load float, float* %2
%10 = load float, float* %3
%11 = fmul float %10, 3.000000e+00
%12 = call float @llvm.fmuladd.f32(float %9, float 2.000000e+00, float %11)
%13 = load float, float* %4
%14 = call float @llvm.fmuladd.f32(float %13, float 4.000000e+00, float %12)
%15 = load float, float* %5
%16 = fadd float %14, %15
%17 = fdiv float %16, 1.000000e+01
%18 = fpext float %17 to double
store double %18, double* %6
%19 = load double, double* %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %19)
%21 = load double, double* %6
%22 = fcmp oge double %21, 7.000000e+00
br i1 %22, label %23, label %25
23: ; preds = %0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %51
25: ; preds = %0
%26 = load double, double* %6
%27 = fcmp olt double %26, 5.000000e+00
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %50
30: ; preds = %25
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%32 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %7)
%33 = load float, float* %7
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), double %34)
%36 = load double, double* %6
%37 = load float, float* %7
%38 = fpext float %37 to double
%39 = fadd double %36, %38
%40 = fdiv double %39, 2.000000e+00
store double %40, double* %6
%41 = load double, double* %6
%42 = fcmp oge double %41, 5.000000e+00
br i1 %42, label %43, label %45
43: ; preds = %30
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
br label %47
45: ; preds = %30
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %47
47: ; preds = %45, %43
%48 = load double, double* %6
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), double %48)
br label %50
50: ; preds = %47, %28
br label %51
51: ; preds = %50, %23
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.8 = [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 aparovado.\00"
@str.11 = [17 x i8] c"Aluno reprovado.\00"
@str.12 = [16 x i8] c"Aluno aprovado.\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%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 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float* %1, float* %2, float* %3, float* %4)
%11 = load float, float* %1
%12 = load float, float* %2
%13 = fmul float %12, 3.000000e+00
%14 = call float @llvm.fmuladd.f32(float %11, float 2.000000e+00, float %13)
%15 = load float, float* %3
%16 = call float @llvm.fmuladd.f32(float %15, float 4.000000e+00, float %14)
%17 = load float, float* %4
%18 = fadd float %17, %16
%19 = fdiv float %18, 1.000000e+01
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %20)
%22 = fcmp ult float %19, 7.000000e+00
br i1 %22, label %25, label %23
23: ; preds = %0
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.12, i64 0, i64 0))
br label %44
25: ; preds = %0
%26 = fcmp olt float %19, 5.000000e+00
br i1 %26, label %27, label %29
27: ; preds = %25
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.11, i64 0, i64 0))
br label %44
29: ; preds = %25
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%31 = bitcast float* %5 to i8*
%32 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %5)
%33 = load float, float* %5
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), double %34)
%36 = load float, float* %5
%37 = fpext float %36 to double
%38 = fadd double %20, %37
%39 = fmul double %38, 5.000000e-01
%40 = fcmp ult double %39, 5.000000e+00
%41 = select i1 %40, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str.11, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str.10, i64 0, i64 0)
%42 = call i32 @puts(i8* dereferenceable(1) %41)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), double %39)
br label %44
44: ; preds = %27, %29, %23
ret i32 0
}