#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, acm, media, turmas, alunos;
  acm = 0;
  printf("digite o numero de turmas\n");
  scanf("%d", &turmas);
  for (i = 1; i <= turmas; i++) {
    printf("digite o numero de alunos\n");
    scanf("%d", &alunos);
    if (alunos > 40) {
      printf("Voce digitou um numero maior que 40\n");
      i = i - 1;
    } else {
      acm = acm + alunos;
    }
  }
  media = acm / turmas;
  printf("a media é %d", media);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf1b(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11c7 <main+0xa7>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x28,-0x18(%rbp)
jle    11ab <main+0x8b>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b4 <main+0x94>
mov    -0xc(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11b9 <main+0x99>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115b <main+0x3b>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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
push   %rax
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
lea    0xebd(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%ecx
xor    %ebx,%ebx
test   %ecx,%ecx
jle    11b7 <main+0x87>
mov    $0x1,%ebp
lea    0xebd(%rip),%r14
lea    0xe99(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xec4(%rip),%r13
jmp    118e <main+0x5e>
add    %eax,%ebx
lea    0x1(%rbp),%eax
mov    (%rsp),%ecx
cmp    %ecx,%ebp
mov    %eax,%ebp
jge    11b7 <main+0x87>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x29,%eax
jl     1180 <main+0x50>
mov    %r13,%rdi
call   1030 <puts@plt>
add    $0xffffffff,%ebp
jmp    1182 <main+0x52>
mov    %ebx,%eax
cltd
idiv   %ecx
lea    0xe3d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"digite o numero de turmas\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"digite o numero de alunos\0A\00"
@.str.3 = [37 x i8] c"Voce digitou um numero maior que 40\0A\00"
@.str.4 = [14 x i8] c"a media \C3\A9 %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
store i32 1, i32* %2
br label %9
9: ; preds = %27, %0
%10 = load i32, i32* %2
%11 = load i32, i32* %5
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %30
13: ; preds = %9
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%16 = load i32, i32* %6
%17 = icmp sgt i32 %16, 40
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32, i32* %2
%21 = sub nsw i32 %20, 1
store i32 %21, i32* %2
br label %26
22: ; preds = %13
%23 = load i32, i32* %3
%24 = load i32, i32* %6
%25 = add nsw i32 %23, %24
store i32 %25, i32* %3
br label %26
26: ; preds = %22, %18
br label %27
27: ; preds = %26
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %9
30: ; preds = %9
%31 = load i32, i32* %3
%32 = load i32, i32* %5
%33 = sdiv i32 %31, %32
store i32 %33, i32* %4
%34 = load i32, i32* %4
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [14 x i8] c"a media \C3\A9 %d\00"
@str = [26 x i8] c"digite o numero de turmas\00"
@str.5 = [26 x i8] c"digite o numero de alunos\00"
@str.6 = [36 x i8] c"Voce digitou um numero maior que 40\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 1
br i1 %8, label %27, label %9
9: ; preds = %0, %21
%10 = phi i32 [ %24, %21 ], [ 1, %0 ]
%11 = phi i32 [ %22, %21 ], [ 0, %0 ]
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.5, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, 40
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.6, i64 0, i64 0))
%18 = add nsw i32 %10, -1
br label %21
19: ; preds = %9
%20 = add nsw i32 %14, %11
br label %21
21: ; preds = %16, %19
%22 = phi i32 [ %11, %16 ], [ %20, %19 ]
%23 = phi i32 [ %18, %16 ], [ %10, %19 ]
%24 = add nsw i32 %23, 1
%25 = load i32, i32* %1
%26 = icmp slt i32 %23, %25
br i1 %26, label %9, label %27
27: ; preds = %21, %0
%28 = phi i32 [ 0, %0 ], [ %22, %21 ]
%29 = phi i32 [ %7, %0 ], [ %25, %21 ]
%30 = sdiv i32 %28, %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %30)
ret i32 0
}