#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*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ radix(int, int, int *, int *);
void radix_sort(int *source, int N) {
  int *temp = malloc(N * sizeof(int));
  radix(0, N, source, temp);
  radix(8, N, temp, source);
  radix(16, N, source, temp);
  radix(24, N, temp, source);
  free(temp);
}


x86 assembly (clang, -O0):
<radix_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
xor    %edi,%edi
call   1040 <radix@plt>
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    $0x8,%edi
call   1040 <radix@plt>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x10,%edi
call   1040 <radix@plt>
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    $0x18,%edi
call   1040 <radix@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<radix_sort>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r14
lea    0x0(,%r15,4),%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
mov    %r15d,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   1040 <radix@plt>
mov    $0x8,%edi
mov    %r15d,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1040 <radix@plt>
mov    $0x10,%edi
mov    %r15d,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1040 <radix@plt>
mov    $0x18,%edi
mov    %r15d,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1040 <radix@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @radix_sort(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = sext i32 %6 to i64
%8 = mul i64 %7, 4
%9 = trunc i64 %8 to i32
%10 = call i32* @malloc(i32 %9)
store i32* %10, i32** %5
%11 = load i32, i32* %4
%12 = load i32*, i32** %3
%13 = load i32*, i32** %5
%14 = call i32 @radix(i32 0, i32 %11, i32* %12, i32* %13)
%15 = load i32, i32* %4
%16 = load i32*, i32** %5
%17 = load i32*, i32** %3
%18 = call i32 @radix(i32 8, i32 %15, i32* %16, i32* %17)
%19 = load i32, i32* %4
%20 = load i32*, i32** %3
%21 = load i32*, i32** %5
%22 = call i32 @radix(i32 16, i32 %19, i32* %20, i32* %21)
%23 = load i32, i32* %4
%24 = load i32*, i32** %5
%25 = load i32*, i32** %3
%26 = call i32 @radix(i32 24, i32 %23, i32* %24, i32* %25)
%27 = load i32*, i32** %5
%28 = call i32 @free(i32* %27)
ret void
}

LLVM IR (-O2):
define void @radix_sort(i32* %0, i32 %1) {
%3 = shl i32 %1, 2
%4 = tail call i32* @malloc(i32 %3)
%5 = tail call i32 @radix(i32 0, i32 %1, i32* %0, i32* %4)
%6 = tail call i32 @radix(i32 8, i32 %1, i32* %4, i32* %0)
%7 = tail call i32 @radix(i32 16, i32 %1, i32* %0, i32* %4)
%8 = tail call i32 @radix(i32 24, i32 %1, i32* %4, i32* %0)
%9 = tail call i32 @free(i32* %4)
ret void
}