#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 maior, menor, media, i, n, soma = 0;
  printf("Entre com a nota: \n");
  scanf("%d", &maior);
  soma = soma + maior;
  printf("Entre com a nota: \n");
  scanf("%d", &menor);
  soma = soma + menor;
  if (maior < menor) {
    n = maior;
    maior = menor;
    menor = n;
  };
  for (i = 0; i < 8; i++) {
    printf("Entre com a nota: \n");
    scanf("%d", &n);
    soma = soma + n;
    if (n > maior) {
      maior = n;
    } else if (n < menor) {
      menor = n;
    }
  };
  media = soma / 10;
  printf("A média das notas é: %d \n", media);
  printf("A maior nota é: %d \n", maior);
  printf("A menor nota é: %d \n", menor);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a2 <main+0x82>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    121b <main+0xfb>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4c(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    11f1 <main+0xd1>
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1208 <main+0xe8>
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1203 <main+0xe3>
mov    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1208 <main+0xe8>
jmp    120d <main+0xed>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a9 <main+0x89>
mov    -0x1c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xdf4(%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
sub    $0x18,%rsp
lea    0xf06(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    (%rsp),%eax
mov    %eax,0x14(%rsp)
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ecx
mov    (%rsp),%eax
cmp    %ecx,%eax
jge    1191 <main+0x61>
mov    %eax,0x8(%rsp)
mov    %ecx,(%rsp)
mov    %eax,0x4(%rsp)
mov    %ecx,0xc(%rsp)
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
lea    0xe58(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
cmp    (%rsp),%eax
jle    11c0 <main+0x90>
mov    %eax,(%rsp)
jmp    11ca <main+0x9a>
cmp    0x4(%rsp),%eax
jge    11ca <main+0x9a>
mov    %eax,0x4(%rsp)
mov    %eax,0x10(%rsp)
lea    0xe76(%rip),%rdi
call   1030 <puts@plt>
lea    0xe1f(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%r13d
cmp    (%rsp),%r13d
jle    11fc <main+0xcc>
mov    %r13d,(%rsp)
jmp    1208 <main+0xd8>
cmp    0x4(%rsp),%r13d
jge    1208 <main+0xd8>
mov    %r13d,0x4(%rsp)
lea    0xe3c(%rip),%rdi
call   1030 <puts@plt>
lea    0xde5(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%ebp
cmp    (%rsp),%ebp
jle    1233 <main+0x103>
mov    %ebp,(%rsp)
jmp    123d <main+0x10d>
cmp    0x4(%rsp),%ebp
jge    123d <main+0x10d>
mov    %ebp,0x4(%rsp)
lea    0xe07(%rip),%rdi
call   1030 <puts@plt>
lea    0xdb0(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%ebx
cmp    (%rsp),%ebx
jle    1268 <main+0x138>
mov    %ebx,(%rsp)
jmp    1272 <main+0x142>
cmp    0x4(%rsp),%ebx
jge    1272 <main+0x142>
mov    %ebx,0x4(%rsp)
lea    0xdd2(%rip),%rdi
call   1030 <puts@plt>
lea    0xd7b(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%r15d
cmp    (%rsp),%r15d
jle    12a0 <main+0x170>
mov    %r15d,(%rsp)
jmp    12ac <main+0x17c>
cmp    0x4(%rsp),%r15d
jge    12ac <main+0x17c>
mov    %r15d,0x4(%rsp)
lea    0xd98(%rip),%rdi
call   1030 <puts@plt>
lea    0xd41(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%r14d
cmp    (%rsp),%r14d
jle    12da <main+0x1aa>
mov    %r14d,(%rsp)
jmp    12e6 <main+0x1b6>
cmp    0x4(%rsp),%r14d
jge    12e6 <main+0x1b6>
mov    %r14d,0x4(%rsp)
lea    0xd5e(%rip),%rdi
call   1030 <puts@plt>
lea    0xd07(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%r12d
cmp    (%rsp),%r12d
jle    1314 <main+0x1e4>
mov    %r12d,(%rsp)
jmp    1320 <main+0x1f0>
cmp    0x4(%rsp),%r12d
jge    1320 <main+0x1f0>
mov    %r12d,0x4(%rsp)
lea    0xd24(%rip),%rdi
call   1030 <puts@plt>
lea    0xccd(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
cmp    (%rsp),%eax
jle    134f <main+0x21f>
mov    %eax,(%rsp)
mov    0xc(%rsp),%ecx
jmp    135d <main+0x22d>
cmp    0x4(%rsp),%eax
mov    0xc(%rsp),%ecx
jge    135d <main+0x22d>
mov    %eax,0x4(%rsp)
add    0x14(%rsp),%ecx
mov    0x10(%rsp),%edx
add    %ecx,%edx
add    %edx,%r13d
add    %r13d,%ebp
add    %ebp,%ebx
add    %ebx,%r15d
add    %r15d,%r14d
add    %r14d,%r12d
add    %r12d,%eax
cltq
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x22,%rsi
add    %eax,%esi
lea    0xc6b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%esi
lea    0xc76(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xc7a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Entre com a nota: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"A m\C3\A9dia das notas \C3\A9: %d \0A\00"
@.str.3 = [22 x i8] c"A maior nota \C3\A9: %d \0A\00"
@.str.4 = [22 x i8] c"A menor nota \C3\A9: %d \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
store i32 0, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %7
%11 = load i32, i32* %2
%12 = add nsw i32 %10, %11
store i32 %12, i32* %7
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %7
%16 = load i32, i32* %3
%17 = add nsw i32 %15, %16
store i32 %17, i32* %7
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %25
21: ; preds = %0
%22 = load i32, i32* %2
store i32 %22, i32* %6
%23 = load i32, i32* %3
store i32 %23, i32* %2
%24 = load i32, i32* %6
store i32 %24, i32* %3
br label %25
25: ; preds = %21, %0
store i32 0, i32* %5
br label %26
26: ; preds = %48, %25
%27 = load i32, i32* %5
%28 = icmp slt i32 %27, 8
br i1 %28, label %29, label %51
29: ; preds = %26
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%32 = load i32, i32* %7
%33 = load i32, i32* %6
%34 = add nsw i32 %32, %33
store i32 %34, i32* %7
%35 = load i32, i32* %6
%36 = load i32, i32* %2
%37 = icmp sgt i32 %35, %36
br i1 %37, label %38, label %40
38: ; preds = %29
%39 = load i32, i32* %6
store i32 %39, i32* %2
br label %47
40: ; preds = %29
%41 = load i32, i32* %6
%42 = load i32, i32* %3
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = load i32, i32* %6
store i32 %45, i32* %3
br label %46
46: ; preds = %44, %40
br label %47
47: ; preds = %46, %38
br label %48
48: ; preds = %47
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
br label %26
51: ; preds = %26
%52 = load i32, i32* %7
%53 = sdiv i32 %52, 10
store i32 %53, i32* %4
%54 = load i32, i32* %4
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %2
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %56)
%58 = load i32, i32* %3
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %58)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"A m\C3\A9dia das notas \C3\A9: %d \0A\00"
@.str.3 = [22 x i8] c"A maior nota \C3\A9: %d \0A\00"
@.str.4 = [22 x i8] c"A menor nota \C3\A9: %d \0A\00"
@str.6 = [19 x i8] c"Entre com a nota: \00"
define i32 @main() {
%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 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, 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 = load i32, i32* %1
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, %12
br i1 %14, label %15, label %16
15: ; preds = %0
store i32 %13, i32* %3
store i32 %12, i32* %1
store i32 %13, i32* %2
br label %16
16: ; preds = %15, %0
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%19 = load i32, i32* %3
%20 = load i32, i32* %1
%21 = icmp sgt i32 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %16
store i32 %19, i32* %1
br label %27
23: ; preds = %16
%24 = load i32, i32* %2
%25 = icmp slt i32 %19, %24
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 %19, i32* %2
br label %27
27: ; preds = %22, %26, %23
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%30 = load i32, i32* %3
%31 = load i32, i32* %1
%32 = icmp sgt i32 %30, %31
br i1 %32, label %37, label %33
33: ; preds = %27
%34 = load i32, i32* %2
%35 = icmp slt i32 %30, %34
br i1 %35, label %36, label %38
36: ; preds = %33
store i32 %30, i32* %2
br label %38
37: ; preds = %27
store i32 %30, i32* %1
br label %38
38: ; preds = %37, %36, %33
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%41 = load i32, i32* %3
%42 = load i32, i32* %1
%43 = icmp sgt i32 %41, %42
br i1 %43, label %48, label %44
44: ; preds = %38
%45 = load i32, i32* %2
%46 = icmp slt i32 %41, %45
br i1 %46, label %47, label %49
47: ; preds = %44
store i32 %41, i32* %2
br label %49
48: ; preds = %38
store i32 %41, i32* %1
br label %49
49: ; preds = %48, %47, %44
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%51 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%52 = load i32, i32* %3
%53 = load i32, i32* %1
%54 = icmp sgt i32 %52, %53
br i1 %54, label %59, label %55
55: ; preds = %49
%56 = load i32, i32* %2
%57 = icmp slt i32 %52, %56
br i1 %57, label %58, label %60
58: ; preds = %55
store i32 %52, i32* %2
br label %60
59: ; preds = %49
store i32 %52, i32* %1
br label %60
60: ; preds = %59, %58, %55
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%62 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%63 = load i32, i32* %3
%64 = load i32, i32* %1
%65 = icmp sgt i32 %63, %64
br i1 %65, label %70, label %66
66: ; preds = %60
%67 = load i32, i32* %2
%68 = icmp slt i32 %63, %67
br i1 %68, label %69, label %71
69: ; preds = %66
store i32 %63, i32* %2
br label %71
70: ; preds = %60
store i32 %63, i32* %1
br label %71
71: ; preds = %70, %69, %66
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%73 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%74 = load i32, i32* %3
%75 = load i32, i32* %1
%76 = icmp sgt i32 %74, %75
br i1 %76, label %81, label %77
77: ; preds = %71
%78 = load i32, i32* %2
%79 = icmp slt i32 %74, %78
br i1 %79, label %80, label %82
80: ; preds = %77
store i32 %74, i32* %2
br label %82
81: ; preds = %71
store i32 %74, i32* %1
br label %82
82: ; preds = %81, %80, %77
%83 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%84 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%85 = load i32, i32* %3
%86 = load i32, i32* %1
%87 = icmp sgt i32 %85, %86
br i1 %87, label %92, label %88
88: ; preds = %82
%89 = load i32, i32* %2
%90 = icmp slt i32 %85, %89
br i1 %90, label %91, label %93
91: ; preds = %88
store i32 %85, i32* %2
br label %93
92: ; preds = %82
store i32 %85, i32* %1
br label %93
93: ; preds = %92, %91, %88
%94 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%95 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%96 = load i32, i32* %3
%97 = load i32, i32* %1
%98 = icmp sgt i32 %96, %97
br i1 %98, label %103, label %99
99: ; preds = %93
%100 = load i32, i32* %2
%101 = icmp slt i32 %96, %100
br i1 %101, label %102, label %104
102: ; preds = %99
store i32 %96, i32* %2
br label %104
103: ; preds = %93
store i32 %96, i32* %1
br label %104
104: ; preds = %103, %102, %99
%105 = add nsw i32 %12, %9
%106 = add nsw i32 %19, %105
%107 = add nsw i32 %30, %106
%108 = add nsw i32 %41, %107
%109 = add nsw i32 %52, %108
%110 = add nsw i32 %63, %109
%111 = add nsw i32 %74, %110
%112 = add nsw i32 %85, %111
%113 = add nsw i32 %96, %112
%114 = sdiv i32 %113, 10
%115 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %114)
%116 = load i32, i32* %1
%117 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %116)
%118 = load i32, i32* %2
%119 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %118)
ret i32 0
}