#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ print(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ radixSort(int *, int);
int main(int argc, char *argv[]) {
  int i, digit, size;
  FILE *input = fopen(argv[1], "r");
  fscanf(input, "%d", &size);
  fscanf(input, "%d", &digit);
  int arr[size];
  for (i = 0; i < size; i++)
    fscanf(input, "%d", &arr[i]);
  printf("\nARRAY  : ");
  print(arr, size);
  radixSort(arr, size);
  printf("\nSORTED : ");
  print(arr, size);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe79(%rip),%rsi
mov    %rsi,-0x48(%rbp)
lea    -0x1c(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x48(%rbp),%rsi
mov    -0x28(%rbp),%rdi
lea    -0x18(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x1c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    120e <main+0xbe>
mov    -0x40(%rbp),%rdx
mov    -0x28(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe07(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d5 <main+0x85>
lea    0xdf0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <print@plt>
mov    -0x40(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <radixSort@plt>
lea    0xdd7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <print@plt>
lea    0xdca(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x8(%rsi),%rdi
lea    0xe84(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r12
lea    0xe77(%rip),%rbx
lea    -0x2c(%rbp),%rdx
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <fscanf@plt>
lea    -0x3c(%rbp),%rdx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <fscanf@plt>
mov    %rsp,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
cmpl   $0x0,-0x2c(%rbp)
jle    11ff <main+0x9f>
xor    %r13d,%r13d
lea    0xe2d(%rip),%r15
mov    %r14,%rbx
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <fscanf@plt>
add    $0x1,%r13
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r13
jl     11e0 <main+0x80>
lea    0xdff(%rip),%rdi
call   1040 <printf@plt>
mov    -0x2c(%rbp),%esi
mov    %r14,%rdi
call   1060 <print@plt>
mov    -0x2c(%rbp),%esi
mov    %r14,%rdi
call   1070 <radixSort@plt>
lea    0xde8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x2c(%rbp),%esi
mov    %r14,%rdi
call   1060 <print@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x38(%rbp),%rsp
xor    %eax,%eax
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"r\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"\0AARRAY : \00"
@.str.3 = [11 x i8] c"\0ASORTED : \00"
@.str.4 = [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*
%10 = alloca i8*
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %9
%16 = load i32*, i32** %9
%17 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%18 = load i32*, i32** %9
%19 = call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%20 = load i32, i32* %8
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %10
%23 = alloca i32, i64 %21
store i64 %21, i64* %11
store i32 0, i32* %6
br label %24
24: ; preds = %34, %2
%25 = load i32, i32* %6
%26 = load i32, i32* %8
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load i32*, i32** %9
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %23, i64 %31
%33 = call i32 @fscanf(i32* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %32)
br label %34
34: ; preds = %28
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %24
37: ; preds = %24
%38 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%39 = load i32, i32* %8
%40 = call i32 @print(i32* %23, i32 %39)
%41 = load i32, i32* %8
%42 = call i32 @radixSort(i32* %23, i32 %41)
%43 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%44 = load i32, i32* %8
%45 = call i32 @print(i32* %23, i32 %44)
%46 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
%47 = load i8*, i8** %10
%48 = load i32, i32* %3
ret i32 %48
}

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