#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*/ printArray(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ radixSort(int *, int);
int main(void) {
  int size = 12;
  int list[] = {10, 2, 303, 4021, 293, 1, 0, 429, 480, 92, 2999, 14};
  printf("\n\nRunning Radix Sort Example in C!\n");
  printf("----------------------------------\n");
  printf("\nUnsorted List: ");
  printArray(&list[0], size);
  radixSort(&list[0], size);
  printf("\nSorted List:");
  printArray(&list[0], size);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xc,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x30,%edx
call   1050 <memcpy@plt>
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <printArray@plt>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <radixSort@plt>
lea    0xedb(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <printArray@plt>
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe8c(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xed0(%rip),%rdi
call   1040 <puts@plt>
lea    0xee7(%rip),%rdi
call   1040 <puts@plt>
lea    0xe99(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xc,%esi
call   1070 <printArray@plt>
mov    %rbx,%rdi
mov    $0xc,%esi
call   1060 <radixSort@plt>
lea    0xe81(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0xc,%esi
call   1070 <printArray@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.list = [12 x i32] [i32 10, i32 2, i32 303, i32 4021, i32 293, i32 1, i32 0, i32 429, i32 480, i32 92, i32 2999, i32 14]
@.str = [36 x i8] c"\0A\0ARunning Radix Sort Example in C!\0A\00"
@.str.1 = [36 x i8] c"----------------------------------\0A\00"
@.str.2 = [17 x i8] c"\0AUnsorted List: \00"
@.str.3 = [14 x i8] c"\0ASorted List:\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [12 x i32]
store i32 0, i32* %1
store i32 12, i32* %2
%4 = bitcast [12 x i32]* %3 to i8*
%5 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%8 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 0
%9 = load i32, i32* %2
%10 = call i32 @printArray(i32* %8, i32 %9)
%11 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 0
%12 = load i32, i32* %2
%13 = call i32 @radixSort(i32* %11, i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%15 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 0
%16 = load i32, i32* %2
%17 = call i32 @printArray(i32* %15, i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.list = [12 x i32] [i32 10, i32 2, i32 303, i32 4021, i32 293, i32 1, i32 0, i32 429, i32 480, i32 92, i32 2999, i32 14]
@.str.2 = [17 x i8] c"\0AUnsorted List: \00"
@.str.3 = [14 x i8] c"\0ASorted List:\00"
@str = [35 x i8] c"\0A\0ARunning Radix Sort Example in C!\00"
@str.5 = [35 x i8] c"----------------------------------\00"
define i32 @main() {
%1 = alloca [12 x i32]
%2 = bitcast [12 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.5, i64 0, i64 0))
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%6 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 0
%7 = call i32 @printArray(i32* %6, i32 12)
%8 = call i32 @radixSort(i32* %6, i32 12)
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @printArray(i32* %6, i32 12)
%11 = call i32 @putchar(i32 10)
ret i32 0
}