#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*/ calculaMedia(float, int);
int /*<<< orphan*/ imprimeMedia(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
main() {
  char nome[50];
  int qtdProvas = 0, p = 0;
  float notas[qtdProvas], media = 0.0;
  printf("Digite o seu nome: ");
  scanf("%[^\n]", nome);
  printf("\nQuantas provas você fez %s: ", nome);
  scanf("%d", &qtdProvas);
  for (p = 0; p < qtdProvas; p++) {
    printf("\nNota da prova %d: ", p + 1);
    scanf("%f", &notas[p]);
    media += notas[p];
  }
  imprimeMedia(nome, calculaMedia(media, qtdProvas));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x44(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x5c(%rbp)
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe74(%rip),%rdi
lea    -0x44(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1239 <main+0xf9>
mov    -0x48(%rbp),%esi
add    $0x1,%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x68(%rbp),%rsi
movslq -0x48(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x68(%rbp),%rax
movslq -0x48(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
addss  -0x5c(%rbp),%xmm0
movss  %xmm0,-0x5c(%rbp)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11d7 <main+0x97>
lea    -0x40(%rbp),%rax
mov    %rax,-0x70(%rbp)
movss  -0x5c(%rbp),%xmm0
mov    -0x44(%rbp),%edi
call   1050 <calculaMedia@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,%esi
call   1030 <imprimeMedia@plt>
mov    -0x50(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %rsp,%r13
movl   $0x0,0x8(%rsp)
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe97(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x8(%rsp),%edi
xorps  %xmm0,%xmm0
test   %edi,%edi
jle    11fc <main+0xbc>
mov    %rsp,%r12
lea    0xe87(%rip),%r14
lea    0xe94(%rip),%r15
xor    %ebx,%ebx
xchg   %ax,%ax
movss  %xmm0,0xc(%rsp)
add    $0x1,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movss  0xc(%rsp),%xmm0
addss  (%rsp),%xmm0
movslq 0x8(%rsp),%rdi
add    $0x4,%r12
cmp    %rdi,%rbx
jl     11c0 <main+0x80>
call   1050 <calculaMedia@plt>
lea    0x10(%rsp),%rdi
mov    %eax,%esi
call   1030 <imprimeMedia@plt>
mov    %r13,%rsp
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Digite o seu nome: \00"
@.str.1 = [6 x i8] c"%[^\0A]\00"
@.str.2 = [31 x i8] c"\0AQuantas provas voc\C3\AA fez %s: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [20 x i8] c"\0ANota da prova %d: \00"
@.str.5 = [3 x i8] c"%f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca float
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
%8 = load i32, i32* %3
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %5
%11 = alloca float, i64 %9
store i64 %9, i64* %6
store float 0.000000e+00, float* %7
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
store i32 0, i32* %4
br label %18
18: ; preds = %36, %0
%19 = load i32, i32* %4
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %39
22: ; preds = %18
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds float, float* %11, i64 %27
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %28)
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float, float* %11, i64 %31
%33 = load float, float* %32
%34 = load float, float* %7
%35 = fadd float %34, %33
store float %35, float* %7
br label %36
36: ; preds = %22
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %18
39: ; preds = %18
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%41 = load float, float* %7
%42 = load i32, i32* %3
%43 = call i32 @calculaMedia(float %41, i32 %42)
%44 = call i32 @imprimeMedia(i8* %40, i32 %43)
%45 = load i8*, i8** %5
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@.str = [20 x i8] c"Digite o seu nome: \00"
@.str.1 = [6 x i8] c"%[^\0A]\00"
@.str.2 = [31 x i8] c"\0AQuantas provas voc\C3\AA fez %s: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [20 x i8] c"\0ANota da prova %d: \00"
@.str.5 = [3 x i8] c"%f\00"
define i32 @main() {
%1 = alloca [0 x float]
%2 = alloca [50 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = tail call i8* @llvm.stacksave()
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %28
13: ; preds = %0
%14 = getelementptr inbounds [0 x float], [0 x float]* %1, i64 0, i64 0
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %18, %15 ]
%17 = phi float [ 0.000000e+00, %13 ], [ %24, %15 ]
%18 = add nuw nsw i64 %16, 1
%19 = trunc i64 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [0 x float], [0 x float]* %1, i64 0, i64 %16
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %21)
%23 = load float, float* %14
%24 = fadd float %17, %23
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %18, %26
br i1 %27, label %15, label %28
28: ; preds = %15, %0
%29 = phi float [ 0.000000e+00, %0 ], [ %24, %15 ]
%30 = phi i32 [ %11, %0 ], [ %25, %15 ]
%31 = call i32 @calculaMedia(float %29, i32 %30)
%32 = call i32 @imprimeMedia(i8* %4, i32 %31)
ret i32 0
}