#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 *, double *, ...);
int main() {
  double a, b, c, d, e, m;
  scanf("%lf %lf %lf %lf", &a, &b, &c, &d);
  m = (a * 2 + b * 3 + c * 4 + d) / 10;
  printf("Media: %.1f\n", m);
  if (m >= 7.0) {
    printf("Aluno aprovado.\n");
  } else if (m >= 5.0) {
    printf("Aluno em exame.\n");
    scanf("%lf", &e);
    printf("Nota do exame: %.1f\n", e);
    if (e + m / 2.0 > 5.0) {
      printf("Aluno aprovado.\n");
    } else {
      printf("Aluno reprovado.\n");
    }
    printf("Media final: %.1f\n", (e + m) / 2.0);
  } else {
    printf("Aluno reprovado.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xefa(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
mov    $0x0,%al
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm1
movsd  0xebe(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
addsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe9c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  0xe7f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
lea    0xea2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm0
movsd  0xe4e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11cf <main+0xaf>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a2 <main+0x182>
movsd  -0x38(%rbp),%xmm0
movsd  0xe44(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     128f <main+0x16f>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe41(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xe5d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  0xdfd(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  0xde5(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1258 <main+0x138>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <main+0x146>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  0xdb0(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe13(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    129d <main+0x17d>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a2 <main+0x182>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
lea    0xef5(%rip),%rdi
lea    0x30(%rsp),%rsi
lea    0x28(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x18(%rsp),%r8
xor    %eax,%eax
call   1050 <scanf@plt>
movsd  0x30(%rsp),%xmm2
movsd  0x28(%rsp),%xmm1
mulsd  0xe96(%rip),%xmm1
addsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
movsd  0x20(%rsp),%xmm0
mulsd  0xe88(%rip),%xmm0
addsd  %xmm2,%xmm0
addsd  0x18(%rsp),%xmm0
divsd  0xe7e(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xea1(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
ucomisd 0xe64(%rip),%xmm0
jae    11c9 <main+0x99>
ucomisd 0xe62(%rip),%xmm0
jae    11da <main+0xaa>
lea    0xebe(%rip),%rdi
jmp    11d0 <main+0xa0>
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
jmp    1262 <main+0x132>
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4f(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsd  0x10(%rsp),%xmm0
lea    0xe47(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
mulsd  0xe0d(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
ucomisd 0xdf7(%rip),%xmm0
lea    0xe66(%rip),%rax
lea    0xe4e(%rip),%rdi
cmova  %rax,%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
mulsd  0xdd4(%rip),%xmm0
lea    0xe07(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@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 = [17 x i8] c"Aluno aprovado.\0A\00"
@.str.3 = [17 x i8] c"Aluno em exame.\0A\00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [21 x i8] c"Nota do exame: %.1f\0A\00"
@.str.6 = [18 x i8] c"Aluno reprovado.\0A\00"
@.str.7 = [19 x i8] c"Media final: %.1f\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
store i32 0, i32* %1
%8 = 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)
%9 = load double, double* %2
%10 = load double, double* %3
%11 = fmul double %10, 3.000000e+00
%12 = call double @llvm.fmuladd.f64(double %9, double 2.000000e+00, double %11)
%13 = load double, double* %4
%14 = call double @llvm.fmuladd.f64(double %13, double 4.000000e+00, double %12)
%15 = load double, double* %5
%16 = fadd double %14, %15
%17 = fdiv double %16, 1.000000e+01
store double %17, double* %7
%18 = load double, double* %7
%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* %7
%21 = fcmp oge double %20, 7.000000e+00
br i1 %21, label %22, label %24
22: ; preds = %0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %50
24: ; preds = %0
%25 = load double, double* %7
%26 = fcmp oge double %25, 5.000000e+00
br i1 %26, label %27, label %47
27: ; preds = %24
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %6)
%30 = load double, double* %6
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), double %30)
%32 = load double, double* %6
%33 = load double, double* %7
%34 = fdiv double %33, 2.000000e+00
%35 = fadd double %32, %34
%36 = fcmp ogt double %35, 5.000000e+00
br i1 %36, label %37, label %39
37: ; preds = %27
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %41
39: ; preds = %27
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %41
41: ; preds = %39, %37
%42 = load double, double* %6
%43 = load double, double* %7
%44 = fadd double %42, %43
%45 = fdiv double %44, 2.000000e+00
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), double %45)
br label %49
47: ; preds = %24
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %49
49: ; preds = %47, %41
br label %50
50: ; preds = %49, %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"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [21 x i8] c"Nota do exame: %.1f\0A\00"
@.str.7 = [19 x i8] c"Media final: %.1f\0A\00"
@str.8 = [16 x i8] c"Aluno em exame.\00"
@str.9 = [17 x i8] c"Aluno reprovado.\00"
@str.11 = [16 x i8] c"Aluno aprovado.\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 = bitcast double* %5 to i8*
%11 = 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)
%12 = load double, double* %1
%13 = load double, double* %2
%14 = fmul double %13, 3.000000e+00
%15 = call double @llvm.fmuladd.f64(double %12, double 2.000000e+00, double %14)
%16 = load double, double* %3
%17 = call double @llvm.fmuladd.f64(double %16, double 4.000000e+00, double %15)
%18 = load double, double* %4
%19 = fadd double %18, %17
%20 = fdiv double %19, 1.000000e+01
%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 double %20, 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.11, i64 0, i64 0))
br label %44
25: ; preds = %0
%26 = fcmp ult double %20, 5.000000e+00
br i1 %26, label %42, label %27
27: ; preds = %25
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.8, i64 0, i64 0))
%29 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %5)
%30 = load double, double* %5
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), double %30)
%32 = load double, double* %5
%33 = fmul double %20, 5.000000e-01
%34 = fadd double %33, %32
%35 = fcmp ogt double %34, 5.000000e+00
%36 = select i1 %35, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0)
%37 = call i32 @puts(i8* dereferenceable(1) %36)
%38 = load double, double* %5
%39 = fadd double %20, %38
%40 = fmul double %39, 5.000000e-01
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), double %40)
br label %44
42: ; preds = %25
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0))
br label %44
44: ; preds = %27, %42, %23
ret i32 0
}