#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*/ print_array(int *, int, char *);
int /*<<< orphan*/ selection_sort(int *, int);
int main() {
  int test1[7] = {4, 5, 1, 8, 9, 0, 1};
  int test2[7] = {1, 1, 1, 2, 2, 0, 1};
  int test3[7] = {4, 0, -1, -8, -9, 0, 1};
  print_array(test1, 7, "Before");
  selection_sort(test1, 7);
  print_array(test1, 7, "After");
  print_array(test2, 7, "Before");
  selection_sort(test2, 7);
  print_array(test2, 7, "After");
  print_array(test3, 7, "Before");
  selection_sort(test3, 7);
  print_array(test3, 7, "After");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec2(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb8(%rip),%eax
mov    %eax,-0x28(%rbp)
mov    0xeb6(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xeae(%rip),%eax
mov    %eax,-0x48(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x7,%esi
lea    0xe9f(%rip),%rdx
call   1040 <print_array@plt>
lea    -0x20(%rbp),%rdi
mov    $0x7,%esi
call   1030 <selection_sort@plt>
lea    -0x20(%rbp),%rdi
mov    $0x7,%esi
lea    0xe83(%rip),%rdx
call   1040 <print_array@plt>
lea    -0x40(%rbp),%rdi
mov    $0x7,%esi
lea    0xe67(%rip),%rdx
call   1040 <print_array@plt>
lea    -0x40(%rbp),%rdi
mov    $0x7,%esi
call   1030 <selection_sort@plt>
lea    -0x40(%rbp),%rdi
mov    $0x7,%esi
lea    0xe4b(%rip),%rdx
call   1040 <print_array@plt>
lea    -0x60(%rbp),%rdi
mov    $0x7,%esi
lea    0xe2f(%rip),%rdx
call   1040 <print_array@plt>
lea    -0x60(%rbp),%rdi
mov    $0x7,%esi
call   1030 <selection_sort@plt>
lea    -0x60(%rbp),%rdi
mov    $0x7,%esi
lea    0xe13(%rip),%rdx
call   1040 <print_array@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
movups 0xedc(%rip),%xmm0
movups %xmm0,0x4c(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movups 0xee4(%rip),%xmm0
movups %xmm0,0x2c(%rsp)
movaps 0xecc(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movups 0xeec(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xed4(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xee5(%rip),%r14
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x7,%esi
mov    %r14,%rdx
call   1040 <print_array@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1030 <selection_sort@plt>
lea    0xec3(%rip),%r15
mov    %rbx,%rdi
mov    $0x7,%esi
mov    %r15,%rdx
call   1040 <print_array@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x7,%esi
mov    %r14,%rdx
call   1040 <print_array@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1030 <selection_sort@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    %r15,%rdx
call   1040 <print_array@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x7,%esi
mov    %r14,%rdx
call   1040 <print_array@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1030 <selection_sort@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    %r15,%rdx
call   1040 <print_array@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.test1 = [7 x i32] [i32 4, i32 5, i32 1, i32 8, i32 9, i32 0, i32 1]
@__const.main.test2 = [7 x i32] [i32 1, i32 1, i32 1, i32 2, i32 2, i32 0, i32 1]
@__const.main.test3 = [7 x i32] [i32 4, i32 0, i32 -1, i32 -8, i32 -9, i32 0, i32 1]
@.str = [7 x i8] c"Before\00"
@.str.1 = [6 x i8] c"After\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [7 x i32]
%3 = alloca [7 x i32]
%4 = alloca [7 x i32]
store i32 0, i32* %1
%5 = bitcast [7 x i32]* %2 to i8*
%6 = bitcast [7 x i32]* %3 to i8*
%7 = bitcast [7 x i32]* %4 to i8*
%8 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 0
%9 = call i32 @print_array(i32* %8, i32 7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 0
%11 = call i32 @selection_sort(i32* %10, i32 7)
%12 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 0
%13 = call i32 @print_array(i32* %12, i32 7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 0
%15 = call i32 @print_array(i32* %14, i32 7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 0
%17 = call i32 @selection_sort(i32* %16, i32 7)
%18 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 0
%19 = call i32 @print_array(i32* %18, i32 7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%20 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 0
%21 = call i32 @print_array(i32* %20, i32 7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%22 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 0
%23 = call i32 @selection_sort(i32* %22, i32 7)
%24 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 0
%25 = call i32 @print_array(i32* %24, i32 7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.test1 = [7 x i32] [i32 4, i32 5, i32 1, i32 8, i32 9, i32 0, i32 1]
@__const.main.test2 = [7 x i32] [i32 1, i32 1, i32 1, i32 2, i32 2, i32 0, i32 1]
@__const.main.test3 = [7 x i32] [i32 4, i32 0, i32 -1, i32 -8, i32 -9, i32 0, i32 1]
@.str = [7 x i8] c"Before\00"
@.str.1 = [6 x i8] c"After\00"
define i32 @main() {
%1 = alloca [7 x i32]
%2 = alloca [7 x i32]
%3 = alloca [7 x i32]
%4 = bitcast [7 x i32]* %1 to i8*
%5 = bitcast [7 x i32]* %2 to i8*
%6 = bitcast [7 x i32]* %3 to i8*
%7 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%8 = call i32 @print_array(i32* %7, i32 7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @selection_sort(i32* %7, i32 7)
%10 = call i32 @print_array(i32* %7, i32 7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 0
%12 = call i32 @print_array(i32* %11, i32 7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @selection_sort(i32* %11, i32 7)
%14 = call i32 @print_array(i32* %11, i32 7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 0
%16 = call i32 @print_array(i32* %15, i32 7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @selection_sort(i32* %15, i32 7)
%18 = call i32 @print_array(i32* %15, i32 7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}