#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*/ heapSort(int *, int);
int /*<<< orphan*/ insertionSort(int *, int);
int /*<<< orphan*/ mergeSort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printArray(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quickSort(int *, int /*<<< orphan*/, int);
int main(void) {
  int A1[] = {5, 4, 3, 8, 10, 2};
  printArray(insertionSort(A1, 6), 6);
  printf("\n");
  int A2[] = {5, 4, 3, 8, 10, 2};
  printArray(mergeSort(A2, 0, 5), 6);
  printf("\n");
  int A3[] = {5, 4, 3, 8, 10, 2};
  printArray(heapSort(A3, 6), 6);
  printf("\n");
  int A4[] = {5, 4, 3, 8, 10, 2};
  printArray(quickSort(A4, 0, 5), 6);
  printf("\n");
  int A5[] = {5, 4, 3, 8, 10, 2};
  int B[6];
  printArray(countingSort(A5, B, 6, 11), 6);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    0xe7e(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe7b(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe78(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x6,%esi
call   1060 <insertionSort@plt>
mov    %eax,%edi
mov    $0x6,%esi
call   1090 <printArray@plt>
lea    0xedb(%rip),%rdi
call   1040 <printf@plt>
mov    0xe57(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe54(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe51(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1050 <mergeSort@plt>
mov    %eax,%edi
mov    $0x6,%esi
call   1090 <printArray@plt>
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
mov    0xe2e(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe2b(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xe28(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0x6,%esi
call   1030 <heapSort@plt>
mov    %eax,%edi
mov    $0x6,%esi
call   1090 <printArray@plt>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
mov    0xe07(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xe04(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xe01(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1070 <quickSort@plt>
mov    %eax,%edi
mov    $0x6,%esi
call   1090 <printArray@plt>
lea    0xe02(%rip),%rdi
call   1040 <printf@plt>
mov    0xdde(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0xdd8(%rip),%rax
mov    %rax,-0x98(%rbp)
mov    0xdd2(%rip),%rax
mov    %rax,-0x90(%rbp)
lea    -0xa0(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
mov    $0x6,%edx
mov    $0xb,%ecx
call   1080 <countingSort@plt>
mov    %eax,%edi
mov    $0x6,%esi
call   1090 <printArray@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xc0,%rsp
mov    0xe91(%rip),%rbx
mov    %rbx,0x90(%rsp)
movaps 0xe72(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
lea    0x80(%rsp),%rdi
mov    $0x6,%esi
call   1060 <insertionSort@plt>
mov    %eax,%edi
mov    $0x6,%esi
call   1090 <printArray@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,0x70(%rsp)
movaps 0xe36(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
lea    0x60(%rsp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1050 <mergeSort@plt>
mov    %eax,%edi
mov    $0x6,%esi
call   1090 <printArray@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,0x50(%rsp)
movaps 0xdfe(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
lea    0x40(%rsp),%rdi
mov    $0x6,%esi
call   1040 <heapSort@plt>
mov    %eax,%edi
mov    $0x6,%esi
call   1090 <printArray@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,0x30(%rsp)
movaps 0xdc8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0x20(%rsp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1070 <quickSort@plt>
mov    %eax,%edi
mov    $0x6,%esi
call   1090 <printArray@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,0x10(%rsp)
movaps 0xd90(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
lea    0xa0(%rsp),%rsi
mov    $0x6,%edx
mov    $0xb,%ecx
call   1080 <countingSort@plt>
mov    %eax,%edi
mov    $0x6,%esi
call   1090 <printArray@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.A1 = [6 x i32] [i32 5, i32 4, i32 3, i32 8, i32 10, i32 2]
@.str = [2 x i8] c"\0A\00"
@__const.main.A2 = [6 x i32] [i32 5, i32 4, i32 3, i32 8, i32 10, i32 2]
@__const.main.A3 = [6 x i32] [i32 5, i32 4, i32 3, i32 8, i32 10, i32 2]
@__const.main.A4 = [6 x i32] [i32 5, i32 4, i32 3, i32 8, i32 10, i32 2]
@__const.main.A5 = [6 x i32] [i32 5, i32 4, i32 3, i32 8, i32 10, i32 2]
define i32 @main() {
%1 = alloca [6 x i32]
%2 = alloca [6 x i32]
%3 = alloca [6 x i32]
%4 = alloca [6 x i32]
%5 = alloca [6 x i32]
%6 = alloca [6 x i32]
%7 = bitcast [6 x i32]* %1 to i8*
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%9 = call i32 @insertionSort(i32* %8, i32 6)
%10 = call i32 @printArray(i32 %9, i32 6)
%11 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = bitcast [6 x i32]* %2 to i8*
%13 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 0
%14 = call i32 @mergeSort(i32* %13, i32 0, i32 5)
%15 = call i32 @printArray(i32 %14, i32 6)
%16 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = bitcast [6 x i32]* %3 to i8*
%18 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%19 = call i32 @heapSort(i32* %18, i32 6)
%20 = call i32 @printArray(i32 %19, i32 6)
%21 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = bitcast [6 x i32]* %4 to i8*
%23 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%24 = call i32 @quickSort(i32* %23, i32 0, i32 5)
%25 = call i32 @printArray(i32 %24, i32 6)
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%27 = bitcast [6 x i32]* %5 to i8*
%28 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 0
%29 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 0
%30 = call i32 @countingSort(i32* %28, i32* %29, i32 6, i32 11)
%31 = call i32 @printArray(i32 %30, i32 6)
ret i32 0
}

LLVM IR (-O2):
@__const.main.A5 = [6 x i32] [i32 5, i32 4, i32 3, i32 8, i32 10, i32 2]
define i32 @main() {
%1 = alloca [6 x i32]
%2 = alloca [6 x i32]
%3 = alloca [6 x i32]
%4 = alloca [6 x i32]
%5 = alloca [6 x i32]
%6 = alloca [6 x i32]
%7 = bitcast [6 x i32]* %1 to i8*
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%9 = call i32 @insertionSort(i32* %8, i32 6)
%10 = call i32 @printArray(i32 %9, i32 6)
%11 = call i32 @putchar(i32 10)
%12 = bitcast [6 x i32]* %2 to i8*
%13 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 0
%14 = call i32 @mergeSort(i32* %13, i32 0, i32 5)
%15 = call i32 @printArray(i32 %14, i32 6)
%16 = call i32 @putchar(i32 10)
%17 = bitcast [6 x i32]* %3 to i8*
%18 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%19 = call i32 @heapSort(i32* %18, i32 6)
%20 = call i32 @printArray(i32 %19, i32 6)
%21 = call i32 @putchar(i32 10)
%22 = bitcast [6 x i32]* %4 to i8*
%23 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%24 = call i32 @quickSort(i32* %23, i32 0, i32 5)
%25 = call i32 @printArray(i32 %24, i32 6)
%26 = call i32 @putchar(i32 10)
%27 = bitcast [6 x i32]* %5 to i8*
%28 = bitcast [6 x i32]* %6 to i8*
%29 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 0
%30 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 0
%31 = call i32 @countingSort(i32* %29, i32* %30, i32 6, i32 11)
%32 = call i32 @printArray(i32 %31, i32 6)
ret i32 0
}