#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;
  float sum, ave, a, n;
  do {
    c = 0;
    sum = 0;
    while (c < 2) {
      scanf("%f", &n);
      if (n >= 0 && n <= 10) {
        sum = sum + n;
        c = c + 1;
        if (c == 2) {
          ave = sum / 2;
        }
      } else {
        printf("nota invalida\n");
      }
    }
    printf("media = %0.2f\n", ave);
    do {
      printf("novo calculo (1-sim 2-nao)\n");
      scanf("%f", &n);
    } while (n != 1 && n != 2);
  } while (n != 2);
  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)
cmpl   $0x2,-0xc(%rbp)
jge    11cb <main+0xab>
lea    0xebd(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x1c(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     11b8 <main+0x98>
movss  0xe97(%rip),%xmm0
ucomiss -0x1c(%rbp),%xmm0
jb     11b8 <main+0x98>
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    11b3 <main+0x93>
movss  -0x10(%rbp),%xmm0
movss  0xe5a(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11c6 <main+0xa6>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    113e <main+0x1e>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe43(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe15(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x1c(%rbp),%xmm0
xor    %eax,%eax
movss  0xdf1(%rip),%xmm1
ucomiss %xmm1,%xmm0
mov    %al,-0x1d(%rbp)
jne    1226 <main+0x106>
jp     1226 <main+0x106>
jmp    1241 <main+0x121>
movss  -0x1c(%rbp),%xmm0
movss  0xdd1(%rip),%xmm1
ucomiss %xmm1,%xmm0
setne  %al
setp   %cl
or     %cl,%al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11e2 <main+0xc2>
jmp    1251 <main+0x131>
movss  -0x1c(%rbp),%xmm0
movss  0xda6(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    112f <main+0xf>
jp     112f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %ebp,%ebp
lea    0xecd(%rip),%r14
lea    0x14(%rsp),%rbx
lea    0xec4(%rip),%r15
lea    0xecc(%rip),%r12
lea    0xee0(%rip),%r13
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
jmp    118d <main+0x5d>
nopl   0x0(%rax)
ucomiss 0xe95(%rip),%xmm0
mov    $0x0,%ebp
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
jne    118d <main+0x5d>
jnp    1258 <main+0x128>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm0
ucomiss 0xe6b(%rip),%xmm0
jb     11f0 <main+0xc0>
movss  0xe51(%rip),%xmm1
ucomiss %xmm0,%xmm1
jb     11f0 <main+0xc0>
movss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
add    $0x1,%ebp
movss  %xmm1,0xc(%rsp)
movaps %xmm1,%xmm0
mulss  0xe32(%rip),%xmm0
cmp    $0x2,%ebp
je     11dd <main+0xad>
movss  0x10(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
cmp    $0x2,%ebp
jl     118d <main+0x5d>
jmp    11fd <main+0xcd>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1030 <puts@plt>
cmp    $0x2,%ebp
jl     118d <main+0x5d>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm0
ucomiss 0xdc8(%rip),%xmm0
jne    1248 <main+0x118>
jnp    1170 <main+0x40>
ucomiss 0xdbd(%rip),%xmm0
jne    1220 <main+0xf0>
jp     1220 <main+0xf0>
jmp    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 = [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"
@.str.3 = [28 x i8] c"novo calculo (1-sim 2-nao)\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
br label %8
8: ; preds = %50, %0
store i32 0, i32* %3
store float 0.000000e+00, float* %4
br label %9
9: ; preds = %33, %8
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %34
12: ; preds = %9
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %7)
%14 = load float, float* %7
%15 = fcmp oge float %14, 0.000000e+00
br i1 %15, label %16, label %31
16: ; preds = %12
%17 = load float, float* %7
%18 = fcmp ole float %17, 1.000000e+01
br i1 %18, label %19, label %31
19: ; preds = %16
%20 = load float, float* %4
%21 = load float, float* %7
%22 = fadd float %20, %21
store float %22, float* %4
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 2
br i1 %26, label %27, label %30
27: ; preds = %19
%28 = load float, float* %4
%29 = fdiv float %28, 2.000000e+00
store float %29, float* %5
br label %30
30: ; preds = %27, %19
br label %33
31: ; preds = %16, %12
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %31, %30
br label %9
34: ; preds = %9
%35 = load float, float* %5
%36 = fpext float %35 to double
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %36)
br label %38
38: ; preds = %47, %34
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %7)
br label %41
41: ; preds = %38
%42 = load float, float* %7
%43 = fcmp une float %42, 1.000000e+00
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load float, float* %7
%46 = fcmp une float %45, 2.000000e+00
br label %47
47: ; preds = %44, %41
%48 = phi i1 [ false, %41 ], [ %46, %44 ]
br i1 %48, label %38, label %49
49: ; preds = %47
br label %50
50: ; preds = %49
%51 = load float, float* %7
%52 = fcmp une float %51, 2.000000e+00
br i1 %52, label %8, label %53
53: ; preds = %50
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 = [27 x i8] c"novo calculo (1-sim 2-nao)\00"
@str.4 = [14 x i8] c"nota invalida\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
br label %3
3: ; preds = %25, %0
%4 = phi i32 [ 0, %0 ], [ %26, %25 ]
%5 = phi float [ undef, %0 ], [ %22, %25 ]
%6 = phi float [ 0.000000e+00, %0 ], [ %27, %25 ]
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%8 = load float, float* %1
%9 = fcmp oge float %8, 0.000000e+00
%10 = fcmp ole float %8, 1.000000e+01
%11 = and i1 %9, %10
br i1 %11, label %12, label %18
12: ; preds = %3
%13 = fadd float %6, %8
%14 = add nsw i32 %4, 1
%15 = icmp eq i32 %14, 2
%16 = fmul float %13, 5.000000e-01
%17 = select i1 %15, float %16, float %5
br label %20
18: ; preds = %3
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.4, i64 0, i64 0))
br label %20
20: ; preds = %12, %18
%21 = phi float [ %6, %18 ], [ %13, %12 ]
%22 = phi float [ %5, %18 ], [ %17, %12 ]
%23 = phi i32 [ %4, %18 ], [ %14, %12 ]
%24 = icmp slt i32 %23, 2
br i1 %24, label %25, label %28
25: ; preds = %20, %38
%26 = phi i32 [ %23, %20 ], [ 0, %38 ]
%27 = phi float [ %21, %20 ], [ 0.000000e+00, %38 ]
br label %3
28: ; preds = %20
%29 = fpext float %22 to double
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %29)
br label %31
31: ; preds = %31, %28
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%34 = load float, float* %1
%35 = fcmp une float %34, 1.000000e+00
%36 = fcmp une float %34, 2.000000e+00
%37 = and i1 %35, %36
br i1 %37, label %31, label %38
38: ; preds = %31
br i1 %36, label %25, label %39
39: ; preds = %38
ret i32 0
}