#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 nota, media = 0, cont_v = 0;
  do {
    scanf(" %lf", &nota);
    if (nota >= 0.0 && nota <= 10.0) {
      cont_v++;
      media += nota;
    } else
      printf("nota invalida\n");
  } while (cont_v < 2);
  printf("media = %0.2lf\n", media / 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)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xed2(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     119a <main+0x7a>
movsd  0xe97(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     119a <main+0x7a>
movsd  0xe8c(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11a8 <main+0x88>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ad <main+0x8d>
movsd  0xe5b(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
ja     113f <main+0x1f>
movsd  -0x18(%rbp),%xmm0
movsd  0xe43(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe54(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xee8(%rip),%r14
lea    0x18(%rsp),%rbx
lea    0xef1(%rip),%r15
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm2,%xmm2
jmp    117c <main+0x4c>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1030 <puts@plt>
movsd  0x10(%rsp),%xmm2
movsd  0xe9a(%rip),%xmm0
ucomisd %xmm2,%xmm0
jbe    11cb <main+0x9b>
movsd  %xmm2,0x10(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movsd  0x18(%rsp),%xmm0
ucomisd 0xe85(%rip),%xmm0
jb     1160 <main+0x30>
movsd  0xe5b(%rip),%xmm1
ucomisd %xmm0,%xmm1
jb     1160 <main+0x30>
movsd  0x10(%rsp),%xmm2
addsd  0xe4f(%rip),%xmm2
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
jmp    116e <main+0x3e>
movsd  0x8(%rsp),%xmm0
mulsd  0xe3f(%rip),%xmm0
lea    0xe4d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c" %lf\00"
@.str.2 = [16 x i8] c"media = %0.2lf\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 = %16, %0
%4 = phi double [ 0.000000e+00, %0 ], [ %17, %16 ]
%5 = phi double [ 0.000000e+00, %0 ], [ %18, %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 oge double %7, 0.000000e+00
%9 = fcmp ole double %7, 1.000000e+01
%10 = and i1 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = fadd double %5, 1.000000e+00
%13 = fadd double %4, %7
br label %16
14: ; preds = %3
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %11, %14
%17 = phi double [ %13, %11 ], [ %4, %14 ]
%18 = phi double [ %12, %11 ], [ %5, %14 ]
%19 = fcmp olt double %18, 2.000000e+00
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 ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %21)
ret i32 0
}