#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*/ getch();
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int notas[50];
  int contador, ordem, soma;
  ordem = 1;
  for (contador = 0; contador < 50; contador++) {
    printf("Digite a nota do aluno %d (entre 0 e 10)\n", ordem);
    scanf("%d", &notas[contador]);
    while ((notas[contador] < 0) || (notas[contador] > 10)) {
      printf("Digite uma nota valida, entre 0 e 10, para o aluno %d\n", ordem);
      scanf("%d", &notas[contador]);
    }
    ordem++;
    soma = soma + notas[contador];
  }
  printf("A media da sala de %d alunos foi: %d", ordem - 1, (soma / ordem));
  getch();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xd8(%rbp)
movl   $0x0,-0xd4(%rbp)
cmpl   $0x32,-0xd4(%rbp)
jge    1257 <main+0x127>
mov    -0xd8(%rbp),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xd4(%rbp),%rax
lea    -0xd0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xef0(%rip),%rdi
call   1040 <scanf@plt>
movslq -0xd4(%rbp),%rcx
mov    $0x1,%al
cmpl   $0x0,-0xd0(%rbp,%rcx,4)
mov    %al,-0xdd(%rbp)
jl     11cd <main+0x9d>
movslq -0xd4(%rbp),%rax
cmpl   $0xa,-0xd0(%rbp,%rax,4)
0a
setg   %al
mov    %al,-0xdd(%rbp)
mov    -0xdd(%rbp),%al
test   $0x1,%al
jne    11e0 <main+0xb0>
jmp    121a <main+0xea>
mov    -0xd8(%rbp),%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xd4(%rbp),%rax
lea    -0xd0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe73(%rip),%rdi
call   1040 <scanf@plt>
jmp    1198 <main+0x68>
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
mov    -0xdc(%rbp),%eax
movslq -0xd4(%rbp),%rcx
add    -0xd0(%rbp,%rcx,4),%eax
mov    %eax,-0xdc(%rbp)
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    1156 <main+0x26>
mov    -0xd8(%rbp),%esi
sub    $0x1,%esi
mov    -0xdc(%rbp),%eax
cltd
idivl  -0xd8(%rbp)
mov    %eax,%edx
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getch@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    $0x1,%ebp
lea    0xf36(%rip),%r15
lea    0xed6(%rip),%r12
xor    %r14d,%r14d
jmp    1170 <main+0x40>
nopl   0x0(%rax)
add    %eax,%r13d
add    $0x1,%ebp
add    $0x1,%r14
cmp    $0x32,%r14
je     11c0 <main+0x90>
lea    0xe89(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    (%rsp,%r14,4),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    (%rsp,%r14,4),%eax
cmp    $0xb,%eax
jb     1160 <main+0x30>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    (%rbx),%eax
cmp    $0xa,%eax
ja     11a0 <main+0x70>
jmp    1160 <main+0x30>
movslq %r13d,%rdx
imul   $0xffffffffa0a0a0a1,%rdx,%rax
shr    $0x20,%rax
add    %eax,%edx
mov    %edx,%eax
shr    $0x1f,%eax
sar    $0x5,%edx
add    %eax,%edx
lea    0xe80(%rip),%rdi
mov    $0x32,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <getch@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Digite a nota do aluno %d (entre 0 e 10)\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [55 x i8] c"Digite uma nota valida, entre 0 e 10, para o aluno %d\0A\00"
@.str.3 = [37 x i8] c"A media da sala de %d alunos foi: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
store i32 0, i32* %3
br label %6
6: ; preds = %46, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 50
br i1 %8, label %9, label %49
9: ; preds = %6
%10 = load i32, i32* %4
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
br label %16
16: ; preds = %30, %9
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = icmp slt i32 %20, 0
br i1 %21, label %28, label %22
22: ; preds = %16
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = icmp sgt i32 %26, 10
br label %28
28: ; preds = %22, %16
%29 = phi i1 [ true, %16 ], [ %27, %22 ]
br i1 %29, label %30, label %37
30: ; preds = %28
%31 = load i32, i32* %4
%32 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %34
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %35)
br label %16
37: ; preds = %28
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
%40 = load i32, i32* %5
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = add nsw i32 %40, %44
store i32 %45, i32* %5
br label %46
46: ; preds = %37
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
br label %6
49: ; preds = %6
%50 = load i32, i32* %4
%51 = sub nsw i32 %50, 1
%52 = load i32, i32* %5
%53 = load i32, i32* %4
%54 = sdiv i32 %52, %53
%55 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %51, i32 %54)
%56 = call i32 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"Digite a nota do aluno %d (entre 0 e 10)\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [55 x i8] c"Digite uma nota valida, entre 0 e 10, para o aluno %d\0A\00"
@.str.3 = [37 x i8] c"A media da sala de %d alunos foi: %d\00"
define i32 @main() {
%1 = alloca [50 x i32]
%2 = bitcast [50 x i32]* %1 to i8*
br label %3
3: ; preds = %0, %17
%4 = phi i64 [ 0, %0 ], [ %21, %17 ]
%5 = phi i32 [ undef, %0 ], [ %20, %17 ]
%6 = phi i32 [ 1, %0 ], [ %19, %17 ]
%7 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %4
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = load i32, i32* %8
%11 = icmp ugt i32 %10, 10
br i1 %11, label %12, label %17
12: ; preds = %3, %12
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%15 = load i32, i32* %8
%16 = icmp ugt i32 %15, 10
br i1 %16, label %12, label %17
17: ; preds = %12, %3
%18 = phi i32 [ %10, %3 ], [ %15, %12 ]
%19 = add nuw nsw i32 %6, 1
%20 = add nsw i32 %18, %5
%21 = add nuw nsw i64 %4, 1
%22 = icmp eq i64 %21, 50
br i1 %22, label %23, label %3
23: ; preds = %17
%24 = sdiv i32 %20, 51
%25 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 50, i32 %24)
%26 = call i32 (...) @getch()
ret i32 0
}