#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*/ completa_vetor(int *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ mostra_vetor(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ s_sort(int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char *argv[]) {
  int *vetor, tamanho_do_vetor;
  printf("digite o tamanho do vetor ");
  scanf("%d", &tamanho_do_vetor);
  vetor = (int *)malloc(tamanho_do_vetor * sizeof(int));
  completa_vetor(vetor, tamanho_do_vetor);
  s_sort(vetor, tamanho_do_vetor);
  mostra_vetor(vetor, tamanho_do_vetor);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
lea    0xe92(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <completa_vetor@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1080 <s_sort@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <mostra_vetor@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
lea    0xea3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%esi
mov    %rax,%rdi
call   1060 <completa_vetor@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1080 <s_sort@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1050 <mostra_vetor@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"digite o tamanho do vetor \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%10 = load i32, i32* %7
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 4
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
store i32* %15, i32** %6
%16 = load i32*, i32** %6
%17 = load i32, i32* %7
%18 = call i32 @completa_vetor(i32* %16, i32 %17)
%19 = load i32*, i32** %6
%20 = load i32, i32* %7
%21 = call i32 @s_sort(i32* %19, i32 %20)
%22 = load i32*, i32** %6
%23 = load i32, i32* %7
%24 = call i32 @mostra_vetor(i32* %22, i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"digite o tamanho do vetor \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 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* %3)
%7 = load i32, i32* %3
%8 = shl i32 %7, 2
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i32*
%11 = load i32, i32* %3
%12 = call i32 @completa_vetor(i32* %10, i32 %11)
%13 = load i32, i32* %3
%14 = call i32 @s_sort(i32* %10, i32 %13)
%15 = load i32, i32* %3
%16 = call i32 @mostra_vetor(i32* %10, i32 %15)
ret i32 0
}