#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 atoi(char *);
int /*<<< orphan*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int *radix_sort(int *, int);
int main(int argc, char *argv[]) {
  int number = argc - 1;
  int i, *array, *out_array;
  array = malloc(number * sizeof(int));
  for (i = 0; i < number; i++) {
    array[i] = atoi(argv[i + 1]);
  }
  out_array = radix_sort(array, number);
  for (i = 0; i < number; i++) {
    printf("%d ", out_array[i]);
  }
  printf("\n");
  free(array);
  free(out_array);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c6 <main+0x76>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <atoi@plt>
mov    %eax,%edx
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1189 <main+0x39>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <radix_sort@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1210 <main+0xc0>
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11dd <main+0x8d>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%r15d
lea    -0x1(%r15),%ebx
lea    -0x4(,%r15,4),%edi
ff
call   1070 <malloc@plt>
mov    %rax,%r12
cmp    $0x1,%r15d
jle    11f9 <main+0x99>
mov    %ebx,0x4(%rsp)
mov    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x1(%rbp),%r14
mov    0x8(%r13,%rbp,8),%rdi
call   1080 <atoi@plt>
mov    %eax,(%r12,%rbp,4)
mov    %r14,%rbp
cmp    %r14,%rbx
jne    11a0 <main+0x40>
mov    %r12,%rdi
mov    0x4(%rsp),%esi
call   1060 <radix_sort@plt>
mov    %rax,%r14
cmp    $0x2,%r15d
jl     1206 <main+0xa6>
lea    0xe2a(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbp,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11e0 <main+0x80>
jmp    1206 <main+0xa6>
mov    %r12,%rdi
mov    %ebx,%esi
call   1060 <radix_sort@plt>
mov    %rax,%r14
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = sub nsw i32 %10, 1
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 4
%15 = trunc i64 %14 to i32
%16 = call i32* @malloc(i32 %15)
store i32* %16, i32** %8
store i32 0, i32* %7
br label %17
17: ; preds = %33, %2
%18 = load i32, i32* %7
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %36
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %22, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
%29 = load i32*, i32** %8
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
store i32 %28, i32* %32
br label %33
33: ; preds = %21
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %17
36: ; preds = %17
%37 = load i32*, i32** %8
%38 = load i32, i32* %6
%39 = call i32* @radix_sort(i32* %37, i32 %38)
store i32* %39, i32** %9
store i32 0, i32* %7
br label %40
40: ; preds = %51, %36
%41 = load i32, i32* %7
%42 = load i32, i32* %6
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %54
44: ; preds = %40
%45 = load i32*, i32** %9
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %44
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %40
54: ; preds = %40
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%56 = load i32*, i32** %8
%57 = call i32 @free(i32* %56)
%58 = load i32*, i32** %9
%59 = call i32 @free(i32* %58)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add nsw i32 %0, -1
%4 = shl i32 %3, 2
%5 = tail call i32* @malloc(i32 %4)
%6 = icmp sgt i32 %0, 1
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32* @radix_sort(i32* %5, i32 %3)
br label %30
9: ; preds = %2
%10 = zext i32 %3 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %13, %11 ]
%13 = add nuw nsw i64 %12, 1
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = getelementptr inbounds i32, i32* %5, i64 %12
store i32 %16, i32* %17
%18 = icmp eq i64 %13, %10
br i1 %18, label %19, label %11
19: ; preds = %11
%20 = tail call i32* @radix_sort(i32* %5, i32 %3)
br i1 %6, label %21, label %30
21: ; preds = %19
%22 = zext i32 %3 to i64
br label %23
23: ; preds = %21, %23
%24 = phi i64 [ 0, %21 ], [ %28, %23 ]
%25 = getelementptr inbounds i32, i32* %20, i64 %24
%26 = load i32, i32* %25
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = add nuw nsw i64 %24, 1
%29 = icmp eq i64 %28, %22
br i1 %29, label %30, label %23
30: ; preds = %23, %7, %19
%31 = phi i32* [ %8, %7 ], [ %20, %19 ], [ %20, %23 ]
%32 = tail call i32 @putchar(i32 10)
%33 = tail call i32 @free(i32* %5)
%34 = tail call i32 @free(i32* %31)
ret i32 0
}