#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*/ calcula_media(float *, int, int);
int /*<<< orphan*/ imprime_media(int, float *);
int /*<<< orphan*/ media_ponderada(float *, int *, int, float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ zera_vetor(float *, int);
int main(int argc, const char *argv[]) {
  int alu, prov, i, j, k;
  printf("Insira a quantidade de provas: ");
  scanf("%d", &prov);
  printf("Insira a quantidade de alunos: ");
  scanf("%d", &alu);
  int pesos[prov];
  float notas[prov], acm = 0, media_aritmetica[prov];
  zera_vetor(media_aritmetica, prov);
  zera_vetor(notas, alu);
  for (k = 0; k < prov; k++) {
    printf("Insira o peso da %dº prova: ", k + 1);
    scanf("%d", &pesos[k]);
    acm += pesos[k];
  }
  for (i = 0; i < alu; i++) {
    for (j = 0; j < prov; j++) {
      printf("Insira a nota da %d prova do %d aluno: ", j + 1, i + 1);
      scanf("%f", &notas[j]);
      media_aritmetica[j] += notas[j];
    }
    media_ponderada(notas, pesos, alu, acm);
  }
  calcula_media(media_aritmetica, prov, alu);
  imprime_media(prov, media_aritmetica);
  printf("----------Fim do Programa----------\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe80(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x69(%rbp)
call   1040 <printf@plt>
mov    -0x69(%rbp),%al
lea    0xe8c(%rip),%rdi
mov    %rdi,-0x78(%rbp)
lea    -0x18(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x69(%rbp),%al
lea    0xe78(%rip),%rdi
call   1040 <printf@plt>
mov    -0x78(%rbp),%rdi
mov    -0x69(%rbp),%al
lea    -0x14(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x18(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x18(%rbp),%eax
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x60(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%esi
call   1070 <zera_vetor@plt>
mov    -0x58(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <zera_vetor@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    12ab <main+0x14b>
mov    -0x24(%rbp),%esi
add    $0x1,%esi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x68(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x68(%rbp),%rax
movslq -0x24(%rbp),%rcx
cvtsi2ssl (%rax,%rcx,4),%xmm0
addss  -0x44(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1249 <main+0xe9>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1358 <main+0x1f8>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1335 <main+0x1d5>
mov    -0x20(%rbp),%esi
add    $0x1,%esi
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x58(%rbp),%rsi
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x58(%rbp),%rcx
mov    -0x60(%rbp),%rax
movslq -0x20(%rbp),%rdx
movss  (%rcx,%rdx,4),%xmm0
movslq -0x20(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12c5 <main+0x165>
mov    -0x68(%rbp),%rsi
mov    -0x58(%rbp),%rdi
mov    -0x14(%rbp),%edx
movss  -0x44(%rbp),%xmm0
call   1050 <media_ponderada@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12b2 <main+0x152>
mov    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <calcula_media@plt>
mov    -0x60(%rbp),%rsi
mov    -0x18(%rbp),%edi
call   1060 <imprime_media@plt>
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xe78(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8a(%rip),%rbx
lea    -0x2c(%rbp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0xe78(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x34(%rbp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    %rsp,-0x50(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    -0x2c(%rbp),%esi
mov    %rsp,%r15
lea    0xf(,%rsi,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%rdi
sub    %rax,%rdi
mov    %rdi,%rsp
mov    %rdi,-0x48(%rbp)
call   1080 <zera_vetor@plt>
mov    -0x34(%rbp),%esi
mov    %r15,%rdi
call   1080 <zera_vetor@plt>
mov    -0x2c(%rbp),%esi
test   %esi,%esi
mov    %r15,-0x40(%rbp)
xorps  %xmm0,%xmm0
jle    128f <main+0x11f>
lea    0xe1d(%rip),%r14
lea    0xdf3(%rip),%r15
mov    %r13,%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  %xmm0,-0x30(%rbp)
add    $0x1,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl (%r12),%xmm0
movss  -0x30(%rbp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
movslq -0x2c(%rbp),%rsi
add    $0x4,%r12
cmp    %rsi,%rbx
jl     1240 <main+0xd0>
mov    -0x40(%rbp),%r15
mov    -0x34(%rbp),%edx
test   %edx,%edx
jle    1358 <main+0x1e8>
lea    0xdc0(%rip),%rbx
lea    0xde1(%rip),%r14
xor    %r12d,%r12d
movss  %xmm0,-0x30(%rbp)
mov    %r13,-0x58(%rbp)
jmp    12db <main+0x16b>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r13,%rsi
movss  -0x30(%rbp),%xmm0
call   1060 <media_ponderada@plt>
mov    -0x34(%rbp),%edx
mov    -0x2c(%rbp),%esi
cmp    %edx,%r12d
jge    1358 <main+0x1e8>
add    $0x1,%r12d
test   %esi,%esi
jle    12c0 <main+0x150>
mov    %r12d,-0x38(%rbp)
mov    %r15,%r12
mov    -0x48(%rbp),%r13
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
mov    %rbx,%rdi
mov    %r15d,%esi
mov    -0x38(%rbp),%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
movss  (%r12),%xmm0
addss  0x0(%r13),%xmm0
movss  %xmm0,0x0(%r13)
movslq -0x2c(%rbp),%rax
add    $0x4,%r13
add    $0x4,%r12
cmp    %rax,%r15
jl     1300 <main+0x190>
mov    -0x34(%rbp),%edx
mov    -0x58(%rbp),%r13
mov    -0x40(%rbp),%r15
mov    -0x38(%rbp),%r12d
jmp    12c0 <main+0x150>
mov    -0x48(%rbp),%rbx
mov    %rbx,%rdi
call   1040 <calcula_media@plt>
mov    -0x2c(%rbp),%edi
mov    %rbx,%rsi
call   1070 <imprime_media@plt>
lea    0xd16(%rip),%rdi
call   1030 <puts@plt>
mov    -0x50(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Insira a quantidade de provas: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"Insira a quantidade de alunos: \00"
@.str.3 = [30 x i8] c"Insira o peso da %d\C2\BA prova: \00"
@.str.4 = [40 x i8] c"Insira a nota da %d prova do %d aluno: \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [37 x i8] c"----------Fim do Programa----------\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i64
%14 = alloca float
%15 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%20 = load i32, i32* %7
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %11
%23 = alloca i32, i64 %21
store i64 %21, i64* %12
%24 = load i32, i32* %7
%25 = zext i32 %24 to i64
%26 = alloca float, i64 %25
store i64 %25, i64* %13
store float 0.000000e+00, float* %14
%27 = load i32, i32* %7
%28 = zext i32 %27 to i64
%29 = alloca float, i64 %28
store i64 %28, i64* %15
%30 = load i32, i32* %7
%31 = call i32 @zera_vetor(float* %29, i32 %30)
%32 = load i32, i32* %6
%33 = call i32 @zera_vetor(float* %26, i32 %32)
store i32 0, i32* %10
br label %34
34: ; preds = %53, %2
%35 = load i32, i32* %10
%36 = load i32, i32* %7
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %56
38: ; preds = %34
%39 = load i32, i32* %10
%40 = add nsw i32 %39, 1
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %10
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %23, i64 %43
%45 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %44)
%46 = load i32, i32* %10
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %23, i64 %47
%49 = load i32, i32* %48
%50 = sitofp i32 %49 to float
%51 = load float, float* %14
%52 = fadd float %51, %50
store float %52, float* %14
br label %53
53: ; preds = %38
%54 = load i32, i32* %10
%55 = add nsw i32 %54, 1
store i32 %55, i32* %10
br label %34
56: ; preds = %34
store i32 0, i32* %8
br label %57
57: ; preds = %92, %56
%58 = load i32, i32* %8
%59 = load i32, i32* %6
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %95
61: ; preds = %57
store i32 0, i32* %9
br label %62
62: ; preds = %85, %61
%63 = load i32, i32* %9
%64 = load i32, i32* %7
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %88
66: ; preds = %62
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
%69 = load i32, i32* %8
%70 = add nsw i32 %69, 1
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %68, i32 %70)
%72 = load i32, i32* %9
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds float, float* %26, i64 %73
%75 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %74)
%76 = load i32, i32* %9
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds float, float* %26, i64 %77
%79 = load float, float* %78
%80 = load i32, i32* %9
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds float, float* %29, i64 %81
%83 = load float, float* %82
%84 = fadd float %83, %79
store float %84, float* %82
br label %85
85: ; preds = %66
%86 = load i32, i32* %9
%87 = add nsw i32 %86, 1
store i32 %87, i32* %9
br label %62
88: ; preds = %62
%89 = load i32, i32* %6
%90 = load float, float* %14
%91 = call i32 @media_ponderada(float* %26, i32* %23, i32 %89, float %90)
br label %92
92: ; preds = %88
%93 = load i32, i32* %8
%94 = add nsw i32 %93, 1
store i32 %94, i32* %8
br label %57
95: ; preds = %57
%96 = load i32, i32* %7
%97 = load i32, i32* %6
%98 = call i32 @calcula_media(float* %29, i32 %96, i32 %97)
%99 = load i32, i32* %7
%100 = call i32 @imprime_media(i32 %99, float* %29)
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %3
%102 = load i8*, i8** %11
%103 = load i32, i32* %3
ret i32 %103
}

LLVM IR (-O2):
@.str = [32 x i8] c"Insira a quantidade de provas: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"Insira a quantidade de alunos: \00"
@.str.3 = [30 x i8] c"Insira o peso da %d\C2\BA prova: \00"
@.str.4 = [40 x i8] c"Insira a nota da %d prova do %d aluno: \00"
@.str.5 = [3 x i8] c"%f\00"
@str = [36 x i8] c"----------Fim do Programa----------\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 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* %4)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %4
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
%14 = alloca i32, i64 %12
%15 = load i32, i32* %4
%16 = zext i32 %15 to i64
%17 = alloca float, i64 %16
%18 = alloca float, i64 %16
%19 = call i32 @zera_vetor(float* %18, i32 %15)
%20 = load i32, i32* %3
%21 = call i32 @zera_vetor(float* %17, i32 %20)
%22 = load i32, i32* %4
%23 = icmp sgt i32 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %29, %2
%25 = phi i32 [ %22, %2 ], [ %40, %29 ]
%26 = phi float [ 0.000000e+00, %2 ], [ %39, %29 ]
%27 = load i32, i32* %3
%28 = icmp sgt i32 %27, 0
br i1 %28, label %43, label %71
29: ; preds = %2, %29
%30 = phi i64 [ %32, %29 ], [ 0, %2 ]
%31 = phi float [ %39, %29 ], [ 0.000000e+00, %2 ]
%32 = add nuw nsw i64 %30, 1
%33 = trunc i64 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds i32, i32* %14, i64 %30
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %35)
%37 = load i32, i32* %35
%38 = sitofp i32 %37 to float
%39 = fadd float %31, %38
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = icmp slt i64 %32, %41
br i1 %42, label %29, label %24
43: ; preds = %24, %65
%44 = phi i32 [ %68, %65 ], [ %27, %24 ]
%45 = phi i32 [ %70, %65 ], [ %25, %24 ]
%46 = phi i32 [ %48, %65 ], [ 0, %24 ]
%47 = icmp sgt i32 %45, 0
%48 = add nuw nsw i32 %46, 1
br i1 %47, label %49, label %65
49: ; preds = %43, %49
%50 = phi i64 [ %51, %49 ], [ 0, %43 ]
%51 = add nuw nsw i64 %50, 1
%52 = trunc i64 %51 to i32
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %52, i32 %48)
%54 = getelementptr inbounds float, float* %17, i64 %50
%55 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %54)
%56 = load float, float* %54
%57 = getelementptr inbounds float, float* %18, i64 %50
%58 = load float, float* %57
%59 = fadd float %56, %58
store float %59, float* %57
%60 = load i32, i32* %4
%61 = sext i32 %60 to i64
%62 = icmp slt i64 %51, %61
br i1 %62, label %49, label %63
63: ; preds = %49
%64 = load i32, i32* %3
br label %65
65: ; preds = %43, %63
%66 = phi i32 [ %64, %63 ], [ %44, %43 ]
%67 = call i32 @media_ponderada(float* %17, i32* %14, i32 %66, float %26)
%68 = load i32, i32* %3
%69 = icmp slt i32 %48, %68
%70 = load i32, i32* %4
br i1 %69, label %43, label %71
71: ; preds = %65, %24
%72 = phi i32 [ %25, %24 ], [ %70, %65 ]
%73 = phi i32 [ %27, %24 ], [ %68, %65 ]
%74 = call i32 @calcula_media(float* %18, i32 %72, i32 %73)
%75 = load i32, i32* %4
%76 = call i32 @imprime_media(i32 %75, float* %18)
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
ret i32 0
}