#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;
  float average;
  float exam;
  scanf("%f %f %f %f", &n1, &n2, &n3, &n4);
  average = (2 * n1 + 3 * n2 + 4 * n3 + n4) / 10;
  printf("Media: %.1f\n", average);
  if (average >= 7) {
    printf("Aluno aprovado.\n");
  } else if (average < 5) {
    printf("Aluno reprovado.\n");
  } else {
    printf("Aluno em exame.\n");
    scanf("%f", &exam);
    printf("Nota do exame: %0.1f\n", exam);
    average = (average + exam) / 2;
    printf("Aluno %s.\nMedia final: %.1f\n",
           (average < 5) ? "reprovado" : "aprovado", average);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee2(%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  0xeb2(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
addss  %xmm1,%xmm1
addss  %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
movss  0xe94(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
addss  -0x14(%rbp),%xmm0
movss  0xe7b(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe82(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
movss  0xe4a(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     11d2 <main+0xb2>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1287 <main+0x167>
movss  0xe36(%rip),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    11f7 <main+0xd7>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1282 <main+0x162>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe15(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  0xdd4(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm1
movss  0xdba(%rip),%xmm0
lea    0xe45(%rip),%rsi
lea    0xe34(%rip),%rax
ucomiss %xmm1,%xmm0
cmova  %rax,%rsi
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe00(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1287 <main+0x167>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xedd(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
mulss  0xe96(%rip),%xmm1
addss  %xmm0,%xmm0
movss  0xc(%rsp),%xmm2
mulss  0xe88(%rip),%xmm2
addss  %xmm1,%xmm0
addss  %xmm0,%xmm2
addss  0x8(%rsp),%xmm2
divss  0xe76(%rip),%xmm2
movss  %xmm2,(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
lea    0xe7f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  (%rsp),%xmm0
ucomiss 0xe54(%rip),%xmm0
jae    11d8 <main+0xa8>
movss  0xe4e(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11e6 <main+0xb6>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
jmp    125f <main+0x12f>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
jmp    125f <main+0x12f>
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe28(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe1b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  (%rsp),%xmm0
addss  0x4(%rsp),%xmm0
mulss  0xde4(%rip),%xmm0
movss  0xdd8(%rip),%xmm1
ucomiss %xmm0,%xmm1
lea    0xe22(%rip),%rax
lea    0xe25(%rip),%rsi
cmova  %rax,%rsi
cvtss2sd %xmm0,%xmm0
lea    0xdef(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%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 = [22 x i8] c"Nota do exame: %0.1f\0A\00"
@.str.7 = [29 x i8] c"Aluno %s.\0AMedia final: %.1f\0A\00"
@.str.8 = [10 x i8] c"reprovado\00"
@.str.9 = [9 x i8] c"aprovado\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
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 3.000000e+00, %10
%12 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %9, float %11)
%13 = load float, float* %4
%14 = call float @llvm.fmuladd.f32(float 4.000000e+00, float %13, float %12)
%15 = load float, float* %5
%16 = fadd float %14, %15
%17 = fdiv float %16, 1.000000e+01
store float %17, float* %6
%18 = load float, float* %6
%19 = fpext float %18 to double
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %19)
%21 = load float, float* %6
%22 = fcmp oge float %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 %48
25: ; preds = %0
%26 = load float, float* %6
%27 = fcmp olt float %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 %47
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 ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), double %34)
%36 = load float, float* %6
%37 = load float, float* %7
%38 = fadd float %36, %37
%39 = fdiv float %38, 2.000000e+00
store float %39, float* %6
%40 = load float, float* %6
%41 = fcmp olt float %40, 5.000000e+00
%42 = zext i1 %41 to i64
%43 = select i1 %41, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0)
%44 = load float, float* %6
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %43, double %45)
br label %47
47: ; preds = %30, %28
br label %48
48: ; preds = %47, %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 = [22 x i8] c"Nota do exame: %0.1f\0A\00"
@.str.7 = [29 x i8] c"Aluno %s.\0AMedia final: %.1f\0A\00"
@.str.8 = [10 x i8] c"reprovado\00"
@.str.9 = [9 x i8] c"aprovado\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() {
%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 = bitcast float* %5 to i8*
%11 = 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)
%12 = load float, float* %1
%13 = load float, float* %2
%14 = fmul float %13, 3.000000e+00
%15 = call float @llvm.fmuladd.f32(float %12, float 2.000000e+00, float %14)
%16 = load float, float* %3
%17 = call float @llvm.fmuladd.f32(float %16, float 4.000000e+00, float %15)
%18 = load float, float* %4
%19 = fadd float %18, %17
%20 = fdiv float %19, 1.000000e+01
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %21)
%23 = fcmp ult float %20, 7.000000e+00
br i1 %23, label %26, label %24
24: ; preds = %0
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0))
br label %43
26: ; preds = %0
%27 = fcmp olt float %20, 5.000000e+00
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.10, i64 0, i64 0))
br label %43
30: ; preds = %26
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, 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* %5)
%33 = load float, float* %5
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), double %34)
%36 = load float, float* %5
%37 = fadd float %20, %36
%38 = fmul float %37, 5.000000e-01
%39 = fcmp olt float %38, 5.000000e+00
%40 = select i1 %39, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0)
%41 = fpext float %38 to double
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %40, double %41)
br label %43
43: ; preds = %28, %30, %24
ret i32 0
}