#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, f;
  scanf("%lf %lf %lf %lf", &a, &b, &c, &d);
  f = 2 * a + 3 * b + 4 * c + d;
  printf("Media: %.1lf\n", f / 10);
  if (f < 50) {
    printf("Aluno reprovado.\n");
    return 0;
  }
  if (f >= 70) {
    printf("Aluno aprovado.\n");
    return 0;
  }
  printf("Aluno em exame.\n");
  scanf("%lf", &e);
  printf("Nota do exame: %.1lf\n", e);
  if (f + 10 * e >= 20.0)
    printf("Aluno aprovado.\n");
  else
    printf("Aluno reprovado.\n");
  printf("Media final: %.1lf\n", (f + 10 * e) / 20);
  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  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe75(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xea2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe53(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    11d2 <main+0xb2>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12be <main+0x19e>
movsd  -0x38(%rbp),%xmm0
movsd  0xe41(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1203 <main+0xe3>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12be <main+0x19e>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe24(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xe53(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  0xdc0(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdd0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1275 <main+0x155>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1283 <main+0x163>
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  0xd73(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd83(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xde8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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),%xmm0
movsd  0x28(%rsp),%xmm1
mulsd  0xe96(%rip),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0x20(%rsp),%xmm1
mulsd  0xe88(%rip),%xmm1
addsd  %xmm0,%xmm1
addsd  0x18(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
divsd  0xe74(%rip),%xmm0
lea    0xe9d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0xe66(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jbe    11ca <main+0x9a>
lea    0xed3(%rip),%rdi
jmp    1275 <main+0x145>
movapd %xmm1,%xmm0
ucomisd 0xe4a(%rip),%xmm1
jae    126e <main+0x13e>
lea    0xe95(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4d(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsd  0x10(%rsp),%xmm0
lea    0xe46(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x10(%rsp),%xmm0
mulsd  0xdf3(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
ucomisd 0xdfd(%rip),%xmm0
lea    0xe66(%rip),%rax
lea    0xe4f(%rip),%rdi
cmovb  %rax,%rdi
call   1030 <puts@plt>
movsd  0xdc6(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
divsd  0xdca(%rip),%xmm0
lea    0xdff(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    127a <main+0x14a>
lea    0xe13(%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 = [14 x i8] c"Media: %.1lf\0A\00"
@.str.2 = [18 x i8] c"Aluno reprovado.\0A\00"
@.str.3 = [17 x i8] c"Aluno aprovado.\0A\00"
@.str.4 = [17 x i8] c"Aluno em exame.\0A\00"
@.str.5 = [4 x i8] c"%lf\00"
@.str.6 = [22 x i8] c"Nota do exame: %.1lf\0A\00"
@.str.7 = [20 x i8] c"Media final: %.1lf\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 3.000000e+00, %10
%12 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %9, double %11)
%13 = load double, double* %4
%14 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %13, double %12)
%15 = load double, double* %5
%16 = fadd double %14, %15
store double %16, double* %7
%17 = load double, double* %7
%18 = fdiv double %17, 1.000000e+01
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), double %18)
%20 = load double, double* %7
%21 = fcmp olt double %20, 5.000000e+01
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))
store i32 0, i32* %1
br label %48
24: ; preds = %0
%25 = load double, double* %7
%26 = fcmp oge double %25, 7.000000e+01
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %48
29: ; preds = %24
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %6)
%32 = load double, double* %6
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), double %32)
%34 = load double, double* %7
%35 = load double, double* %6
%36 = call double @llvm.fmuladd.f64(double 1.000000e+01, double %35, double %34)
%37 = fcmp oge double %36, 2.000000e+01
br i1 %37, label %38, label %40
38: ; preds = %29
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %42
40: ; preds = %29
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %42
42: ; preds = %40, %38
%43 = load double, double* %7
%44 = load double, double* %6
%45 = call double @llvm.fmuladd.f64(double 1.000000e+01, double %44, double %43)
%46 = fdiv double %45, 2.000000e+01
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), double %46)
store i32 0, i32* %1
br label %48
48: ; preds = %42, %27, %22
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@.str = [16 x i8] c"%lf %lf %lf %lf\00"
@.str.1 = [14 x i8] c"Media: %.1lf\0A\00"
@.str.5 = [4 x i8] c"%lf\00"
@.str.6 = [22 x i8] c"Nota do exame: %.1lf\0A\00"
@.str.7 = [20 x i8] c"Media final: %.1lf\0A\00"
@str = [16 x i8] c"Aluno em exame.\00"
@str.10 = [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 = 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 ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), double %20)
%22 = fcmp olt double %19, 5.000000e+01
br i1 %22, label %23, label %25
23: ; preds = %0
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.11, i64 0, i64 0))
br label %43
25: ; preds = %0
%26 = fcmp ult double %19, 7.000000e+01
br i1 %26, label %29, label %27
27: ; preds = %25
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.10, i64 0, i64 0))
br label %43
29: ; preds = %25
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%31 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %5)
%32 = load double, double* %5
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), double %32)
%34 = load double, double* %5
%35 = call double @llvm.fmuladd.f64(double %34, double 1.000000e+01, double %19)
%36 = fcmp ult double %35, 2.000000e+01
%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.10, i64 0, i64 0)
%38 = call i32 @puts(i8* dereferenceable(1) %37)
%39 = load double, double* %5
%40 = call double @llvm.fmuladd.f64(double %39, double 1.000000e+01, double %19)
%41 = fdiv double %40, 2.000000e+01
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), double %41)
br label %43
43: ; preds = %29, %27, %23
ret i32 0
}