#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 /*<<< orphan*/ system(char *);
int main() {
  int x, max, min;
  printf("Digite um número inteiro positivo: ");
  scanf("%d", &x);
  if (x == -1) {
    printf("\nFim de programa!\n\n");
    system("pause");
    return (0);
  }
  max = min = x;
  while (x != -1) {
    printf("Digite um número inteiro positivo: ");
    scanf("%d", &x);
    if (x > max)
      max = x;
    else if (x < min) {
      if (x != -1)
        min = x;
    }
  }
  printf("\nO maior valor digitado foi %d e o menor valor foi %d.\n\n", max,
         min);
  system("pause");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0xffffffff,-0x8(%rbp)
jne    118d <main+0x5d>
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
call   1030 <system@plt>
movl   $0x0,-0x4(%rbp)
jmp    1227 <main+0xf7>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     1200 <main+0xd0>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe70(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11d5 <main+0xa5>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11fb <main+0xcb>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11f6 <main+0xc6>
cmpl   $0xffffffff,-0x8(%rbp)
je     11f1 <main+0xc1>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11f6 <main+0xc6>
jmp    11fb <main+0xcb>
jmp    1196 <main+0x66>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe21(%rip),%rdi
call   1030 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%ebx
cmp    $0xffffffff,%ebx
je     11db <main+0x9b>
lea    0xe86(%rip),%r14
lea    0xea4(%rip),%r15
lea    0x4(%rsp),%r12
mov    %ebx,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebx,%r13d
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0xffffffff,%eax
cmovne %eax,%ebx
cmp    %r13d,%eax
cmovge %r13d,%ebx
cmp    %ebp,%eax
cmovg  %eax,%ebp
cmovg  %r13d,%ebx
cmp    $0xffffffff,%eax
jne    1190 <main+0x50>
lea    0xe60(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e7 <main+0xa7>
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3a(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Digite um n\C3\BAmero inteiro positivo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"\0AFim de programa!\0A\0A\00"
@.str.3 = [6 x i8] c"pause\00"
@.str.4 = [57 x i8] c"\0AO maior valor digitado foi %d e o menor valor foi %d.\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 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 eq i32 %7, -1
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %42
12: ; preds = %0
%13 = load i32, i32* %2
store i32 %13, i32* %4
store i32 %13, i32* %3
br label %14
14: ; preds = %36, %12
%15 = load i32, i32* %2
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %37
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = icmp sgt i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = load i32, i32* %2
store i32 %24, i32* %3
br label %36
25: ; preds = %17
%26 = load i32, i32* %2
%27 = load i32, i32* %4
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = load i32, i32* %2
%31 = icmp ne i32 %30, -1
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = load i32, i32* %2
store i32 %33, i32* %4
br label %34
34: ; preds = %32, %29
br label %35
35: ; preds = %34, %25
br label %36
36: ; preds = %35, %23
br label %14
37: ; preds = %14
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i32 %38, i32 %39)
%41 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %42
42: ; preds = %37, %9
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [37 x i8] c"Digite um n\C3\BAmero inteiro positivo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [6 x i8] c"pause\00"
@.str.4 = [57 x i8] c"\0AO maior valor digitado foi %d e o menor valor foi %d.\0A\0A\00"
@str = [19 x i8] c"\0AFim de programa!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %25
9: ; preds = %0, %9
%10 = phi i32 [ %21, %9 ], [ %5, %0 ]
%11 = phi i32 [ %20, %9 ], [ %5, %0 ]
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 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* %1)
%14 = load i32, i32* %1
%15 = icmp sgt i32 %14, %11
%16 = icmp slt i32 %14, %10
%17 = icmp ne i32 %14, -1
%18 = and i1 %16, %17
%19 = select i1 %18, i32 %14, i32 %10
%20 = select i1 %15, i32 %14, i32 %11
%21 = select i1 %15, i32 %10, i32 %19
%22 = icmp eq i32 %14, -1
br i1 %22, label %23, label %9
23: ; preds = %9
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i32 %20, i32 %21)
br label %25
25: ; preds = %23, %7
%26 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}