#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 *);
void calcularMediaAluno() {
  int n1, n2, n3, media;
  printf("Digite nota da primeira prova -> ");
  scanf("%d", &n1);
  printf("Digite nota da segunda prova  -> ");
  scanf("%d", &n2);
  printf("Digite nota da terceira prova -> ");
  scanf("%d", &n3);
  media = (n1 + n2 + n3) / 3;
  if (media >= 6) {
    printf("Média: %d Aluno aprovado! \n", media);
    return;
  }
  if (media < 6 && media > 4) {
    printf("Média: %d Recuperação! \n", media);
    return;
  }
  if (media < 4) {
    printf("Média %d Reprovado! \n", media);
    return;
  }
}


x86 assembly (clang, -O0):
<calcularMediaAluno>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea9(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
cmpl   $0x6,-0x10(%rbp)
jl     11b6 <calcularMediaAluno+0x96>
mov    -0x10(%rbp),%esi
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fb <calcularMediaAluno+0xdb>
cmpl   $0x6,-0x10(%rbp)
jge    11e0 <calcularMediaAluno+0xc0>
cmpl   $0x4,-0x10(%rbp)
jle    11e0 <calcularMediaAluno+0xc0>
mov    -0x10(%rbp),%esi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fb <calcularMediaAluno+0xdb>
cmpl   $0x4,-0x10(%rbp)
jge    11fb <calcularMediaAluno+0xdb>
mov    -0x10(%rbp),%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcularMediaAluno>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee8(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xed7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xede(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
add    0xc(%rsp),%eax
add    0x4(%rsp),%eax
movslq %eax,%rcx
imul   $0x55555556,%rcx,%rsi
mov    %rsi,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rsi
add    %edx,%esi
cmp    $0x12,%ecx
jl     11ae <calcularMediaAluno+0x8e>
lea    0xebd(%rip),%rdi
jmp    11cd <calcularMediaAluno+0xad>
cmp    $0xf,%eax
jl     11c1 <calcularMediaAluno+0xa1>
lea    0xecc(%rip),%rdi
mov    $0x5,%esi
jmp    11cd <calcularMediaAluno+0xad>
cmp    $0xb,%eax
jg     11d4 <calcularMediaAluno+0xb4>
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Digite nota da primeira prova -> \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"Digite nota da segunda prova -> \00"
@.str.3 = [34 x i8] c"Digite nota da terceira prova -> \00"
@.str.4 = [29 x i8] c"M\C3\A9dia: %d Aluno aprovado! \0A\00"
@.str.5 = [28 x i8] c"M\C3\A9dia: %d Recupera\C3\A7\C3\A3o! \0A\00"
@.str.6 = [23 x i8] c"M\C3\A9dia %d Reprovado! \0A\00"
define void @calcularMediaAluno() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = add nsw i32 %11, %12
%14 = load i32, i32* %3
%15 = add nsw i32 %13, %14
%16 = sdiv i32 %15, 3
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = icmp sge i32 %17, 6
br i1 %18, label %19, label %22
19: ; preds = %0
%20 = load i32, i32* %4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %20)
br label %37
22: ; preds = %0
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 6
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 4
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* %4
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %29)
br label %37
31: ; preds = %25, %22
%32 = load i32, i32* %4
%33 = icmp slt i32 %32, 4
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* %4
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %19, %28, %34, %31
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"Digite nota da primeira prova -> \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"Digite nota da segunda prova -> \00"
@.str.3 = [34 x i8] c"Digite nota da terceira prova -> \00"
@.str.4 = [29 x i8] c"M\C3\A9dia: %d Aluno aprovado! \0A\00"
@.str.5 = [28 x i8] c"M\C3\A9dia: %d Recupera\C3\A7\C3\A3o! \0A\00"
@.str.6 = [23 x i8] c"M\C3\A9dia %d Reprovado! \0A\00"
define void @calcularMediaAluno() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 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* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = add nsw i32 %14, %13
%16 = load i32, i32* %3
%17 = add nsw i32 %15, %16
%18 = sdiv i32 %17, 3
%19 = icmp sgt i32 %17, 17
br i1 %19, label %20, label %22
20: ; preds = %0
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %18)
br label %30
22: ; preds = %0
%23 = icmp sgt i32 %17, 14
br i1 %23, label %24, label %26
24: ; preds = %22
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 5)
br label %30
26: ; preds = %22
%27 = icmp slt i32 %17, 12
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %18)
br label %30
30: ; preds = %26, %28, %24, %20
ret void
}