#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 *, ...);
main() {
  double a, b;
  int x = 1;
  while (x == 1) {
    scanf("%lf", &a);
    while (a < 0 || a > 10) {
      if (a < 0 || a > 0) {
        printf("nota invalida\n");
        scanf("%lf", &a);
      }
    }
    scanf("%lf", &b);
    while (b < 0 || b > 10) {
      if (b < 0 || b > 0) {
        printf("nota invalida\n");
        scanf("%lf", &b);
      }
    }
    printf("media = %.2lf\n", (a + b) / 2);
    printf("novo calculo (1-sim 2-nao)\n");
    scanf("%d", &x);
    while (x < 1 || x > 2) {
      printf("novo calculo (1-sim 2-nao)\n");
      scanf("%d", &x);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    12f9 <main+0x1d9>
lea    0xec9(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    $0x1,%al
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
mov    %al,-0x1d(%rbp)
ja     117c <main+0x5c>
movsd  -0x10(%rbp),%xmm0
movsd  0xe8e(%rip),%xmm1
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    118c <main+0x6c>
jmp    11d1 <main+0xb1>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     11ac <main+0x8c>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11cc <main+0xac>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4f(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    1152 <main+0x32>
lea    0xe38(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    $0x1,%al
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
mov    %al,-0x1e(%rbp)
ja     120d <main+0xed>
movsd  -0x18(%rbp),%xmm0
movsd  0xdfd(%rip),%xmm1
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%al
test   $0x1,%al
jne    121d <main+0xfd>
jmp    1262 <main+0x142>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
ja     123d <main+0x11d>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    125d <main+0x13d>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdbe(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    11e3 <main+0xc3>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xd94(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xda4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdb3(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x1c(%rbp)
mov    %al,-0x1f(%rbp)
jl     12bf <main+0x19f>
cmpl   $0x2,-0x1c(%rbp)
setg   %al
mov    %al,-0x1f(%rbp)
mov    -0x1f(%rbp),%al
test   $0x1,%al
jne    12cf <main+0x1af>
jmp    12f4 <main+0x1d4>
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd6a(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    12a6 <main+0x186>
jmp    1136 <main+0x16>
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
movl   $0x1,0x4(%rsp)
lea    0xec3(%rip),%rbx
lea    0xeed(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xec6(%rip),%rbp
lea    0xebc(%rip),%r13
lea    0x4(%rsp),%r14
jmp    1179 <main+0x49>
xchg   %ax,%ax
cmp    $0x1,%eax
jne    1296 <main+0x166>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
ucomisd %xmm0,%xmm1
ja     11b0 <main+0x80>
ucomisd 0xe52(%rip),%xmm0
jbe    11e0 <main+0xb0>
ucomisd %xmm1,%xmm0
je     11a0 <main+0x70>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
xorpd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm0
jmp    11a0 <main+0x70>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
xorpd  %xmm1,%xmm1
movsd  0x10(%rsp),%xmm0
ucomisd %xmm0,%xmm1
ja     1207 <main+0xd7>
ucomisd 0xdfb(%rip),%xmm0
jbe    1220 <main+0xf0>
ucomisd %xmm1,%xmm0
je     11f7 <main+0xc7>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    11e0 <main+0xb0>
nopw   0x0(%rax,%rax,1)
addsd  0x8(%rsp),%xmm0
mulsd  0xdda(%rip),%xmm0
lea    0xddf(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x3(%rax),%ecx
cmp    $0xfffffffd,%ecx
ja     1170 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x3(%rax),%ecx
cmp    $0xfffffffe,%ecx
jb     1270 <main+0x140>
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 = [4 x i8] c"%lf\00"
@.str.1 = [15 x i8] c"nota invalida\0A\00"
@.str.2 = [15 x i8] c"media = %.2lf\0A\00"
@.str.3 = [28 x i8] c"novo calculo (1-sim 2-nao)\0A\00"
@.str.4 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
br label %5
5: ; preds = %67, %0
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %68
8: ; preds = %5
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %2)
br label %10
10: ; preds = %27, %8
%11 = load double, double* %2
%12 = fcmp olt double %11, 0.000000e+00
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load double, double* %2
%15 = fcmp ogt double %14, 1.000000e+01
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ true, %10 ], [ %15, %13 ]
br i1 %17, label %18, label %28
18: ; preds = %16
%19 = load double, double* %2
%20 = fcmp olt double %19, 0.000000e+00
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load double, double* %2
%23 = fcmp ogt double %22, 0.000000e+00
br i1 %23, label %24, label %27
24: ; preds = %21, %18
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %2)
br label %27
27: ; preds = %24, %21
br label %10
28: ; preds = %16
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %3)
br label %30
30: ; preds = %47, %28
%31 = load double, double* %3
%32 = fcmp olt double %31, 0.000000e+00
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load double, double* %3
%35 = fcmp ogt double %34, 1.000000e+01
br label %36
36: ; preds = %33, %30
%37 = phi i1 [ true, %30 ], [ %35, %33 ]
br i1 %37, label %38, label %48
38: ; preds = %36
%39 = load double, double* %3
%40 = fcmp olt double %39, 0.000000e+00
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = load double, double* %3
%43 = fcmp ogt double %42, 0.000000e+00
br i1 %43, label %44, label %47
44: ; preds = %41, %38
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%46 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %3)
br label %47
47: ; preds = %44, %41
br label %30
48: ; preds = %36
%49 = load double, double* %2
%50 = load double, double* %3
%51 = fadd double %49, %50
%52 = fdiv double %51, 2.000000e+00
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%55 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
br label %56
56: ; preds = %64, %48
%57 = load i32, i32* %4
%58 = icmp slt i32 %57, 1
br i1 %58, label %62, label %59
59: ; preds = %56
%60 = load i32, i32* %4
%61 = icmp sgt i32 %60, 2
br label %62
62: ; preds = %59, %56
%63 = phi i1 [ true, %56 ], [ %61, %59 ]
br i1 %63, label %64, label %67
64: ; preds = %62
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%66 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
br label %56
67: ; preds = %62
br label %5
68: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.2 = [15 x i8] c"media = %.2lf\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@str.5 = [27 x i8] c"novo calculo (1-sim 2-nao)\00"
@str.7 = [14 x i8] c"nota invalida\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca i32
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast i32* %3 to i8*
store i32 1, i32* %3
br label %10
7: ; preds = %57, %46
%8 = phi i32 [ %54, %46 ], [ %60, %57 ]
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %63
10: ; preds = %0, %7
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%12 = load double, double* %1
%13 = fcmp olt double %12, 0.000000e+00
%14 = fcmp ogt double %12, 1.000000e+01
%15 = or i1 %13, %14
br i1 %15, label %16, label %28
16: ; preds = %10, %23
%17 = phi double [ %24, %23 ], [ %12, %10 ]
%18 = fcmp ueq double %17, 0.000000e+00
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.7, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%22 = load double, double* %1
br label %23
23: ; preds = %16, %19
%24 = phi double [ %17, %16 ], [ %22, %19 ]
%25 = fcmp olt double %24, 0.000000e+00
%26 = fcmp ogt double %24, 1.000000e+01
%27 = or i1 %25, %26
br i1 %27, label %16, label %28
28: ; preds = %23, %10
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %2)
%30 = load double, double* %2
%31 = fcmp olt double %30, 0.000000e+00
%32 = fcmp ogt double %30, 1.000000e+01
%33 = or i1 %31, %32
br i1 %33, label %34, label %46
34: ; preds = %28, %41
%35 = phi double [ %42, %41 ], [ %30, %28 ]
%36 = fcmp ueq double %35, 0.000000e+00
br i1 %36, label %41, label %37
37: ; preds = %34
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.7, i64 0, i64 0))
%39 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %2)
%40 = load double, double* %2
br label %41
41: ; preds = %34, %37
%42 = phi double [ %35, %34 ], [ %40, %37 ]
%43 = fcmp olt double %42, 0.000000e+00
%44 = fcmp ogt double %42, 1.000000e+01
%45 = or i1 %43, %44
br i1 %45, label %34, label %46
46: ; preds = %41, %28
%47 = phi double [ %30, %28 ], [ %42, %41 ]
%48 = load double, double* %1
%49 = fadd double %47, %48
%50 = fmul double %49, 5.000000e-01
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %50)
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.5, i64 0, i64 0))
%53 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%54 = load i32, i32* %3
%55 = add i32 %54, -3
%56 = icmp ult i32 %55, -2
br i1 %56, label %57, label %7
57: ; preds = %46, %57
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.5, i64 0, i64 0))
%59 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%60 = load i32, i32* %3
%61 = add i32 %60, -3
%62 = icmp ult i32 %61, -2
br i1 %62, label %57, label %7
63: ; preds = %7
ret i32 0
}