#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);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int A[100], n, i, Max = -1;
  printf("Enter Number of Elements: ");
  scanf("%d", &n);
  printf("Enter %d Elements(>=0):\n", n);
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
    Max = (Max > A[i]) ? Max : A[i];
  }
  radixSort(A, n, Max);
  printArray(A, n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x1ac(%rbp)
ff ff ff
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x1a4(%rbp),%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x1a4(%rbp),%eax
jge    122d <main+0xed>
movslq -0x1a8(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe52(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x1ac(%rbp),%eax
movslq -0x1a8(%rbp),%rcx
cmp    -0x1a0(%rbp,%rcx,4),%eax
jle    11f9 <main+0xb9>
mov    -0x1ac(%rbp),%eax
mov    %eax,-0x1b0(%rbp)
jmp    120d <main+0xcd>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    %eax,-0x1b0(%rbp)
mov    -0x1b0(%rbp),%eax
mov    %eax,-0x1ac(%rbp)
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    119b <main+0x5b>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
mov    -0x1ac(%rbp),%edx
call   1040 <radixSort@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
call   1060 <printArray@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1a8,%rsp
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
mov    $0xffffffff,%edx
test   %esi,%esi
jle    11c6 <main+0x86>
lea    0x10(%rsp),%rbx
xor    %r15d,%r15d
lea    0xe81(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %edx,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    (%rbx),%edx
cmp    %edx,%ebp
cmovg  %ebp,%edx
add    $0x1,%r15
movslq 0xc(%rsp),%rsi
add    $0x4,%rbx
cmp    %rsi,%r15
jl     11a0 <main+0x60>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <radixSort@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1060 <printArray@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Enter Number of Elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [25 x i8] c"Enter %d Elements(>=0):\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %8)
store i32 0, i32* %4
br label %10
10: ; preds = %34, %0
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %37
14: ; preds = %10
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = load i32, i32* %5
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = icmp sgt i32 %19, %23
br i1 %24, label %25, label %27
25: ; preds = %14
%26 = load i32, i32* %5
br label %32
27: ; preds = %14
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %29
%31 = load i32, i32* %30
br label %32
32: ; preds = %27, %25
%33 = phi i32 [ %26, %25 ], [ %31, %27 ]
store i32 %33, i32* %5
br label %34
34: ; preds = %32
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %10
37: ; preds = %10
%38 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%39 = load i32, i32* %3
%40 = load i32, i32* %5
%41 = call i32 @radixSort(i32* %38, i32 %39, i32 %40)
%42 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%43 = load i32, i32* %3
%44 = call i32 @printArray(i32* %42, i32 %43)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Enter Number of Elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [25 x i8] c"Enter %d Elements(>=0):\0A\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = bitcast [100 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %0, %11
%12 = phi i64 [ %19, %11 ], [ 0, %0 ]
%13 = phi i32 [ %18, %11 ], [ -1, %0 ]
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %12
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = load i32, i32* %14
%17 = icmp sgt i32 %13, %16
%18 = select i1 %17, i32 %13, i32 %16
%19 = add nuw nsw i64 %12, 1
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %11, label %23
23: ; preds = %11, %0
%24 = phi i32 [ -1, %0 ], [ %18, %11 ]
%25 = phi i32 [ %9, %0 ], [ %20, %11 ]
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%27 = call i32 @radixSort(i32* %26, i32 %25, i32 %24)
%28 = load i32, i32* %2
%29 = call i32 @printArray(i32* %26, i32 %28)
ret i32 0
}