#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*/ insertion(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ mostra(int *, int);
int /*<<< orphan*/ printf(char *);
int main() {
  int elementos = 0;
  int vetor[5000];
  if (carregarray(vetor, &elementos))
    return -1;
  printf("Vetor:\n");
  mostra(vetor, elementos);
  printf("Ordenado:\n");
  insertion(vetor, 0, elementos);
  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    11cd <main+0x8d>
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
lea    -0x4e30(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <mostra@plt>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
lea    -0x4e30(%rbp),%rdi
mov    -0x8(%rbp),%edx
xor    %esi,%esi
call   1050 <insertion@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    11b0 <main+0x70>
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
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <insertion@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 %20
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 = call i32 @insertion(i32* %14, i32 0, i32 %15)
%17 = getelementptr inbounds [5000 x i32], [5000 x i32]* %3, i64 0, i64 0
%18 = load i32, i32* %2
%19 = call i32 @mostra(i32* %17, i32 %18)
store i32 0, i32* %1
br label %20
20: ; preds = %8, %7
%21 = load i32, i32* %1
ret i32 %21
}

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 %17
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 = call i32 @insertion(i32* %5, i32 0, i32 %13)
%15 = load i32, i32* %1
%16 = call i32 @mostra(i32* %5, i32 %15)
br label %17
17: ; preds = %0, %8
%18 = phi i32 [ 0, %8 ], [ -1, %0 ]
ret i32 %18
}