#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*/ selectionSort(int *, int);
void test_selectionSort(void) {
  printf("TEST: selectionSort\n");
  int test[] = {34, 8, 64, 51, 32, 21};
  printf("Befor selectionSort: ");
  printArray(test, 6);
  selectionSort(test, 6);
  printf("After selectionSort: ");
  printArray(test, 6);
  int test2[] = {34};
  printf("Befor selectionSort: ");
  printArray(test2, 1);
  selectionSort(test2, 1);
  printf("After selectionSort: ");
  printArray(test2, 1);
}


x86 assembly (clang, -O0):
<test_selectionSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    0xf05(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xf02(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeff(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x6,%esi
call   1050 <printArray@plt>
lea    -0x20(%rbp),%rdi
mov    $0x6,%esi
call   1040 <selectionSort@plt>
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x6,%esi
call   1050 <printArray@plt>
mov    0xebb(%rip),%eax
mov    %eax,-0x24(%rbp)
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
lea    -0x24(%rbp),%rdi
mov    $0x1,%esi
call   1050 <printArray@plt>
lea    -0x24(%rbp),%rdi
mov    $0x1,%esi
call   1040 <selectionSort@plt>
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
lea    -0x24(%rbp),%rdi
mov    $0x1,%esi
call   1050 <printArray@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_selectionSort>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
mov    0xeb4(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xe98(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xea4(%rip),%r14
mov    %r14,%rdi
call   1040 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x6,%esi
call   1060 <printArray@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1050 <selectionSort@plt>
lea    0xe8c(%rip),%r15
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1060 <printArray@plt>
movl   $0x22,0xc(%rsp)
mov    %r14,%rdi
call   1040 <printf@plt>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1060 <printArray@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1050 <selectionSort@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1060 <printArray@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"TEST: selectionSort\0A\00"
@__const.test_selectionSort.test = [6 x i32] [i32 34, i32 8, i32 64, i32 51, i32 32, i32 21]
@.str.1 = [22 x i8] c"Befor selectionSort: \00"
@.str.2 = [22 x i8] c"After selectionSort: \00"
@__const.test_selectionSort.test2 = [1 x i32] [i32 34]
define void @test_selectionSort() {
%1 = alloca [6 x i32]
%2 = alloca [1 x i32]
%3 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = bitcast [6 x i32]* %1 to i8*
%5 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%7 = call i32 @printArray(i32* %6, i32 6)
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%9 = call i32 @selectionSort(i32* %8, i32 6)
%10 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%12 = call i32 @printArray(i32* %11, i32 6)
%13 = bitcast [1 x i32]* %2 to i8*
%14 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%15 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
%16 = call i32 @printArray(i32* %15, i32 1)
%17 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
%18 = call i32 @selectionSort(i32* %17, i32 1)
%19 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%20 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
%21 = call i32 @printArray(i32* %20, i32 1)
ret void
}

LLVM IR (-O2):
@__const.test_selectionSort.test = [6 x i32] [i32 34, i32 8, i32 64, i32 51, i32 32, i32 21]
@.str.1 = [22 x i8] c"Befor selectionSort: \00"
@.str.2 = [22 x i8] c"After selectionSort: \00"
@str = [20 x i8] c"TEST: selectionSort\00"
define void @test_selectionSort() {
%1 = alloca [6 x i32]
%2 = alloca [1 x i32]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%4 = bitcast [6 x i32]* %1 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%7 = call i32 @printArray(i32* %6, i32 6)
%8 = call i32 @selectionSort(i32* %6, i32 6)
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printArray(i32* %6, i32 6)
%11 = bitcast [1 x i32]* %2 to i8*
%12 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
store i32 34, i32* %12
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @printArray(i32* %12, i32 1)
%15 = call i32 @selectionSort(i32* %12, i32 1)
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @printArray(i32* %12, i32 1)
ret void
}