#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 *);
main() {
  int cont, valor, quantidade, soma, MAnumero, MEnumero, coringa;
  float media;
  soma = 0;
  coringa = 0;
  printf("Digite a quantidade de numeros: ");
  scanf("%d", &quantidade);
  for (cont = 1; cont <= quantidade; cont++) {
    printf("Por favor, digite um numero inteiro: ");
    scanf("%d", &valor);
    soma = soma + valor;
    if (coringa == 1) {
      if (valor > MAnumero)
        MAnumero = valor;
      if (valor < MEnumero)
        MEnumero = valor;
    } else {
      coringa = 1;
      MAnumero = valor;
      MEnumero = valor;
    }
  }
  media = (float)soma / quantidade;
  printf("\nSoma: %d \n", soma);
  printf("Media: %4.2f \n", media);
  printf("Maior numero: %d \n", MAnumero);
  printf("Menor numero: %d \n", MEnumero);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11ee <main+0xce>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x20(%rbp)
jne    11c8 <main+0xa8>
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11b1 <main+0x91>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c3 <main+0xa3>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11db <main+0xbb>
movl   $0x1,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11e0 <main+0xc0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1162 <main+0x42>
cvtsi2ssl -0x14(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe34(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%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    %ebp,%ebp
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11da <main+0xba>
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x10(%rsp),%r14d
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
jl     11dc <main+0xbc>
mov    $0x1,%r15d
lea    0xe8c(%rip),%r12
lea    0x10(%rsp),%r13
mov    %r14d,%ebx
mov    %r14d,%ebp
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
add    %eax,%ebp
cmp    %ebx,%eax
cmovg  %eax,%ebx
cmp    %r14d,%eax
cmovl  %eax,%r14d
mov    0xc(%rsp),%eax
add    $0x1,%r15d
cmp    %eax,%r15d
jl     11a0 <main+0x80>
jmp    11e2 <main+0xc2>
jmp    11e2 <main+0xc2>
mov    %r14d,%ebp
mov    %r14d,%ebx
cvtsi2ss %ebp,%xmm1
cvtsi2ss %eax,%xmm0
divss  %xmm0,%xmm1
movss  %xmm1,0x14(%rsp)
lea    0xe4f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe41(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe42(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe45(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
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 = [38 x i8] c"Por favor, digite um numero inteiro: \00"
@.str.3 = [12 x i8] c"\0ASoma: %d \0A\00"
@.str.4 = [15 x i8] c"Media: %4.2f \0A\00"
@.str.5 = [19 x i8] c"Maior numero: %d \0A\00"
@.str.6 = [19 x i8] c"Menor numero: %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
%8 = alloca i32
%9 = alloca float
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
store i32 1, i32* %2
br label %12
12: ; preds = %41, %0
%13 = load i32, i32* %2
%14 = load i32, i32* %4
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %44
16: ; preds = %12
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, 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* %5
%20 = load i32, i32* %3
%21 = add nsw i32 %19, %20
store i32 %21, i32* %5
%22 = load i32, i32* %8
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %37
24: ; preds = %16
%25 = load i32, i32* %3
%26 = load i32, i32* %6
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = load i32, i32* %3
store i32 %29, i32* %6
br label %30
30: ; preds = %28, %24
%31 = load i32, i32* %3
%32 = load i32, i32* %7
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = load i32, i32* %3
store i32 %35, i32* %7
br label %36
36: ; preds = %34, %30
br label %40
37: ; preds = %16
store i32 1, i32* %8
%38 = load i32, i32* %3
store i32 %38, i32* %6
%39 = load i32, i32* %3
store i32 %39, i32* %7
br label %40
40: ; preds = %37, %36
br label %41
41: ; preds = %40
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %12
44: ; preds = %12
%45 = load i32, i32* %5
%46 = sitofp i32 %45 to float
%47 = load i32, i32* %4
%48 = sitofp i32 %47 to float
%49 = fdiv float %46, %48
store float %49, float* %9
%50 = load i32, i32* %5
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %50)
%52 = load float, float* %9
%53 = fpext float %52 to double
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), double %53)
%55 = load i32, i32* %6
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %55)
%57 = load i32, i32* %7
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %57)
%59 = load i32, i32* %1
ret i32 %59
}

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