#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 *, ...);
int main(void) {
  double nota, soma;
  int quantidadeDeNotasValidas, opcao;
  do {
    soma = 0.0;
    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);
    do {
      printf("novo calculo (1-sim 2-nao)\n");
      scanf("%d\n", &opcao);
    } while (opcao != 1 && opcao != 2);
    if (opcao == 2) {
      break;
    }
  } while (1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    11af <main+0x8f>
lea    0xec1(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     117f <main+0x5f>
movsd  -0x10(%rbp),%xmm0
movsd  0xe93(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1192 <main+0x72>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11aa <main+0x8a>
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  0xe44(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe5d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
xor    %eax,%eax
cmpl   $0x1,-0x20(%rbp)
mov    %al,-0x21(%rbp)
je     1207 <main+0xe7>
cmpl   $0x2,-0x20(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11ce <main+0xae>
cmpl   $0x2,-0x20(%rbp)
jne    1221 <main+0x101>
jmp    1235 <main+0x115>
jmp    1226 <main+0x106>
mov    $0x1,%al
test   $0x1,%al
jne    112f <main+0xf>
jmp    1235 <main+0x115>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xed3(%rip),%r14
lea    0x10(%rsp),%r13
lea    0xede(%rip),%rbx
lea    0xed3(%rip),%rbp
lea    0x4(%rsp),%r15
xor    %r12d,%r12d
xorpd  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     11c0 <main+0x90>
ucomisd 0xe65(%rip),%xmm0
ja     11c0 <main+0x90>
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x1,%r12d
cmp    $0x2,%r12d
jl     1170 <main+0x40>
jmp    11d8 <main+0xa8>
nopw   0x0(%rax,%rax,1)
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm0
cmp    $0x2,%r12d
jl     1170 <main+0x40>
mulsd  0xe28(%rip),%xmm0
lea    0xe36(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x3(%rax),%ecx
cmp    $0xfffffffe,%ecx
jb     11f0 <main+0xc0>
mov    $0x0,%r12d
xorpd  %xmm0,%xmm0
cmp    $0x2,%eax
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
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"
@.str.3 = [28 x i8] c"novo calculo (1-sim 2-nao)\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %46, %0
store double 0.000000e+00, double* %3
store i32 0, i32* %4
br label %7
7: ; preds = %25, %6
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double* %2)
%12 = load double, double* %2
%13 = fcmp olt double %12, 0.000000e+00
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = load double, double* %2
%16 = fcmp ogt double %15, 1.000000e+01
br i1 %16, label %17, label %19
17: ; preds = %14, %10
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %25
19: ; preds = %14
%20 = load double, double* %2
%21 = load double, double* %3
%22 = fadd double %21, %20
store double %22, double* %3
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %25
25: ; preds = %19, %17
br label %7
26: ; preds = %7
%27 = load double, double* %3
%28 = fdiv double %27, 2.000000e+00
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %28)
br label %30
30: ; preds = %39, %26
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %5)
br label %33
33: ; preds = %30
%34 = load i32, i32* %5
%35 = icmp ne i32 %34, 1
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* %5
%38 = icmp ne i32 %37, 2
br label %39
39: ; preds = %36, %33
%40 = phi i1 [ false, %33 ], [ %38, %36 ]
br i1 %40, label %30, label %41
41: ; preds = %39
%42 = load i32, i32* %5
%43 = icmp eq i32 %42, 2
br i1 %43, label %44, label %45
44: ; preds = %41
br label %47
45: ; preds = %41
br label %46
46: ; preds = %45
br i1 true, label %6, label %47
47: ; preds = %46, %44
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.4 = [4 x i8] c"%d\0A\00"
@str = [27 x i8] c"novo calculo (1-sim 2-nao)\00"
@str.5 = [14 x i8] c"nota invalida\00"
define i32 @main() {
%1 = alloca double
%2 = alloca i32
%3 = bitcast double* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %22, %0
%6 = phi i32 [ 0, %0 ], [ %23, %22 ]
%7 = phi double [ 0.000000e+00, %0 ], [ %24, %22 ]
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double* %1)
%9 = load double, double* %1
%10 = fcmp olt double %9, 0.000000e+00
%11 = fcmp ogt double %9, 1.000000e+01
%12 = or i1 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %5
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.5, i64 0, i64 0))
br label %18
15: ; preds = %5
%16 = fadd double %7, %9
%17 = add nsw i32 %6, 1
br label %18
18: ; preds = %15, %13
%19 = phi double [ %7, %13 ], [ %16, %15 ]
%20 = phi i32 [ %6, %13 ], [ %17, %15 ]
%21 = icmp slt i32 %20, 2
br i1 %21, label %22, label %25
22: ; preds = %18, %34
%23 = phi i32 [ %20, %18 ], [ 0, %34 ]
%24 = phi double [ %19, %18 ], [ 0.000000e+00, %34 ]
br label %5
25: ; preds = %18
%26 = fmul double %19, 5.000000e-01
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %26)
br label %28
28: ; preds = %28, %25
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%31 = load i32, i32* %2
%32 = add i32 %31, -3
%33 = icmp ult i32 %32, -2
br i1 %33, label %28, label %34
34: ; preds = %28
%35 = icmp eq i32 %31, 2
br i1 %35, label %36, label %22
36: ; preds = %34
ret i32 0
}