#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*/ Bucket_Sort(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int array[100], i, num;
  printf("Enter the size of array : ");
  scanf("%d", &num);
  printf("Enter the %d elements to be sorted:\n", num);
  for (i = 0; i < num; i++)
    scanf("%d", &array[i]);
  printf("\nThe array of elements before sorting : \n");
  for (i = 0; i < num; i++)
    printf("%d ", array[i]);
  printf("\nThe array of elements after sorting : \n");
  Bucket_Sort(array, num);
  for (i = 0; i < num; i++)
    printf("%d ", array[i]);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x1a8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1a8(%rbp),%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x1a8(%rbp),%eax
jge    11c8 <main+0x98>
movslq -0x1a4(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe6c(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    1181 <main+0x51>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x1a8(%rbp),%eax
jge    1222 <main+0xf2>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    11e0 <main+0xb0>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a8(%rbp),%esi
call   1050 <Bucket_Sort@plt>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x1a8(%rbp),%eax
jge    128e <main+0x15e>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    124c <main+0x11c>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1a0,%rsp
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeaa(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11cd <main+0x7d>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe79(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     11b0 <main+0x60>
lea    0xe73(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    120c <main+0xbc>
lea    0xe5c(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11f0 <main+0xa0>
lea    0xe5d(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1070 <Bucket_Sort@plt>
cmpl   $0x0,0xc(%rsp)
jle    125c <main+0x10c>
lea    0xe0f(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1240 <main+0xf0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Enter the size of array : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [37 x i8] c"Enter the %d elements to be sorted:\0A\00"
@.str.3 = [42 x i8] c"\0AThe array of elements before sorting : \0A\00"
@.str.4 = [4 x i8] c"%d \00"
@.str.5 = [41 x i8] c"\0AThe array of elements after sorting : \0A\00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* 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* %4)
%7 = load i32, i32* %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %7)
store i32 0, i32* %3
br label %9
9: ; preds = %18, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
br label %18
18: ; preds = %13
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %9
21: ; preds = %9
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %23
23: ; preds = %33, %21
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %27
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %23
36: ; preds = %23
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%38 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%39 = load i32, i32* %4
%40 = call i32 @Bucket_Sort(i32* %38, i32 %39)
store i32 0, i32* %3
br label %41
41: ; preds = %51, %36
%42 = load i32, i32* %3
%43 = load i32, i32* %4
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %54
45: ; preds = %41
%46 = load i32, i32* %3
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %45
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 1
store i32 %53, i32* %3
br label %41
54: ; preds = %41
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Enter the size of array : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [37 x i8] c"Enter the %d elements to be sorted:\0A\00"
@.str.4 = [4 x i8] c"%d \00"
@str = [41 x i8] c"\0AThe array of elements before sorting : \00"
@str.7 = [40 x i8] c"\0AThe array of elements after sorting : \00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = bitcast [100 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @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* %2)
%7 = load i32, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %0, %11
%12 = phi i64 [ %15, %11 ], [ 0, %0 ]
%13 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %12
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %13)
%15 = add nuw nsw i64 %12, 1
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %11, label %19
19: ; preds = %11, %0
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%21 = load i32, i32* %2
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %19, %23
%24 = phi i64 [ %28, %23 ], [ 0, %19 ]
%25 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = add nuw nsw i64 %24, 1
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %28, %30
br i1 %31, label %23, label %32
32: ; preds = %23, %19
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.7, i64 0, i64 0))
%34 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%35 = load i32, i32* %2
%36 = call i32 @Bucket_Sort(i32* %34, i32 %35)
%37 = load i32, i32* %2
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %48
39: ; preds = %32, %39
%40 = phi i64 [ %44, %39 ], [ 0, %32 ]
%41 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = add nuw nsw i64 %40, 1
%45 = load i32, i32* %2
%46 = sext i32 %45 to i64
%47 = icmp slt i64 %44, %46
br i1 %47, label %39, label %48
48: ; preds = %39, %32
%49 = call i32 @putchar(i32 10)
ret i32 0
}