#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(void) {
  double nota, soma = 0.0;
  int quantidadeDeNotasValidas = 0;
  while (quantidadeDeNotasValidas < 2) {
    scanf("%lf\n", &nota);
    if (nota < 0 || nota > 10) {
      printf("nota invalida\n");
    } else {
      soma += nota;
      quantidadeDeNotasValidas++;
    }
  }
  printf("media = %.2f\n", soma / 2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    11ad <main+0x8d>
lea    0xec1(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     117d <main+0x5d>
movsd  -0x10(%rbp),%xmm0
movsd  0xe95(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1190 <main+0x70>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a8 <main+0x88>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113e <main+0x1e>
movsd  -0x18(%rbp),%xmm0
movsd  0xe46(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe5f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %ebp,%ebp
lea    0xed5(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xedc(%rip),%r15
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    116d <main+0x3d>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <puts@plt>
cmp    $0x2,%ebp
jge    11aa <main+0x7a>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1160 <main+0x30>
ucomisd 0xe70(%rip),%xmm0
ja     1160 <main+0x30>
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
add    $0x1,%ebp
cmp    $0x2,%ebp
jl     116d <main+0x3d>
movsd  0x8(%rsp),%xmm0
mulsd  0xe50(%rip),%xmm0
lea    0xe5e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lf\0A\00"
@.str.1 = [15 x i8] c"nota invalida\0A\00"
@.str.2 = [14 x i8] c"media = %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store i32 0, i32* %1
store double 0.000000e+00, double* %3
store i32 0, i32* %4
br label %5
5: ; preds = %23, %0
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double* %2)
%10 = load double, double* %2
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = load double, double* %2
%14 = fcmp ogt double %13, 1.000000e+01
br i1 %14, label %15, label %17
15: ; preds = %12, %8
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %23
17: ; preds = %12
%18 = load double, double* %2
%19 = load double, double* %3
%20 = fadd double %19, %18
store double %20, double* %3
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %23
23: ; preds = %17, %15
br label %5
24: ; preds = %5
%25 = load double, double* %3
%26 = fdiv double %25, 2.000000e+00
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lf\0A\00"
@.str.2 = [14 x i8] c"media = %.2f\0A\00"
@str = [14 x i8] c"nota invalida\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
br label %3
3: ; preds = %0, %16
%4 = phi i32 [ 0, %0 ], [ %18, %16 ]
%5 = phi double [ 0.000000e+00, %0 ], [ %17, %16 ]
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double* %1)
%7 = load double, double* %1
%8 = fcmp olt double %7, 0.000000e+00
%9 = fcmp ogt double %7, 1.000000e+01
%10 = or i1 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %16
13: ; preds = %3
%14 = fadd double %5, %7
%15 = add nsw i32 %4, 1
br label %16
16: ; preds = %13, %11
%17 = phi double [ %5, %11 ], [ %14, %13 ]
%18 = phi i32 [ %4, %11 ], [ %15, %13 ]
%19 = icmp slt i32 %18, 2
br i1 %19, label %3, label %20
20: ; preds = %16
%21 = fmul double %17, 5.000000e-01
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %21)
ret i32 0
}