#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 n, i, x, soma = 0, maior, menor;
  float media;
  printf("Digite a quantidade de numeros: ");
  scanf("%d", &n);
  printf("Digite os numeros:");
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    if (x > maior || i == 1) {
      maior = x;
    }
    if (x < menor || i == 1) {
      menor = x;
    }
    soma += x;
  }
  media = (float)soma / n;
  printf("Maior valor = %d\n", maior);
  printf("Menor valor = %d\n", menor);
  printf("Media = %.2f\n", media);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11d4 <main+0xb4>
lea    0xea5(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     119b <main+0x7b>
cmpl   $0x1,-0xc(%rbp)
jne    11a1 <main+0x81>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     11b7 <main+0x97>
cmpl   $0x1,-0xc(%rbp)
jne    11bd <main+0x9d>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1169 <main+0x49>
cvtsi2ssl -0x14(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe42(%rip),%rdi
mov    $0x1,%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    0xecb(%rip),%rdi
xor    %r12d,%r12d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedb(%rip),%r14
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%r15
xor    %r13d,%r13d
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
test   %r12d,%r12d
mov    %ebp,%ecx
cmove  %eax,%ecx
mov    %ebx,%edx
cmove  %eax,%edx
cmp    %ebp,%eax
mov    %ecx,%ebp
cmovg  %eax,%ebp
cmp    %ebx,%eax
mov    %edx,%ebx
cmovl  %eax,%ebx
add    %eax,%r13d
mov    0x14(%rsp),%eax
add    $0x1,%r12d
cmp    %eax,%r12d
jl     1170 <main+0x50>
cvtsi2ss %r13d,%xmm1
cvtsi2ss %eax,%xmm0
divss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
lea    0xe73(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe75(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6d(%rip),%rdi
mov    $0x1,%al
call   1030 <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 = [33 x i8] c"Digite a quantidade de numeros: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"Digite os numeros:\00"
@.str.3 = [18 x i8] c"Maior valor = %d\0A\00"
@.str.4 = [18 x i8] c"Menor valor = %d\0A\00"
@.str.5 = [14 x i8] c"Media = %.2f\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
%8 = alloca float
store i32 0, i32* %1
store i32 0, i32* %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, 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* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %12
12: ; preds = %39, %0
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %42
16: ; preds = %12
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%18 = load i32, i32* %4
%19 = load i32, i32* %6
%20 = icmp sgt i32 %18, %19
br i1 %20, label %24, label %21
21: ; preds = %16
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %26
24: ; preds = %21, %16
%25 = load i32, i32* %4
store i32 %25, i32* %6
br label %26
26: ; preds = %24, %21
%27 = load i32, i32* %4
%28 = load i32, i32* %7
%29 = icmp slt i32 %27, %28
br i1 %29, label %33, label %30
30: ; preds = %26
%31 = load i32, i32* %3
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %35
33: ; preds = %30, %26
%34 = load i32, i32* %4
store i32 %34, i32* %7
br label %35
35: ; preds = %33, %30
%36 = load i32, i32* %4
%37 = load i32, i32* %5
%38 = add nsw i32 %37, %36
store i32 %38, i32* %5
br label %39
39: ; preds = %35
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %12
42: ; preds = %12
%43 = load i32, i32* %5
%44 = sitofp i32 %43 to float
%45 = load i32, i32* %2
%46 = sitofp i32 %45 to float
%47 = fdiv float %44, %46
store float %47, float* %8
%48 = load i32, i32* %6
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %7
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %50)
%52 = load float, float* %8
%53 = fpext float %52 to double
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double %53)
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Digite a quantidade de numeros: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"Digite os numeros:\00"
@.str.3 = [18 x i8] c"Maior valor = %d\0A\00"
@.str.4 = [18 x i8] c"Menor valor = %d\0A\00"
@.str.5 = [14 x i8] c"Media = %.2f\0A\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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 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* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br label %10
10: ; preds = %0, %10
%11 = phi i32 [ %25, %10 ], [ 1, %0 ]
%12 = phi i32 [ %23, %10 ], [ undef, %0 ]
%13 = phi i32 [ %20, %10 ], [ undef, %0 ]
%14 = phi i32 [ %24, %10 ], [ 0, %0 ]
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
%17 = icmp sgt i32 %16, %13
%18 = icmp eq i32 %11, 1
%19 = select i1 %17, i1 true, i1 %18
%20 = select i1 %19, i32 %16, i32 %13
%21 = icmp slt i32 %16, %12
%22 = select i1 %21, i1 true, i1 %18
%23 = select i1 %22, i32 %16, i32 %12
%24 = add nsw i32 %16, %14
%25 = add nuw nsw i32 %11, 1
%26 = load i32, i32* %1
%27 = icmp slt i32 %11, %26
br i1 %27, label %10, label %28
28: ; preds = %10
%29 = sitofp i32 %24 to float
%30 = sitofp i32 %26 to float
%31 = fdiv float %29, %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%34 = fpext float %31 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double %34)
ret i32 0
}