#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 somatorio = 0;
  double inNota;
  double menorNota = 11;
  char temMenorQue3 = 0;
  printf("Insira as notas das 3 unidades: ");
  int i = 0;
  for (i = 0; i < 3; i++) {
    scanf(" %lf", &inNota);
    somatorio += inNota;
    if (inNota < menorNota)
      menorNota = inNota;
    if (inNota < 3.0)
      temMenorQue3 = 1;
  }
  if ((somatorio / 3 >= 7.0) || (somatorio / 3 >= 5.0 && !temMenorQue3)) {
    printf("Aprovado.\n");
  } else {
    printf("Em reposição...\nDigite a nota da reposição: ");
    scanf(" %lf", &inNota);
    somatorio = somatorio - menorNota + inNota;
    if (somatorio / 3 >= 5.0) {
      printf("Aprovado.\n");
    } else {
      printf("Reprovado.\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xec1(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movb   $0x0,-0x21(%rbp)
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    11d3 <main+0xb3>
lea    0xece(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a9 <main+0x89>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe5f(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11c0 <main+0xa0>
movb   $0x1,-0x21(%rbp)
jmp    11c5 <main+0xa5>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1162 <main+0x42>
movsd  -0x10(%rbp),%xmm0
movsd  0xe30(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe1c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    1223 <main+0x103>
movsd  -0x10(%rbp),%xmm0
movsd  0xe0d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe09(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1234 <main+0x114>
cmpb   $0x0,-0x21(%rbp)
jne    1234 <main+0x114>
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
jmp    12a9 <main+0x189>
lea    0xe16(%rip),%rdi
call   1030 <printf@plt>
lea    0xdfa(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xd9f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd9b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1298 <main+0x178>
lea    0xdb8(%rip),%rdi
call   1030 <printf@plt>
jmp    12a4 <main+0x184>
lea    0xde3(%rip),%rdi
call   1030 <printf@plt>
jmp    12a9 <main+0x189>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xee2(%rip),%rdi
call   1040 <printf@plt>
lea    0xef7(%rip),%rbx
lea    0x10(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
movsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x18(%rsp)
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm3
addsd  %xmm3,%xmm1
movapd %xmm1,%xmm0
divsd  0xe46(%rip),%xmm0
lea    0xeb9(%rip),%rdi
ucomisd 0xe3f(%rip),%xmm0
jae    1274 <main+0x144>
ucomisd 0xe39(%rip),%xmm0
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm4
jb     1207 <main+0xd7>
movsd  0xe13(%rip),%xmm0
ucomisd %xmm3,%xmm0
ja     1207 <main+0xd7>
ucomisd %xmm4,%xmm0
ja     1207 <main+0xd7>
ucomisd %xmm2,%xmm0
jbe    1274 <main+0x144>
minsd  0xdf1(%rip),%xmm2
minsd  %xmm2,%xmm4
minsd  %xmm4,%xmm3
movsd  %xmm3,0x18(%rsp)
lea    0xe22(%rip),%rdi
movsd  %xmm1,0x8(%rsp)
call   1040 <printf@plt>
lea    0xe0b(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <scanf@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
divsd  0xdae(%rip),%xmm0
ucomisd 0xdb6(%rip),%xmm0
lea    0xe0e(%rip),%rax
lea    0xe12(%rip),%rdi
cmovb  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Insira as notas das 3 unidades: \00"
@.str.1 = [5 x i8] c" %lf\00"
@.str.2 = [11 x i8] c"Aprovado.\0A\00"
@.str.3 = [49 x i8] c"Em reposi\C3\A7\C3\A3o...\0ADigite a nota da reposi\C3\A7\C3\A3o: \00"
@.str.4 = [12 x i8] c"Reprovado.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i8
%6 = alloca i32
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store double 1.100000e+01, double* %4
store i8 0, i8* %5
%7 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
store i32 0, i32* %6
br label %8
8: ; preds = %26, %0
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %3)
%13 = load double, double* %3
%14 = load double, double* %2
%15 = fadd double %14, %13
store double %15, double* %2
%16 = load double, double* %3
%17 = load double, double* %4
%18 = fcmp olt double %16, %17
br i1 %18, label %19, label %21
19: ; preds = %11
%20 = load double, double* %3
store double %20, double* %4
br label %21
21: ; preds = %19, %11
%22 = load double, double* %3
%23 = fcmp olt double %22, 3.000000e+00
br i1 %23, label %24, label %25
24: ; preds = %21
store i8 1, i8* %5
br label %25
25: ; preds = %24, %21
br label %26
26: ; preds = %25
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %8
29: ; preds = %8
%30 = load double, double* %2
%31 = fdiv double %30, 3.000000e+00
%32 = fcmp oge double %31, 7.000000e+00
br i1 %32, label %40, label %33
33: ; preds = %29
%34 = load double, double* %2
%35 = fdiv double %34, 3.000000e+00
%36 = fcmp oge double %35, 5.000000e+00
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load i8, i8* %5
%39 = icmp ne i8 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37, %29
%41 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %58
42: ; preds = %37, %33
%43 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
%44 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %3)
%45 = load double, double* %2
%46 = load double, double* %4
%47 = fsub double %45, %46
%48 = load double, double* %3
%49 = fadd double %47, %48
store double %49, double* %2
%50 = load double, double* %2
%51 = fdiv double %50, 3.000000e+00
%52 = fcmp oge double %51, 5.000000e+00
br i1 %52, label %53, label %55
53: ; preds = %42
%54 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %57
55: ; preds = %42
%56 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %57
57: ; preds = %55, %53
br label %58
58: ; preds = %57, %40
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Insira as notas das 3 unidades: \00"
@.str.1 = [5 x i8] c" %lf\00"
@.str.3 = [49 x i8] c"Em reposi\C3\A7\C3\A3o...\0ADigite a nota da reposi\C3\A7\C3\A3o: \00"
@str.5 = [11 x i8] c"Reprovado.\00"
@str.6 = [10 x i8] c"Aprovado.\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = fadd double %5, 0.000000e+00
%7 = fcmp olt double %5, 1.100000e+01
%8 = select i1 %7, double %5, double 1.100000e+01
%9 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %1)
%10 = load double, double* %1
%11 = fadd double %6, %10
%12 = fcmp olt double %10, %8
%13 = select i1 %12, double %10, double %8
%14 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %1)
%15 = load double, double* %1
%16 = fadd double %11, %15
%17 = fcmp olt double %15, %13
%18 = select i1 %17, double %15, double %13
%19 = fdiv double %16, 3.000000e+00
%20 = fcmp ult double %19, 7.000000e+00
br i1 %20, label %21, label %38
21: ; preds = %0
%22 = fcmp olt double %15, 3.000000e+00
%23 = fcmp olt double %5, 3.000000e+00
%24 = fcmp olt double %10, 3.000000e+00
%25 = fcmp ult double %19, 5.000000e+00
%26 = select i1 %25, i1 true, i1 %22
%27 = select i1 %26, i1 true, i1 %24
%28 = select i1 %27, i1 true, i1 %23
br i1 %28, label %29, label %38
29: ; preds = %21
%30 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %1)
%32 = fsub double %16, %18
%33 = load double, double* %1
%34 = fadd double %32, %33
%35 = fdiv double %34, 3.000000e+00
%36 = fcmp ult double %35, 5.000000e+00
%37 = select i1 %36, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str.6, i64 0, i64 0)
br label %38
38: ; preds = %29, %0, %21
%39 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.6, i64 0, i64 0), %21 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.6, i64 0, i64 0), %0 ], [ %37, %29 ]
%40 = call i32 @puts(i8* dereferenceable(1) %39)
ret i32 0
}