#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*/ free(float *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ inserirNotas(float *, int);
int /*<<< orphan*/ listarNotas(float *, int);
scalar_t__ malloc(int);
double media(float *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int menu = 0;
  int qtd = 4;
  float *notas = (float *)malloc(sizeof(float) * qtd);
  if (&notas == NULL) {
    printf("Erro ao alocar dados na memoria\n");
    return -1;
  }
  do {
    getchar();
    inserirNotas(notas, qtd);
    listarNotas(notas, qtd);
    printf("media: %f\n", media(notas, qtd));
  } while (menu != 0);
  free(notas);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x4,-0xc(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <inserirNotas@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1080 <listarNotas@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1090 <media@plt>
lea    0xe2e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    11a0 <main+0x30>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1070 <inserirNotas@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1080 <listarNotas@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1090 <media@plt>
lea    0xe4d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"media: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float*
store i32 0, i32* %1
store i32 0, i32* %2
store i32 4, i32* %3
%5 = load i32, i32* %3
%6 = sext i32 %5 to i64
%7 = mul i64 4, %6
%8 = trunc i64 %7 to i32
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to float*
store float* %10, float** %4
br label %11
11: ; preds = %23, %0
%12 = call i32 (...) @getchar()
%13 = load float*, float** %4
%14 = load i32, i32* %3
%15 = call i32 @inserirNotas(float* %13, i32 %14)
%16 = load float*, float** %4
%17 = load i32, i32* %3
%18 = call i32 @listarNotas(float* %16, i32 %17)
%19 = load float*, float** %4
%20 = load i32, i32* %3
%21 = call double @media(float* %19, i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %21)
br label %23
23: ; preds = %11
%24 = load i32, i32* %2
%25 = icmp ne i32 %24, 0
br i1 %25, label %11, label %26
26: ; preds = %23
%27 = load float*, float** %4
%28 = call i32 @free(float* %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"media: %f\0A\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 16)
%2 = inttoptr i64 %1 to float*
%3 = tail call i32 (...) @getchar()
%4 = tail call i32 @inserirNotas(float* %2, i32 4)
%5 = tail call i32 @listarNotas(float* %2, i32 4)
%6 = tail call double @media(float* %2, i32 4)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %6)
%8 = tail call i32 @free(float* %2)
ret i32 0
}