#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(int *, int, int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i;
  int test_scores[] = {5,  5, 5,  9,  1,  0,  100, 12, 8,
                       12, 8, 90, 23, 67, 25, 88,  101};
  int tslen = sizeof test_scores / sizeof test_scores[0];
  int k = 101;
  int B[tslen];
  CountingSort(test_scores, tslen, B, k);
  for (i = 0; i < tslen; ++i)
    printf("%d%s", B[i], (i < tslen - 1) ? ", " : "");
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xf0b(%rip),%eax
mov    %eax,-0x10(%rbp)
movaps 0xef1(%rip),%xmm0
movaps %xmm0,-0x20(%rbp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,-0x30(%rbp)
movaps 0xebb(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
movaps 0xea0(%rip),%xmm0
movaps %xmm0,-0x50(%rbp)
movl   $0x11,-0x54(%rbp)
movl   $0x65,-0x58(%rbp)
mov    -0x54(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x60(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x70(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x68(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%ecx
call   1040 <CountingSort@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    11ff <main+0xdf>
mov    -0x70(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x8(%rbp),%ecx
mov    -0x54(%rbp),%edi
sub    $0x1,%edi
lea    0xe77(%rip),%rdx
lea    0xe6c(%rip),%rax
cmp    %edi,%ecx
cmovl  %rax,%rdx
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11af <main+0x8f>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xa0,%rsp
mov    %rsp,%r15
mov    0xefb(%rip),%eax
mov    %eax,0x90(%rsp)
movaps 0xedd(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xea2(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe86(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
lea    0x50(%rsp),%rdi
mov    %rsp,%rdx
mov    $0x11,%esi
mov    $0x65,%ecx
call   1050 <CountingSort@plt>
mov    (%rsp),%esi
lea    0xea4(%rip),%rbx
lea    0xea2(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x30(%rsp),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x34(%rsp),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x38(%rsp),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x3c(%rsp),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x40(%rsp),%esi
lea    0xd8d(%rip),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rsp
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.test_scores = [17 x i32] [i32 5, i32 5, i32 5, i32 9, i32 1, i32 0, i32 100, i32 12, i32 8, i32 12, i32 8, i32 90, i32 23, i32 67, i32 25, i32 88, i32 101]
@.str = [5 x i8] c"%d%s\00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [17 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %1
%8 = bitcast [17 x i32]* %3 to i8*
store i32 17, i32* %4
store i32 101, i32* %5
%9 = load i32, i32* %4
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %6
%12 = alloca i32, i64 %10
store i64 %10, i64* %7
%13 = getelementptr inbounds [17 x i32], [17 x i32]* %3, i64 0, i64 0
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = call i32 @CountingSort(i32* %13, i32 %14, i32* %12, i32 %15)
store i32 0, i32* %2
br label %17
17: ; preds = %33, %0
%18 = load i32, i32* %2
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %36
21: ; preds = %17
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %12, i64 %23
%25 = load i32, i32* %24
%26 = load i32, i32* %2
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 1
%29 = icmp slt i32 %26, %28
%30 = zext i1 %29 to i64
%31 = select i1 %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %25, i8* %31)
br label %33
33: ; preds = %21
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 1
store i32 %35, i32* %2
br label %17
36: ; preds = %17
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
%38 = load i8*, i8** %6
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@__const.main.test_scores = [17 x i32] [i32 5, i32 5, i32 5, i32 9, i32 1, i32 0, i32 100, i32 12, i32 8, i32 12, i32 8, i32 90, i32 23, i32 67, i32 25, i32 88, i32 101]
@.str = [5 x i8] c"%d%s\00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @main() {
%1 = alloca [17 x i32]
%2 = bitcast [17 x i32]* %1 to i8*
%3 = tail call i8* @llvm.stacksave()
%4 = alloca [17 x i32]
%5 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 0
%6 = getelementptr inbounds [17 x i32], [17 x i32]* %1, i64 0, i64 0
%7 = call i32 @CountingSort(i32* %6, i32 17, i32* %5, i32 101)
%8 = load i32, i32* %5
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 1
%11 = load i32, i32* %10
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 2
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 3
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 4
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%22 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 5
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%25 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 6
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%28 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 7
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%31 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 8
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%34 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 9
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%37 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 10
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%40 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 11
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%43 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 12
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%46 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 13
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%49 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 14
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%52 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 15
%53 = load i32, i32* %52
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %53, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%55 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 16
%56 = load i32, i32* %55
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %56, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%58 = call i32 @putchar(i32 10)
ret i32 0
}