#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 *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int in[10] = {1, 20, 23, 4, 53, 4, 3, 4, 4, 0};
  int out[100] = {0};
  int index = 0;
  int i = 0;
  bucket_sort(in, 10, out);
  printf("After sort:");
  for (index; index < 100; index++) {
    for (i = 0; i < out[index]; i++) {
      printf("%d ", index);
    }
  }
  printf("\n");
  printf("\b");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x28,%edx
call   1060 <memcpy@plt>
lea    -0x1c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
movl   $0x0,-0x1c4(%rbp)
movl   $0x0,-0x1c8(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x1c0(%rbp),%rdx
mov    $0xa,%esi
call   1050 <bucket_sort@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x64,-0x1c4(%rbp)
jge    1223 <main+0xe3>
movl   $0x0,-0x1c8(%rbp)
mov    -0x1c8(%rbp),%eax
movslq -0x1c4(%rbp),%rcx
cmp    -0x1c0(%rbp,%rcx,4),%eax
jge    120a <main+0xca>
mov    -0x1c4(%rbp),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c8(%rbp)
jmp    11c8 <main+0x88>
jmp    120f <main+0xcf>
mov    -0x1c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c4(%rbp)
jmp    11b1 <main+0x71>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1c0,%rsp
mov    0xece(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe96(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x30(%rsp),%rbx
mov    $0x190,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rsp,%rdi
mov    $0xa,%esi
mov    %rbx,%rdx
call   1060 <bucket_sort@plt>
lea    0xe8f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8d(%rip),%r14
xor    %ebx,%ebx
jmp    11ba <main+0x7a>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x64,%rbx
je     11e7 <main+0xa7>
cmpl   $0x0,0x30(%rsp,%rbx,4)
jle    11b0 <main+0x70>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    0x30(%rsp,%rbx,4),%ebp
jl     11d0 <main+0x90>
jmp    11b0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x8,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.in = [10 x i32] [i32 1, i32 20, i32 23, i32 4, i32 53, i32 4, i32 3, i32 4, i32 4, i32 0]
@.str = [12 x i8] c"After sort:\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [2 x i8] c"\08\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca [100 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [10 x i32]* %2 to i8*
%7 = bitcast [100 x i32]* %3 to i8*
store i32 0, i32* %4
store i32 0, i32* %5
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%9 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%10 = call i32 @bucket_sort(i32* %8, i32 10, i32* %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* %4
br label %13
13: ; preds = %31, %0
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 100
br i1 %15, label %16, label %34
16: ; preds = %13
store i32 0, i32* %5
br label %17
17: ; preds = %27, %16
%18 = load i32, i32* %5
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = icmp slt i32 %18, %22
br i1 %23, label %24, label %30
24: ; preds = %17
%25 = load i32, i32* %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %24
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %17
30: ; preds = %17
br label %31
31: ; preds = %30
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %13
34: ; preds = %13
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@__const.main.in = [10 x i32] [i32 1, i32 20, i32 23, i32 4, i32 53, i32 4, i32 3, i32 4, i32 4, i32 0]
@.str = [12 x i8] c"After sort:\00"
@.str.1 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca [100 x i32]
%3 = bitcast [10 x i32]* %1 to i8*
%4 = bitcast [100 x i32]* %2 to i8*
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%6 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%7 = call i32 @bucket_sort(i32* %5, i32 10, i32* %6)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %0, %22
%10 = phi i64 [ 0, %0 ], [ %23, %22 ]
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %9
%15 = trunc i64 %10 to i32
br label %16
16: ; preds = %14, %16
%17 = phi i32 [ %19, %16 ], [ 0, %14 ]
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%19 = add nuw nsw i32 %17, 1
%20 = load i32, i32* %11
%21 = icmp slt i32 %19, %20
br i1 %21, label %16, label %22
22: ; preds = %16, %9
%23 = add nuw nsw i64 %10, 1
%24 = icmp eq i64 %23, 100
br i1 %24, label %25, label %9
25: ; preds = %22
%26 = call i32 @putchar(i32 10)
%27 = call i32 @putchar(i32 8)
ret i32 0
}