#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 INT_MAX;
int INT_MIN;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  int i = -1, num, soma = 0, maior = INT_MIN, menor = INT_MAX;
  float media;
  while (num != 0) {
    printf("Entre com um numero: ");
    scanf("%d", &num);
    if ((num < menor) && (num != 0)) {
      menor = num;
    }
    if (num > maior) {
      maior = num;
    }
    soma = soma + num;
    i++;
  }
  printf("\nSoma: %d", soma);
  media = (float)soma / i;
  printf("\nMedia: %.2f", media);
  printf("\nMaior: %d", maior);
  printf("\nMenor: %d", menor);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    0x2e9c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e98(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11c2 <main+0xa2>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea9(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1199 <main+0x79>
cmpl   $0x0,-0xc(%rbp)
je     1199 <main+0x79>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11ab <main+0x8b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1155 <main+0x35>
mov    -0x10(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2ssl -0x10(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2eae(%rip),%rax
mov    (%rax),%r14d
mov    0x2eac(%rip),%rax
mov    (%rax),%ebx
mov    $0xffffffff,%r15d
lea    0x4(%rsp),%r13
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebx,%r12d
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
mov    %r13,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
cmovne %eax,%ebx
cmp    %r12d,%eax
cmovge %r12d,%ebx
cmp    %r14d,%eax
cmovg  %eax,%r14d
add    %eax,%ebp
add    $0x1,%r15d
test   %eax,%eax
jne    1150 <main+0x30>
cvtsi2ss %r15d,%xmm0
movss  %xmm0,(%rsp)
lea    0xe74(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
divss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe5d(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe57(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@INT_MIN = global i32 0
@INT_MAX = global i32 0
@.str = [22 x i8] c"Entre com um numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [10 x i8] c"\0ASoma: %d\00"
@.str.3 = [13 x i8] c"\0AMedia: %.2f\00"
@.str.4 = [11 x i8] c"\0AMaior: %d\00"
@.str.5 = [11 x i8] c"\0AMenor: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
store i32 0, i32* %1
store i32 -1, i32* %2
store i32 0, i32* %4
%8 = load i32, i32* @INT_MIN
store i32 %8, i32* %5
%9 = load i32, i32* @INT_MAX
store i32 %9, i32* %6
br label %10
10: ; preds = %30, %0
%11 = load i32, i32* %3
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %36
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %3
%17 = load i32, i32* %6
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %24
19: ; preds = %13
%20 = load i32, i32* %3
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = load i32, i32* %3
store i32 %23, i32* %6
br label %24
24: ; preds = %22, %19, %13
%25 = load i32, i32* %3
%26 = load i32, i32* %5
%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* %5
br label %30
30: ; preds = %28, %24
%31 = load i32, i32* %4
%32 = load i32, i32* %3
%33 = add nsw i32 %31, %32
store i32 %33, i32* %4
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 1
store i32 %35, i32* %2
br label %10
36: ; preds = %10
%37 = load i32, i32* %4
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %4
%40 = sitofp i32 %39 to float
%41 = load i32, i32* %2
%42 = sitofp i32 %41 to float
%43 = fdiv float %40, %42
store float %43, float* %7
%44 = load float, float* %7
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %45)
%47 = load i32, i32* %5
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %6
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %1
ret i32 %51
}

LLVM IR (-O2):
@INT_MIN = global i32 0
@INT_MAX = global i32 0
@.str = [22 x i8] c"Entre com um numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [10 x i8] c"\0ASoma: %d\00"
@.str.3 = [13 x i8] c"\0AMedia: %.2f\00"
@.str.4 = [11 x i8] c"\0AMaior: %d\00"
@.str.5 = [11 x i8] c"\0AMenor: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @INT_MIN
%4 = load i32, i32* @INT_MAX
br label %5
5: ; preds = %0, %5
%6 = phi i32 [ %20, %5 ], [ -1, %0 ]
%7 = phi i32 [ %16, %5 ], [ %4, %0 ]
%8 = phi i32 [ %18, %5 ], [ %3, %0 ]
%9 = phi i32 [ %19, %5 ], [ 0, %0 ]
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 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* %1)
%12 = load i32, i32* %1
%13 = icmp slt i32 %12, %7
%14 = icmp ne i32 %12, 0
%15 = and i1 %13, %14
%16 = select i1 %15, i32 %12, i32 %7
%17 = icmp sgt i32 %12, %8
%18 = select i1 %17, i32 %12, i32 %8
%19 = add nsw i32 %12, %9
%20 = add nsw i32 %6, 1
%21 = icmp eq i32 %12, 0
br i1 %21, label %22, label %5
22: ; preds = %5
%23 = sitofp i32 %20 to float
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%25 = sitofp i32 %19 to float
%26 = fdiv float %25, %23
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %27)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %16)
ret i32 0
}