#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 argc, const char *argv[]) {
  int i, soma = 0, v, num, maior, menor;
  printf("digite a quantidade de valores:");
  scanf("%d", &v);
  for (i = 1; i <= v; i++) {
    printf("digite um numero entre 0 e 1000: ");
    scanf("%d", &num);
    if ((num >= 0) && (num < 1000)) {
      if (i == 1) {
        maior = num;
        menor = num;
      }
      if (num >= maior) {
        maior = num;
      } else if (num < menor) {
        menor = num;
      }
      soma = soma + num;
    } else {
      printf("numero fora do intervalo\n");
      maior = 0;
      menor = 0;
      break;
    }
  }
  printf("a soma dos valores: %d \no maior numero: %d \ne o menor numero: %d\n",
         soma, maior, menor);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     1229 <main+0x109>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9d(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x20(%rbp)
jl     11f5 <main+0xd5>
cmpl   $0x3e8,-0x20(%rbp)
jge    11f5 <main+0xd5>
cmpl   $0x1,-0x14(%rbp)
jne    11b9 <main+0x99>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jl     11d0 <main+0xb0>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11e7 <main+0xc7>
mov    -0x20(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    11e2 <main+0xc2>
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    11e7 <main+0xc7>
mov    -0x18(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1216 <main+0xf6>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
jmp    1229 <main+0x109>
jmp    121b <main+0xfb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1162 <main+0x42>
mov    -0x18(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xec2(%rip),%r12
mov    %rsp,%r13
xor    %r15d,%r15d
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%eax
cmp    $0x3e7,%eax
ja     11bb <main+0x8b>
test   %r15d,%r15d
cmove  %eax,%ebp
cmove  %eax,%ebx
cmp    %ebx,%eax
mov    %ebx,%ecx
cmovl  %eax,%ecx
cmp    %ebp,%eax
cmovge %eax,%ebp
cmovl  %ecx,%ebx
add    %eax,%r14d
add    $0x1,%r15d
cmp    0x4(%rsp),%r15d
jl     1170 <main+0x40>
jmp    11cb <main+0x9b>
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
xor    %ebx,%ebx
lea    0xe73(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"digite a quantidade de valores:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"digite um numero entre 0 e 1000: \00"
@.str.3 = [26 x i8] c"numero fora do intervalo\0A\00"
@.str.4 = [66 x i8] c"a soma dos valores: %d \0Ao maior numero: %d \0Ae o menor numero: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
store i32 1, i32* %6
br label %14
14: ; preds = %52, %2
%15 = load i32, i32* %6
%16 = load i32, i32* %8
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %55
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%21 = load i32, i32* %9
%22 = icmp sge i32 %21, 0
br i1 %22, label %23, label %49
23: ; preds = %18
%24 = load i32, i32* %9
%25 = icmp slt i32 %24, 1000
br i1 %25, label %26, label %49
26: ; preds = %23
%27 = load i32, i32* %6
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* %9
store i32 %30, i32* %10
%31 = load i32, i32* %9
store i32 %31, i32* %11
br label %32
32: ; preds = %29, %26
%33 = load i32, i32* %9
%34 = load i32, i32* %10
%35 = icmp sge i32 %33, %34
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = load i32, i32* %9
store i32 %37, i32* %10
br label %45
38: ; preds = %32
%39 = load i32, i32* %9
%40 = load i32, i32* %11
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = load i32, i32* %9
store i32 %43, i32* %11
br label %44
44: ; preds = %42, %38
br label %45
45: ; preds = %44, %36
%46 = load i32, i32* %7
%47 = load i32, i32* %9
%48 = add nsw i32 %46, %47
store i32 %48, i32* %7
br label %51
49: ; preds = %23, %18
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %10
store i32 0, i32* %11
br label %55
51: ; preds = %45
br label %52
52: ; preds = %51
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %14
55: ; preds = %49, %14
%56 = load i32, i32* %7
%57 = load i32, i32* %10
%58 = load i32, i32* %11
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.4, i64 0, i64 0), i32 %56, i32 %57, i32 %58)
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"digite a quantidade de valores:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"digite um numero entre 0 e 1000: \00"
@.str.4 = [66 x i8] c"a soma dos valores: %d \0Ao maior numero: %d \0Ae o menor numero: %d\0A\00"
@str = [25 x i8] c"numero fora do intervalo\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 0
br label %11
11: ; preds = %2, %20
%12 = phi i32 [ %28, %20 ], [ undef, %2 ]
%13 = phi i32 [ %26, %20 ], [ undef, %2 ]
%14 = phi i32 [ %29, %20 ], [ 0, %2 ]
%15 = phi i32 [ %30, %20 ], [ 1, %2 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%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 = icmp ult i32 %18, 1000
br i1 %19, label %20, label %33
20: ; preds = %11
%21 = icmp eq i32 %15, 1
%22 = select i1 %21, i32 %18, i32 %13
%23 = select i1 %21, i32 %18, i32 %12
%24 = icmp slt i32 %18, %22
%25 = icmp slt i32 %18, %23
%26 = select i1 %24, i32 %22, i32 %18
%27 = select i1 %24, i1 %25, i1 false
%28 = select i1 %27, i32 %18, i32 %23
%29 = add nsw i32 %18, %14
%30 = add nuw nsw i32 %15, 1
%31 = load i32, i32* %3
%32 = icmp slt i32 %15, %31
br i1 %32, label %11, label %35
33: ; preds = %11
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %35
35: ; preds = %20, %33
%36 = phi i32 [ %14, %33 ], [ %29, %20 ]
%37 = phi i32 [ 0, %33 ], [ %26, %20 ]
%38 = phi i32 [ 0, %33 ], [ %28, %20 ]
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.4, i64 0, i64 0), i32 %36, i32 %37, i32 %38)
ret i32 0
}