#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 */
scalar_t__ carregarray(int *, int *);
int /*<<< orphan*/ mostra(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quicksort(int *, int /*<<< orphan*/, int);
int main() {
  int elementos = 0;
  int vetor[5000];
  if (carregarray(vetor, &elementos))
    return -1;
  printf("Vetor:\n");
  mostra(vetor, elementos);
  printf("Ordenado:\n");
  quicksort(vetor, 0, elementos - 1);
  mostra(vetor, elementos);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x4e30(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <carregarray@plt>
cmp    $0x0,%rax
je     117f <main+0x3f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d0 <main+0x90>
lea    0xe7a(%rip),%rdi
call   1050 <printf@plt>
lea    -0x4e30(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <mostra@plt>
lea    0xe67(%rip),%rdi
call   1050 <printf@plt>
lea    -0x4e30(%rbp),%rdi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1040 <quicksort@plt>
lea    -0x4e30(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <mostra@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4e30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x4e38,%rsp
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1060 <carregarray@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jne    11b3 <main+0x73>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1040 <mostra@plt>
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%edx
add    $0xffffffff,%edx
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <quicksort@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
call   1040 <mostra@plt>
mov    %ebx,%eax
add    $0x4e38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Vetor:\0A\00"
@.str.1 = [11 x i8] c"Ordenado:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5000 x i32]
store i32 0, i32* %1
store i32 0, i32* %2
%4 = getelementptr inbounds [5000 x i32], [5000 x i32]* %3, i64 0, i64 0
%5 = call i64 @carregarray(i32* %4, i32* %2)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %0
store i32 -1, i32* %1
br label %21
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [5000 x i32], [5000 x i32]* %3, i64 0, i64 0
%11 = load i32, i32* %2
%12 = call i32 @mostra(i32* %10, i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [5000 x i32], [5000 x i32]* %3, i64 0, i64 0
%15 = load i32, i32* %2
%16 = sub nsw i32 %15, 1
%17 = call i32 @quicksort(i32* %14, i32 0, i32 %16)
%18 = getelementptr inbounds [5000 x i32], [5000 x i32]* %3, i64 0, i64 0
%19 = load i32, i32* %2
%20 = call i32 @mostra(i32* %18, i32 %19)
store i32 0, i32* %1
br label %21
21: ; preds = %8, %7
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@str = [7 x i8] c"Vetor:\00"
@str.2 = [10 x i8] c"Ordenado:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5000 x i32]
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast [5000 x i32]* %2 to i8*
%5 = getelementptr inbounds [5000 x i32], [5000 x i32]* %2, i64 0, i64 0
%6 = call i64 @carregarray(i32* %5, i32* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = call i32 @mostra(i32* %5, i32 %10)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.2, i64 0, i64 0))
%13 = load i32, i32* %1
%14 = add nsw i32 %13, -1
%15 = call i32 @quicksort(i32* %5, i32 0, i32 %14)
%16 = load i32, i32* %1
%17 = call i32 @mostra(i32* %5, i32 %16)
br label %18
18: ; preds = %0, %8
%19 = phi i32 [ 0, %8 ], [ -1, %0 ]
ret i32 %19
}