#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() {
  printf("\n\nRunning Radix Sort Example in C!\n");
  printf("----------------------------------\n");
  int size = 6;
  int list[] = {2, 3, 3, 1, 4, 1};
  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    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
movl   $0x6,-0x8(%rbp)
mov    0xf0b(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xf08(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xf05(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <printArray@plt>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <radixSort@plt>
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <printArray@plt>
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xedb(%rip),%rdi
call   1040 <puts@plt>
lea    0xef2(%rip),%rdi
call   1040 <puts@plt>
mov    0xe9c(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xe80(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xe8d(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x6,%esi
call   1070 <printArray@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1060 <radixSort@plt>
lea    0xe75(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1070 <printArray@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [36 x i8] c"\0A\0ARunning Radix Sort Example in C!\0A\00"
@.str.1 = [36 x i8] c"----------------------------------\0A\00"
@__const.main.list = [6 x i32] [i32 2, i32 3, i32 3, i32 1, i32 4, i32 1]
@.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 [6 x i32]
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
store i32 6, i32* %2
%6 = bitcast [6 x i32]* %3 to i8*
%7 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%9 = load i32, i32* %2
%10 = call i32 @printArray(i32* %8, i32 %9)
%11 = getelementptr inbounds [6 x i32], [6 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 [6 x i32], [6 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 = [6 x i32] [i32 2, i32 3, i32 3, i32 1, i32 4, i32 1]
@.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 [6 x i32]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.5, i64 0, i64 0))
%4 = bitcast [6 x i32]* %1 to i8*
%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 [6 x i32], [6 x i32]* %1, i64 0, i64 0
%7 = call i32 @printArray(i32* %6, i32 6)
%8 = call i32 @radixSort(i32* %6, i32 6)
%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 6)
%11 = call i32 @putchar(i32 10)
ret i32 0
}