#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 n1, n2, n3, n4, media, mediaesc;
  printf("Qual foi sua media no ano?\n");
  printf("Digite a media de sua escola.\n\n");
  scanf("%d", &mediaesc);
  printf("Digite as notas dos 4 bimestres.\n\n");
  scanf("%d"
        "%d"
        "%d"
        "%d",
        &n1, &n2, &n3, &n4);
  media = (n1 + n2 + n3 + n4) / 4;
  printf("Sua media foi %d\n", media);
  if (media < mediaesc) {
    printf("Voce repetiu de ano.\n");
  } else {
    printf("Voce passou de ano!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf13(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d0 <main+0xb0>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11de <main+0xbe>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8d(%rip),%rdi
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x10(%rsp),%r8
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x18(%rsp),%eax
add    0x1c(%rsp),%eax
add    0x14(%rsp),%eax
mov    0x10(%rsp),%ecx
lea    (%rcx,%rax,1),%ebx
add    $0x3,%ebx
add    %ecx,%eax
cmovns %eax,%ebx
sar    $0x2,%ebx
lea    0xe56(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    0xc(%rsp),%ebx
lea    0xec4(%rip),%rax
lea    0xea9(%rip),%rdi
cmovl  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Qual foi sua media no ano?\0A\00"
@.str.1 = [32 x i8] c"Digite a media de sua escola.\0A\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [35 x i8] c"Digite as notas dos 4 bimestres.\0A\0A\00"
@.str.4 = [9 x i8] c"%d%d%d%d\00"
@.str.5 = [18 x i8] c"Sua media foi %d\0A\00"
@.str.6 = [22 x i8] c"Voce repetiu de ano.\0A\00"
@.str.7 = [21 x i8] c"Voce passou de ano!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %5)
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = add nsw i32 %13, %14
%16 = load i32, i32* %4
%17 = add nsw i32 %15, %16
%18 = load i32, i32* %5
%19 = add nsw i32 %17, %18
%20 = sdiv i32 %19, 4
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %30
28: ; preds = %0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %30
30: ; preds = %28, %26
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [9 x i8] c"%d%d%d%d\00"
@.str.5 = [18 x i8] c"Sua media foi %d\0A\00"
@str = [27 x i8] c"Qual foi sua media no ano?\00"
@str.8 = [31 x i8] c"Digite a media de sua escola.\0A\00"
@str.9 = [34 x i8] c"Digite as notas dos 4 bimestres.\0A\00"
@str.10 = [20 x i8] c"Voce passou de ano!\00"
@str.11 = [21 x i8] c"Voce repetiu de ano.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.8, i64 0, i64 0))
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.9, i64 0, i64 0))
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = add nsw i32 %17, %16
%19 = load i32, i32* %3
%20 = add nsw i32 %18, %19
%21 = load i32, i32* %4
%22 = add nsw i32 %20, %21
%23 = sdiv i32 %22, 4
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %5
%26 = icmp slt i32 %23, %25
%27 = select i1 %26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0)
%28 = call i32 @puts(i8* dereferenceable(1) %27)
ret i32 0
}