#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 num, max, min;
  printf("Digite um número inteiro e positivo: ");
  scanf("%d", &num);
  max = min = num;
  do {
    printf("Digite outro número inteiro e positivo: ");
    scanf("%d", &num);
    if (num < 0) {
      printf("\nDigite um número positivo!\n\n");
      continue;
    } else if (num == 0)
      continue;
    else if (num > max)
      max = num;
    else if (num < min)
      min = num;
  } while (num != 0);
  printf("O 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    0xed3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    %eax,-0xc(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeac(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    11a1 <main+0x71>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ed <main+0xbd>
cmpl   $0x0,-0x8(%rbp)
jne    11b0 <main+0x80>
jmp    11ed <main+0xbd>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11c7 <main+0x97>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11de <main+0xae>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d9 <main+0xa9>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11de <main+0xae>
jmp    11e3 <main+0xb3>
jmp    11e8 <main+0xb8>
jmp    11ed <main+0xbd>
cmpl   $0x0,-0x8(%rbp)
jne    1166 <main+0x36>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9a(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%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    0xec7(%rip),%r14
lea    0x4(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%ebx
lea    0xeaf(%rip),%r12
lea    0xf11(%rip),%r13
mov    %ebx,%ebp
jmp    11a0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     11d7 <main+0x97>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%ecx
test   %ecx,%ecx
js     1190 <main+0x50>
je     11d7 <main+0x97>
mov    $0x1,%eax
cmp    %ebx,%ecx
jle    11d0 <main+0x90>
mov    %ecx,%ebx
jmp    119c <main+0x5c>
nopl   0x0(%rax)
cmp    %ebp,%ecx
cmovl  %ecx,%ebp
jmp    119c <main+0x5c>
lea    0xe76(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9d(%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 = [39 x i8] c"Digite um n\C3\BAmero inteiro e positivo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [42 x i8] c"Digite outro n\C3\BAmero inteiro e positivo: \00"
@.str.3 = [31 x i8] c"\0ADigite um n\C3\BAmero positivo!\0A\0A\00"
@.str.4 = [57 x i8] c"O maior valor digitado foi %d, e o menor valor foi %d.\0A\0A\00"
@.str.5 = [6 x i8] c"pause\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 ([39 x i8], [39 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
store i32 %7, i32* %4
store i32 %7, i32* %3
br label %8
8: ; preds = %35, %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, 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 = load i32, i32* %2
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %35
15: ; preds = %8
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15
br label %35
19: ; preds = %15
%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 = %19
%24 = load i32, i32* %2
store i32 %24, i32* %3
br label %32
25: ; preds = %19
%26 = load i32, i32* %2
%27 = load i32, i32* %4
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = load i32, i32* %2
store i32 %30, i32* %4
br label %31
31: ; preds = %29, %25
br label %32
32: ; preds = %31, %23
br label %33
33: ; preds = %32
br label %34
34: ; preds = %33
br label %35
35: ; preds = %34, %18, %13
%36 = load i32, i32* %2
%37 = icmp ne i32 %36, 0
br i1 %37, label %8, label %38
38: ; preds = %35
%39 = load i32, i32* %3
%40 = load i32, i32* %4
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i32 %39, i32 %40)
%42 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c"Digite um n\C3\BAmero inteiro e positivo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [42 x i8] c"Digite outro n\C3\BAmero inteiro e positivo: \00"
@.str.4 = [57 x i8] c"O maior valor digitado foi %d, e o menor valor foi %d.\0A\0A\00"
@.str.5 = [6 x i8] c"pause\00"
@str = [30 x i8] c"\0ADigite um n\C3\BAmero positivo!\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 ([39 x i8], [39 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
br label %6
6: ; preds = %23, %0
%7 = phi i32 [ %5, %0 ], [ %25, %23 ]
%8 = phi i32 [ %5, %0 ], [ %26, %23 ]
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %6
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%15 = load i32, i32* %1
br label %23
16: ; preds = %6
%17 = icmp eq i32 %11, 0
br i1 %17, label %28, label %18
18: ; preds = %16
%19 = icmp sgt i32 %11, %7
br i1 %19, label %23, label %20
20: ; preds = %18
%21 = icmp slt i32 %11, %8
%22 = select i1 %21, i32 %11, i32 %8
br label %23
23: ; preds = %20, %18, %13
%24 = phi i32 [ 1, %20 ], [ 1, %18 ], [ %15, %13 ]
%25 = phi i32 [ %7, %20 ], [ %11, %18 ], [ %7, %13 ]
%26 = phi i32 [ %22, %20 ], [ %8, %18 ], [ %8, %13 ]
%27 = icmp eq i32 %24, 0
br i1 %27, label %28, label %6
28: ; preds = %16, %23
%29 = phi i32 [ %26, %23 ], [ %8, %16 ]
%30 = phi i32 [ %25, %23 ], [ %7, %16 ]
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i32 %30, i32 %29)
%32 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}