#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 */
scalar_t__ malloc(int);
float media(int, float *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  float *p, valor = 0, recebe_media = 0;
  int maximo_elementos = 0, i;
  printf("Entre com o tamanho: ");
  scanf("%d", &maximo_elementos);
  p = (float *)malloc(maximo_elementos * sizeof(float));
  if (p == NULL)
    printf("Falta de Memória!");
  for (i = 0; i < maximo_elementos; i++) {
    printf("Entre com a %d nota: ", i + 1);
    scanf("%f", &valor);
    if ((valor >= 0 && valor <= 10))
      p[i] = valor;
    else {
      printf("Precisa ser no intervalo de 0 a 10!\n");
      while (valor < 0 || valor > 10) {
        scanf("%f", &valor);
        p[i] = valor;
      }
    }
  }
  recebe_media = media(maximo_elementos, p);
  printf("%.3f\n", recebe_media);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9f(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b2 <main+0x72>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12ac <main+0x16c>
mov    -0x20(%rbp),%esi
add    $0x1,%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe66(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1225 <main+0xe5>
movss  0xdfc(%rip),%xmm0
ucomiss -0x14(%rbp),%xmm0
jb     1225 <main+0xe5>
movss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
jmp    1299 <main+0x159>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%al
xorps  %xmm0,%xmm0
ucomiss -0x14(%rbp),%xmm0
mov    %al,-0x21(%rbp)
ja     125b <main+0x11b>
movss  -0x14(%rbp),%xmm0
movss  0xdae(%rip),%xmm1
ucomiss %xmm1,%xmm0
seta   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    126b <main+0x12b>
jmp    1294 <main+0x154>
lea    0xdd4(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
jmp    1233 <main+0xf3>
jmp    1299 <main+0x159>
jmp    129e <main+0x15e>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b9 <main+0x79>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <media@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xda1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xe97(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9f(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11ad <main+0x5d>
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
test   %edi,%edi
jle    1262 <main+0x112>
lea    0xe74(%rip),%r14
lea    0xe83(%rip),%r15
mov    %rsp,%r12
xor    %r13d,%r13d
jmp    11e3 <main+0x93>
nop
movss  %xmm0,(%rbx,%rbp,4)
movslq 0x4(%rsp),%rdi
cmp    %rdi,%r13
jge    1262 <main+0x112>
mov    %r13,%rbp
add    $0x1,%r13
mov    %r14,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movss  (%rsp),%xmm0
ucomiss 0xdf4(%rip),%xmm0
jb     121f <main+0xcf>
movss  0xde6(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    11d0 <main+0x80>
lea    0xe2d(%rip),%rdi
call   1030 <puts@plt>
jmp    1247 <main+0xf7>
nopl   (%rax)
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movss  (%rsp),%xmm0
movss  %xmm0,(%rbx,%rbp,4)
movss  (%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     1230 <main+0xe0>
ucomiss 0xda5(%rip),%xmm0
ja     1230 <main+0xe0>
jmp    11d5 <main+0x85>
mov    %rbx,%rsi
call   1070 <media@plt>
cvtss2sd %xmm0,%xmm0
lea    0xdd8(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Entre com o tamanho: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"Falta de Mem\C3\B3ria!\00"
@.str.3 = [22 x i8] c"Entre com a %d nota: \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [37 x i8] c"Precisa ser no intervalo de 0 a 10!\0A\00"
@.str.6 = [6 x i8] c"%.3f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float*
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
store i32 0, i32* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 4
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to float*
store float* %14, float** %2
%15 = load float*, float** %2
%16 = icmp eq float* %15, null
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %0
store i32 0, i32* %6
br label %20
20: ; preds = %59, %19
%21 = load i32, i32* %6
%22 = load i32, i32* %5
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %62
24: ; preds = %20
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %3)
%29 = load float, float* %3
%30 = fcmp oge float %29, 0.000000e+00
br i1 %30, label %31, label %40
31: ; preds = %24
%32 = load float, float* %3
%33 = fcmp ole float %32, 1.000000e+01
br i1 %33, label %34, label %40
34: ; preds = %31
%35 = load float, float* %3
%36 = load float*, float** %2
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds float, float* %36, i64 %38
store float %35, float* %39
br label %58
40: ; preds = %31, %24
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
br label %42
42: ; preds = %50, %40
%43 = load float, float* %3
%44 = fcmp olt float %43, 0.000000e+00
br i1 %44, label %48, label %45
45: ; preds = %42
%46 = load float, float* %3
%47 = fcmp ogt float %46, 1.000000e+01
br label %48
48: ; preds = %45, %42
%49 = phi i1 [ true, %42 ], [ %47, %45 ]
br i1 %49, label %50, label %57
50: ; preds = %48
%51 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %3)
%52 = load float, float* %3
%53 = load float*, float** %2
%54 = load i32, i32* %6
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds float, float* %53, i64 %55
store float %52, float* %56
br label %42
57: ; preds = %48
br label %58
58: ; preds = %57, %34
br label %59
59: ; preds = %58
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 1
store i32 %61, i32* %6
br label %20
62: ; preds = %20
%63 = load i32, i32* %5
%64 = load float*, float** %2
%65 = call float @media(i32 %63, float* %64)
store float %65, float* %4
%66 = load float, float* %4
%67 = fpext float %66 to double
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), double %67)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Entre com o tamanho: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"Falta de Mem\C3\B3ria!\00"
@.str.3 = [22 x i8] c"Entre com a %d nota: \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.6 = [6 x i8] c"%.3f\0A\00"
@str = [36 x i8] c"Precisa ser no intervalo de 0 a 10!\00"
define i32 @main() {
%1 = alloca float
%2 = alloca i32
%3 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = shl i32 %7, 2
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to float*
%11 = icmp eq i64 %9, 0
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %0
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %48
17: ; preds = %14, %44
%18 = phi i64 [ %19, %44 ], [ 0, %14 ]
%19 = add nuw nsw i64 %18, 1
%20 = trunc i64 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %1)
%23 = load float, float* %1
%24 = fcmp oge float %23, 0.000000e+00
%25 = fcmp ole float %23, 1.000000e+01
%26 = and i1 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %17
%28 = getelementptr inbounds float, float* %10, i64 %18
store float %23, float* %28
br label %44
29: ; preds = %17
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%31 = load float, float* %1
%32 = fcmp olt float %31, 0.000000e+00
%33 = fcmp ogt float %31, 1.000000e+01
%34 = or i1 %32, %33
br i1 %34, label %35, label %44
35: ; preds = %29
%36 = getelementptr inbounds float, float* %10, i64 %18
br label %37
37: ; preds = %35, %37
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %1)
%39 = load float, float* %1
store float %39, float* %36
%40 = load float, float* %1
%41 = fcmp olt float %40, 0.000000e+00
%42 = fcmp ogt float %40, 1.000000e+01
%43 = or i1 %41, %42
br i1 %43, label %37, label %44
44: ; preds = %37, %29, %27
%45 = load i32, i32* %2
%46 = sext i32 %45 to i64
%47 = icmp slt i64 %19, %46
br i1 %47, label %17, label %48
48: ; preds = %44, %14
%49 = phi i32 [ %15, %14 ], [ %45, %44 ]
%50 = call float @media(i32 %49, float* %10)
%51 = fpext float %50 to double
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), double %51)
ret i32 0
}