#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*/ countingSort(unsigned char **, unsigned char **, int, int);
int /*<<< orphan*/ printTweet(unsigned char *);
int /*<<< orphan*/ printf(char *);
void radixSort(unsigned char *A[], int n, int d) {
  int i, j;
  unsigned char *B[n];
  for (i = d - 1; i >= 0; i--) {
    countingSort(A, B, n, i);
    for (j = 0; j < n; j++)
      A[j] = B[j];
  }
  for (i = n - 1; i >= n - 10; i--) {
    printTweet(A[i]);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<radixSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11db <radixSort+0xab>
mov    -0x30(%rbp),%rsi
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1050 <countingSort@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c8 <radixSort+0x98>
mov    -0x30(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1196 <radixSort+0x66>
jmp    11cd <radixSort+0x9d>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1172 <radixSort+0x42>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0xa,%ecx
cmp    %ecx,%eax
jl     1220 <radixSort+0xf0>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <printTweet@plt>
lea    0xdf3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11e4 <radixSort+0xb4>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<radixSort>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
mov    %esi,%r12d
mov    %rsp,%r13
lea    0xf(,%r12,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
test   %edx,%edx
jle    11ae <radixSort+0x6e>
mov    %edx,%ebx
shl    $0x3,%r12
add    $0x1,%ebx
jmp    1188 <radixSort+0x48>
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jbe    11ae <radixSort+0x6e>
lea    -0x2(%rbx),%ecx
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r14d,%edx
call   1060 <countingSort@plt>
test   %r14d,%r14d
jle    1180 <radixSort+0x40>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1050 <memcpy@plt>
jmp    1180 <radixSort+0x40>
movslq %r14d,%rbx
add    $0xfffffff7,%r14d
movslq %r14d,%r14
add    $0x1,%rbx
nopl   0x0(%rax)
mov    -0x10(%r15,%rbx,8),%rdi
call   1040 <printTweet@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
cmp    %r14,%rbx
jg     11c0 <radixSort+0x80>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @radixSort(i8** %0, i32 %1, i32 %2) {
%4 = bitcast i8** %0 to i8*
%5 = zext i32 %1 to i64
%6 = alloca i8*, i64 %5
%7 = bitcast i8** %6 to i8*
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %14
9: ; preds = %3
%10 = icmp sgt i32 %1, 0
%11 = shl nuw nsw i64 %5, 3
br label %18
12: ; preds = %22, %18
%13 = icmp ugt i32 %19, 1
br i1 %13, label %18, label %14
14: ; preds = %12, %3
%15 = sext i32 %1 to i64
%16 = add nsw i32 %1, -9
%17 = sext i32 %16 to i64
br label %23
18: ; preds = %9, %12
%19 = phi i32 [ %2, %9 ], [ %20, %12 ]
%20 = add nsw i32 %19, -1
%21 = call i32 @countingSort(i8** %0, i8** %6, i32 %1, i32 %20)
br i1 %10, label %22, label %12
22: ; preds = %18
br label %12
23: ; preds = %14, %23
%24 = phi i64 [ %15, %14 ], [ %25, %23 ]
%25 = add nsw i64 %24, -1
%26 = getelementptr inbounds i8*, i8** %0, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @printTweet(i8* %27)
%29 = call i32 @putchar(i32 10)
%30 = icmp sgt i64 %24, %17
br i1 %30, label %23, label %31
31: ; preds = %23
ret void
}