#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*/ array;

/* Variables and functions */
int /*<<< orphan*/ print_array(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ select_sort_nondec(int *, int);
int /*<<< orphan*/ select_sort_noninc(int *, int);
int main() {
  int array[] = {4, 5,  2,  9, 12,   78,   123, 43, 567, 234,
                 1, 23, 36, 2, 1345, 6322, 29,  0,  46,  23};
  int n = sizeof(array) / sizeof(array[0]);
  printf("Before Sorting\n");
  print_array(array, n);
  select_sort_nondec(array, n);
  printf("After Sorting (non-dec sort) \n");
  print_array(array, n);
  select_sort_noninc(array, n);
  printf("After Sorting (non-inc sort) \n");
  print_array(array, n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe96(%rip),%rsi
mov    $0x50,%edx
call   1070 <memcpy@plt>
movl   $0x14,-0x64(%rbp)
lea    0xece(%rip),%rdi
call   1060 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   1040 <print_array@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   1030 <select_sort_nondec@plt>
lea    0xeba(%rip),%rdi
call   1060 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   1040 <print_array@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   1050 <select_sort_noninc@plt>
lea    0xeb5(%rip),%rdi
call   1060 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   1040 <print_array@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
movaps 0xef4(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xebc(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe84(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xec9(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1050 <print_array@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1030 <select_sort_nondec@plt>
lea    0xeaf(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1050 <print_array@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1060 <select_sort_noninc@plt>
lea    0xea7(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1050 <print_array@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.array = [20 x i32] [i32 4, i32 5, i32 2, i32 9, i32 12, i32 78, i32 123, i32 43, i32 567, i32 234, i32 1, i32 23, i32 36, i32 2, i32 1345, i32 6322, i32 29, i32 0, i32 46, i32 23]
@.str = [16 x i8] c"Before Sorting\0A\00"
@.str.1 = [31 x i8] c"After Sorting (non-dec sort) \0A\00"
@.str.2 = [31 x i8] c"After Sorting (non-inc sort) \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [20 x i32]* %2 to i8*
store i32 20, i32* %3
%5 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%7 = load i32, i32* %3
%8 = call i32 @print_array(i32* %6, i32 %7)
%9 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%10 = load i32, i32* %3
%11 = call i32 @select_sort_nondec(i32* %9, i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%14 = load i32, i32* %3
%15 = call i32 @print_array(i32* %13, i32 %14)
%16 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%17 = load i32, i32* %3
%18 = call i32 @select_sort_noninc(i32* %16, i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%20 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%21 = load i32, i32* %3
%22 = call i32 @print_array(i32* %20, i32 %21)
ret i32 0
}

LLVM IR (-O2):
@__const.main.array = [20 x i32] [i32 4, i32 5, i32 2, i32 9, i32 12, i32 78, i32 123, i32 43, i32 567, i32 234, i32 1, i32 23, i32 36, i32 2, i32 1345, i32 6322, i32 29, i32 0, i32 46, i32 23]
@str = [15 x i8] c"Before Sorting\00"
@str.3 = [30 x i8] c"After Sorting (non-dec sort) \00"
@str.4 = [30 x i8] c"After Sorting (non-inc sort) \00"
define i32 @main() {
%1 = alloca [20 x i32]
%2 = bitcast [20 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%5 = call i32 @print_array(i32* %4, i32 20)
%6 = call i32 @select_sort_nondec(i32* %4, i32 20)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.3, i64 0, i64 0))
%8 = call i32 @print_array(i32* %4, i32 20)
%9 = call i32 @select_sort_noninc(i32* %4, i32 20)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.4, i64 0, i64 0))
%11 = call i32 @print_array(i32* %4, i32 20)
ret i32 0
}