#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 *);
void calculo() {
  double n1, soma = 0, i = 1;
  while (i <= 2) {
    scanf("%lf", &n1);
    if (n1 < 0 || n1 > 10) {
      printf("nota invalida\n");
    } else {
      soma += n1;
      i++;
    }
  }
  printf("media = %.2f\n", soma / 2);
}


x86 assembly (clang, -O0):
<calculo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xec8(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xec3(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11be <calculo+0x9e>
lea    0xec1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
ja     1185 <calculo+0x65>
movsd  -0x8(%rbp),%xmm0
movsd  0xe95(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1198 <calculo+0x78>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b9 <calculo+0x99>
movsd  -0x8(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe51(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    113d <calculo+0x1d>
movsd  -0x10(%rbp),%xmm0
movsd  0xe3d(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe55(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculo>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movsd  0xebf(%rip),%xmm1
lea    0xee0(%rip),%r14
lea    0x18(%rsp),%rbx
lea    0xee6(%rip),%r15
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    117c <calculo+0x4c>
mov    %r15,%rdi
call   1030 <puts@plt>
movsd  0x10(%rsp),%xmm1
movsd  0xe9a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11c7 <calculo+0x97>
movsd  %xmm1,0x10(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movsd  0x18(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1160 <calculo+0x30>
ucomisd 0xe63(%rip),%xmm0
ja     1160 <calculo+0x30>
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm1
addsd  0xe3b(%rip),%xmm1
jmp    116e <calculo+0x3e>
movsd  0x8(%rsp),%xmm0
mulsd  0xe43(%rip),%xmm0
lea    0xe50(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.2 = [14 x i8] c"media = %.2f\0A\00"
@str = [14 x i8] c"nota invalida\00"
define void @calculo() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
br label %3
3: ; preds = %0, %16
%4 = phi double [ 1.000000e+00, %0 ], [ %18, %16 ]
%5 = phi double [ 0.000000e+00, %0 ], [ %17, %16 ]
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%7 = load double, double* %1
%8 = fcmp olt double %7, 0.000000e+00
%9 = fcmp ogt double %7, 1.000000e+01
%10 = or i1 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %16
13: ; preds = %3
%14 = fadd double %5, %7
%15 = fadd double %4, 1.000000e+00
br label %16
16: ; preds = %13, %11
%17 = phi double [ %5, %11 ], [ %14, %13 ]
%18 = phi double [ %4, %11 ], [ %15, %13 ]
%19 = fcmp ugt double %18, 2.000000e+00
br i1 %19, label %20, label %3
20: ; preds = %16
%21 = fmul double %17, 5.000000e-01
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %21)
ret void
}