#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 *, float *);
int main() {
  int i, c = 0;
  float sum = 0, ave, a, n;
  while (1) {
    scanf("%f", &n);
    if (n < 0 || n > 10) {
      printf("nota invalida\n");
    } else if (n >= 0 && n <= 10) {
      sum = sum + n;
      c = c + 1;
      if (c == 2) {
        ave = sum / 2;
        printf("media = %0.2f\n", ave);
        break;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomiss -0x1c(%rbp),%xmm0
ja     1171 <main+0x51>
movss  -0x1c(%rbp),%xmm0
movss  0xe98(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1184 <main+0x64>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1205 <main+0xe5>
movss  -0x1c(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1200 <main+0xe0>
movss  0xe63(%rip),%xmm0
ucomiss -0x1c(%rbp),%xmm0
jb     1200 <main+0xe0>
movss  -0x10(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jne    11fb <main+0xdb>
movss  -0x10(%rbp),%xmm0
movss  0xe2e(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    120a <main+0xea>
jmp    1200 <main+0xe0>
jmp    1205 <main+0xe5>
jmp    113e <main+0x1e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xecc(%rip),%r14
lea    0x8(%rsp),%rbx
lea    0xed2(%rip),%r15
jmp    1158 <main+0x28>
xchg   %ax,%ax
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm1,%xmm0
ja     1150 <main+0x20>
ucomiss 0xe88(%rip),%xmm1
ja     1150 <main+0x20>
ucomiss 0xe87(%rip),%xmm1
jb     1158 <main+0x28>
movss  0xe75(%rip),%xmm0
ucomiss %xmm1,%xmm0
jb     1158 <main+0x28>
movss  %xmm1,0xc(%rsp)
lea    0xe6f(%rip),%r14
lea    0x8(%rsp),%rbx
lea    0xe75(%rip),%r15
jmp    11b8 <main+0x88>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     11b0 <main+0x80>
ucomiss 0xe28(%rip),%xmm0
ja     11b0 <main+0x80>
ucomiss 0xe27(%rip),%xmm0
jb     11b8 <main+0x88>
movss  0xe15(%rip),%xmm1
ucomiss %xmm0,%xmm1
jb     11b8 <main+0x88>
xorps  %xmm1,%xmm1
movss  0xc(%rsp),%xmm2
addss  %xmm1,%xmm2
addss  %xmm0,%xmm2
mulss  0xdfb(%rip),%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
lea    0xdf8(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%f\00"
@.str.1 = [15 x i8] c"nota invalida\0A\00"
@.str.2 = [15 x i8] c"media = %0.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store i32 0, i32* %1
store i32 0, i32* %3
store float 0.000000e+00, float* %4
br label %8
8: ; preds = %0, %39
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %7)
%10 = load float, float* %7
%11 = fcmp olt float %10, 0.000000e+00
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = load float, float* %7
%14 = fcmp ogt float %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 %39
17: ; preds = %12
%18 = load float, float* %7
%19 = fcmp oge float %18, 0.000000e+00
br i1 %19, label %20, label %38
20: ; preds = %17
%21 = load float, float* %7
%22 = fcmp ole float %21, 1.000000e+01
br i1 %22, label %23, label %38
23: ; preds = %20
%24 = load float, float* %4
%25 = load float, float* %7
%26 = fadd float %24, %25
store float %26, float* %4
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 2
br i1 %30, label %31, label %37
31: ; preds = %23
%32 = load float, float* %4
%33 = fdiv float %32, 2.000000e+00
store float %33, float* %5
%34 = load float, float* %5
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %35)
br label %40
37: ; preds = %23
br label %38
38: ; preds = %37, %20, %17
br label %39
39: ; preds = %38, %15
br label %8
40: ; preds = %31
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
@.str.2 = [15 x i8] c"media = %0.2f\0A\00"
@str = [14 x i8] c"nota invalida\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
br label %3
3: ; preds = %15, %0
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%5 = load float, float* %1
%6 = fcmp olt float %5, 0.000000e+00
%7 = fcmp ogt float %5, 1.000000e+01
%8 = or i1 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %15
11: ; preds = %3
%12 = fcmp oge float %5, 0.000000e+00
%13 = fcmp ole float %5, 1.000000e+01
%14 = and i1 %12, %13
br i1 %14, label %16, label %15
15: ; preds = %11, %9
br label %3
16: ; preds = %11, %34
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%18 = load float, float* %1
%19 = fcmp olt float %18, 0.000000e+00
%20 = fcmp ogt float %18, 1.000000e+01
%21 = or i1 %19, %20
br i1 %21, label %32, label %22
22: ; preds = %16
%23 = fcmp oge float %18, 0.000000e+00
%24 = fcmp ole float %18, 1.000000e+01
%25 = and i1 %23, %24
br i1 %25, label %26, label %34
26: ; preds = %22
%27 = fadd float %5, 0.000000e+00
%28 = fadd float %27, %18
%29 = fmul float %28, 5.000000e-01
%30 = fpext float %29 to double
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %30)
ret i32 0
32: ; preds = %16
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %34
34: ; preds = %32, %22
br label %16
}