#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 *malloc(int);
int /*<<< orphan*/ print(int *, int, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read(int *, int);
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 range\n");
  scanf("%d", &n);
  int *v = malloc(sizeof(int) * n);
  int i;
  read(v, n);
  print(v, n, "Before");
  printf("\n");
  bucketSort(v, n);
  printf("\n");
  print(v, n, "After");
  printf("\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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   1030 <printf@plt>
lea    0xe65(%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   1050 <read@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
lea    0xe32(%rip),%rdx
call   1040 <print@plt>
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1090 <bucketSort@plt>
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
lea    0xe02(%rip),%rdx
call   1040 <print@plt>
lea    0xdfc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%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   1040 <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   1060 <read@plt>
mov    0x4(%rsp),%esi
lea    0xe19(%rip),%rdx
mov    %rbx,%rdi
call   1050 <print@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   10a0 <bucketSort@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%esi
lea    0xded(%rip),%rdx
mov    %rbx,%rdi
call   1050 <print@plt>
lea    0xdfa(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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