#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 *, int *);
int main() {
  int n1, n2, n3, up, down, mid;
  printf("Ola, eu trabalho e colocar numeros em ordem crescente. Vamos "
         "comecar?\n Escreva tres numeros...\n");
  scanf("%d"
        "%d"
        "%d",
        &n1, &n2, &n3);
  if (n1 > n2) {
    up = n1;
    down = n2;
  } else {
    up = n2;
    down = n1;
  }
  if ((n3 > down) || (n3 < up)) {
    mid = n3;
  }
  if (n3 > up) {
    mid = up;
    up = n3;
  }
  if (n3 < down) {
    mid = down;
    down = n3;
  }
  printf("Os numeros, em ordem crescente, sao: %d %d %d\n", down, mid, up);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf1c(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1172 <main+0x52>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    117e <main+0x5e>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1196 <main+0x76>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    119c <main+0x7c>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11b4 <main+0x94>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11cc <main+0xac>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xefb(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb9(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
mov    0x10(%rsp),%ecx
cmp    %ecx,%eax
mov    %ecx,%edx
cmovg  %eax,%edx
cmovg  %ecx,%eax
mov    0xc(%rsp),%esi
cmp    %edx,%esi
mov    %edx,%ecx
cmovg  %esi,%ecx
cmovle %esi,%edx
cmp    %eax,%esi
cmovge %eax,%esi
cmovl  %eax,%edx
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [96 x i8] c"Ola, eu trabalho e colocar numeros em ordem crescente. Vamos comecar?\0A Escreva tres numeros...\0A\00"
@.str.1 = [7 x i8] c"%d%d%d\00"
@.str.2 = [47 x i8] c"Os numeros, em ordem crescente, sao: %d %d %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
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = icmp sgt i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = load i32, i32* %2
store i32 %14, i32* %5
%15 = load i32, i32* %3
store i32 %15, i32* %6
br label %19
16: ; preds = %0
%17 = load i32, i32* %3
store i32 %17, i32* %5
%18 = load i32, i32* %2
store i32 %18, i32* %6
br label %19
19: ; preds = %16, %13
%20 = load i32, i32* %4
%21 = load i32, i32* %6
%22 = icmp sgt i32 %20, %21
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %23, %19
%28 = load i32, i32* %4
store i32 %28, i32* %7
br label %29
29: ; preds = %27, %23
%30 = load i32, i32* %4
%31 = load i32, i32* %5
%32 = icmp sgt i32 %30, %31
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i32, i32* %5
store i32 %34, i32* %7
%35 = load i32, i32* %4
store i32 %35, i32* %5
br label %36
36: ; preds = %33, %29
%37 = load i32, i32* %4
%38 = load i32, i32* %6
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load i32, i32* %6
store i32 %41, i32* %7
%42 = load i32, i32* %4
store i32 %42, i32* %6
br label %43
43: ; preds = %40, %36
%44 = load i32, i32* %6
%45 = load i32, i32* %7
%46 = load i32, i32* %5
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 %44, i32 %45, i32 %46)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%d%d%d\00"
@.str.2 = [47 x i8] c"Os numeros, em ordem crescente, sao: %d %d %d\0A\00"
@str = [95 x i8] c"Ola, eu trabalho e colocar numeros em ordem crescente. Vamos comecar?\0A Escreva tres numeros...\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([95 x i8], [95 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = icmp sgt i32 %9, %10
%12 = select i1 %11, i32 %9, i32 %10
%13 = select i1 %11, i32 %10, i32 %9
%14 = load i32, i32* %3
%15 = icmp sgt i32 %14, %13
%16 = icmp slt i32 %14, %12
%17 = select i1 %15, i1 true, i1 %16
%18 = select i1 %17, i32 %14, i32 undef
%19 = icmp sgt i32 %14, %12
%20 = select i1 %19, i32 %14, i32 %12
%21 = select i1 %19, i32 %12, i32 %18
%22 = icmp slt i32 %14, %13
%23 = select i1 %22, i32 %14, i32 %13
%24 = select i1 %22, i32 %13, i32 %21
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %24, i32 %20)
ret i32 0
}