#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *, ...);
int /*<<< orphan*/ stdout;
int main(void) {
  double n1, n2, n3, n4;
  double media;
  scanf("%lf %lf %lf %lf", &n1, &n2, &n3, &n4);
  media = n1 * 0.2 + n2 * 0.3 + n3 * 0.4 + n4 * 0.1;
  printf("Media: %.1f\n", media);
  if (media < 5.0) {
    printf("Aluno reprovado.\n");
  } else if (media < 7.0) {
    printf("Aluno em exame.\n");
    fflush(stdout);
    double exame;
    double mediaFinal;
    scanf("%lf", &exame);
    printf("Nota do exame: %.1f\n", exame);
    mediaFinal = media * 0.5 + exame * 0.5;
    if (mediaFinal < 5.0) {
      printf("Aluno reprovado.\n");
      printf("Media final: %.1f\n", mediaFinal);
    } else {
      printf("Aluno aprovado.\n");
      printf("Media final: %.1f\n", mediaFinal);
    }
  } else {
    printf("Aluno aprovado.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xef2(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
mov    $0x0,%al
call   1050 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xeb6(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  0xea1(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xe84(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  0xe67(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xe8e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe37(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    11e7 <main+0xb7>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d4 <main+0x1a4>
movsd  0xe39(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    12c1 <main+0x191>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
lea    0xe27(%rip),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsd  -0x38(%rbp),%xmm0
lea    0xe44(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
movsd  0xde8(%rip),%xmm1
mulsd  -0x38(%rbp),%xmm1
movsd  0xddb(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xd96(%rip),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    129b <main+0x16b>
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x40(%rbp),%xmm0
lea    0xdfe(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12bc <main+0x18c>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x40(%rbp),%xmm0
lea    0xdd8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12cf <main+0x19f>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d4 <main+0x1a4>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
lea    0xeed(%rip),%rdi
lea    0x30(%rsp),%rsi
lea    0x28(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x18(%rsp),%r8
xor    %eax,%eax
call   1060 <scanf@plt>
movsd  0x28(%rsp),%xmm0
mulsd  0xe8c(%rip),%xmm0
movsd  0x30(%rsp),%xmm1
mulsd  0xe86(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0x20(%rsp),%xmm2
mulsd  0xe7c(%rip),%xmm2
addsd  %xmm1,%xmm2
movsd  0x18(%rsp),%xmm0
mulsd  0xe72(%rip),%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xe91(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm1
movsd  0xe54(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11de <main+0x9e>
lea    0xec4(%rip),%rdi
jmp    1297 <main+0x157>
movsd  0xe42(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1290 <main+0x150>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    0xe33(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movsd  0x10(%rsp),%xmm0
lea    0xe2b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0xdf7(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0xdc1(%rip),%xmm0
ucomisd %xmm2,%xmm0
lea    0xe33(%rip),%rax
lea    0xe1c(%rip),%rdi
cmova  %rax,%rdi
call   1030 <puts@plt>
lea    0xde9(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
jmp    129c <main+0x15c>
lea    0xdf6(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

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

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