#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*/ bucketSort(int *, int);
int /*<<< orphan*/ ler(int *, int);
int *malloc(int);
int /*<<< orphan*/ print(int *, int, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  int n;
  printf("Input the array size\n");
  scanf("%d", &n);
  int *arr = malloc(sizeof(int) * n);
  ler(arr, n);
  print(arr, n, "Antes");
  printf("\n");
  bucketSort(arr, n);
  printf("\n");
  print(arr, n, "Depois");
  printf("\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe64(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10a0 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <ler@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
lea    0xe31(%rip),%rdx
call   1050 <print@plt>
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1090 <bucketSort@plt>
lea    0xe1b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
lea    0xe00(%rip),%rdx
call   1050 <print@plt>
lea    0xdfb(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
lea    0xe67(%rip),%rdi
call   1050 <puts@plt>
lea    0xe4b(%rip),%rdi
lea    0x4(%rsp),%rsi
call   10b0 <scanf@plt>
mov    0x4(%rsp),%r14d
lea    0x0(,%r14,4),%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14d,%esi
call   1030 <ler@plt>
mov    0x4(%rsp),%esi
lea    0xe19(%rip),%rdx
mov    %rbx,%rdi
call   1060 <print@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   10a0 <bucketSort@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x4(%rsp),%esi
lea    0xdec(%rip),%rdx
mov    %rbx,%rdi
call   1060 <print@plt>
lea    0xdf9(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Input the array size\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"Antes\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [7 x i8] c"Depois\00"
@.str.5 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = mul i64 4, %9
%11 = trunc i64 %10 to i32
%12 = call i32* @malloc(i32 %11)
store i32* %12, i32** %3
%13 = load i32*, i32** %3
%14 = load i32, i32* %2
%15 = call i32 @ler(i32* %13, i32 %14)
%16 = load i32*, i32** %3
%17 = load i32, i32* %2
%18 = call i32 @print(i32* %16, i32 %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32*, i32** %3
%21 = load i32, i32* %2
%22 = call i32 @bucketSort(i32* %20, i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = load i32*, i32** %3
%25 = load i32, i32* %2
%26 = call i32 @print(i32* %24, i32 %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"Antes\00"
@.str.4 = [7 x i8] c"Depois\00"
@str = [21 x i8] c"Input the array size\00"
@str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
%4 = bitcast i32* %1 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 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* %1)
%7 = load i32, i32* %1
%8 = shl i32 %7, 2
%9 = call i32* @malloc(i32 %8)
%10 = call i32 @ler(i32* %9, i32 %7)
%11 = load i32, i32* %1
%12 = call i32 @print(i32* %9, i32 %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @putchar(i32 10)
%14 = load i32, i32* %1
%15 = call i32 @bucketSort(i32* %9, i32 %14)
%16 = call i32 @putchar(i32 10)
%17 = load i32, i32* %1
%18 = call i32 @print(i32* %9, i32 %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0))
ret i32 0
}