#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 *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char resp;
  int n, i;
  float *notas, media = 0.0;
  do {
    printf("Entre com a quantidade de notas: ");
    scanf("%d", &n);
    notas = (float *)malloc(n * sizeof(float));
    for (i = 0; i < n; i++) {
      printf("Digite a %d nota ", i + 1);
      scanf("%f", &notas[i]);
      media += notas[i];
    }
    media /= n;
    printf("A media das notas e: %.2f\n", media);
    free(notas);
    printf("\nDeseja calcular outra media (S ou N)? ");
    scanf(" %c", &resp);
  } while ((resp == 'S') || (resp == 's'));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f3 <main+0xb3>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1191 <main+0x51>
cvtsi2ssl -0xc(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe24(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe42(%rip),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movsbl -0x5(%rbp),%ecx
mov    $0x1,%al
cmp    $0x53,%ecx
mov    %al,-0x1d(%rbp)
je     1265 <main+0x125>
movsbl -0x5(%rbp),%eax
cmp    $0x73,%eax
sete   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1157 <main+0x17>
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
xorps  %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
lea    0xec7(%rip),%r13
lea    0xed2(%rip),%rbx
lea    0xf(%rsp),%r12
jmp    11d1 <main+0x91>
nopl   0x0(%rax)
movss  0x10(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
divss  %xmm0,%xmm1
movss  %xmm1,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xea5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xf(%rsp),%al
and    $0xdf,%al
cmp    $0x53,%al
jne    1262 <main+0x122>
lea    0xe28(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3c(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x14(%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    0x14(%rsp),%eax
test   %eax,%eax
jle    1170 <main+0x30>
mov    %r14,%rbp
xor    %r15d,%r15d
movss  0x10(%rsp),%xmm1
nopl   0x0(%rax)
movss  %xmm1,0x10(%rsp)
add    $0x1,%r15
mov    %r13,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movss  0x10(%rsp),%xmm1
addss  0x0(%rbp),%xmm1
movslq 0x14(%rsp),%rax
add    $0x4,%rbp
cmp    %rax,%r15
jl     1220 <main+0xe0>
jmp    1176 <main+0x36>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Entre com a quantidade de notas: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"Digite a %d nota \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [27 x i8] c"A media das notas e: %.2f\0A\00"
@.str.5 = [40 x i8] c"\0ADeseja calcular outra media (S ou N)? \00"
@.str.6 = [4 x i8] c" %c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = alloca float*
%6 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %6
br label %7
7: ; preds = %59, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 4
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to float*
store float* %15, float** %5
store i32 0, i32* %4
br label %16
16: ; preds = %36, %7
%17 = load i32, i32* %4
%18 = load i32, i32* %3
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %39
20: ; preds = %16
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load float*, float** %5
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds float, float* %24, i64 %26
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %27)
%29 = load float*, float** %5
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float, float* %29, i64 %31
%33 = load float, float* %32
%34 = load float, float* %6
%35 = fadd float %34, %33
store float %35, float* %6
br label %36
36: ; preds = %20
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %16
39: ; preds = %16
%40 = load i32, i32* %3
%41 = sitofp i32 %40 to float
%42 = load float, float* %6
%43 = fdiv float %42, %41
store float %43, float* %6
%44 = load float, float* %6
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %45)
%47 = load float*, float** %5
%48 = call i32 @free(float* %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%50 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %2)
br label %51
51: ; preds = %39
%52 = load i8, i8* %2
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 83
br i1 %54, label %59, label %55
55: ; preds = %51
%56 = load i8, i8* %2
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 115
br label %59
59: ; preds = %55, %51
%60 = phi i1 [ true, %51 ], [ %58, %55 ]
br i1 %60, label %7, label %61
61: ; preds = %59
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"Entre com a quantidade de notas: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"Digite a %d nota \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [27 x i8] c"A media das notas e: %.2f\0A\00"
@.str.5 = [40 x i8] c"\0ADeseja calcular outra media (S ou N)? \00"
@.str.6 = [4 x i8] c" %c\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
br label %4
4: ; preds = %27, %0
%5 = phi float [ 0.000000e+00, %0 ], [ %31, %27 ]
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = shl i32 %8, 2
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to float*
%12 = load i32, i32* %2
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %27
14: ; preds = %4, %14
%15 = phi i64 [ %17, %14 ], [ 0, %4 ]
%16 = phi float [ %23, %14 ], [ %5, %4 ]
%17 = add nuw nsw i64 %15, 1
%18 = trunc i64 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds float, float* %11, i64 %15
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %20)
%22 = load float, float* %20
%23 = fadd float %16, %22
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %17, %25
br i1 %26, label %14, label %27
27: ; preds = %14, %4
%28 = phi float [ %5, %4 ], [ %23, %14 ]
%29 = phi i32 [ %12, %4 ], [ %24, %14 ]
%30 = sitofp i32 %29 to float
%31 = fdiv float %28, %30
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %32)
%34 = call i32 @free(float* %11)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %1)
%37 = load i8, i8* %1
%38 = and i8 %37, -33
%39 = icmp eq i8 %38, 83
br i1 %39, label %4, label %40
40: ; preds = %27
ret i32 0
}