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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int selectKth(int *, int /*<<< orphan*/, int, int);
int main() {
  int a[] = {9, 5, 1, 3, 4, -2};
  int n = sizeof(a) / sizeof(int);
  int i;
  for (i = 0; i < 6; i++) {
    int ans = selectKth(a, 0, n - 1, i);
    printf("%d\n", ans);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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)
movl   $0x6,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x6,-0x28(%rbp)
jge    119c <main+0x7c>
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
sub    $0x1,%edx
mov    -0x28(%rbp),%ecx
xor    %esi,%esi
call   1040 <selectKth@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    115e <main+0x3e>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0xee2(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x5,%edx
xor    %ecx,%ecx
call   1040 <selectKth@plt>
lea    0xebf(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x5,%edx
mov    $0x1,%ecx
call   1040 <selectKth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x5,%edx
mov    $0x2,%ecx
call   1040 <selectKth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x5,%edx
mov    $0x3,%ecx
call   1040 <selectKth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x5,%edx
mov    $0x4,%ecx
call   1040 <selectKth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x5,%edx
mov    $0x5,%ecx
call   1040 <selectKth@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.a = [6 x i32] [i32 9, i32 5, i32 1, i32 3, i32 4, i32 -2]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [6 x i32]* %2 to i8*
store i32 6, i32* %3
store i32 0, i32* %4
br label %7
7: ; preds = %18, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 6
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 0
%12 = load i32, i32* %3
%13 = sub nsw i32 %12, 1
%14 = load i32, i32* %4
%15 = call i32 @selectKth(i32* %11, i32 0, i32 %13, i32 %14)
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %10
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %7
21: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [6 x i32] [i32 9, i32 5, i32 1, i32 3, i32 4, i32 -2]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [6 x i32]
%2 = bitcast [6 x i32]* %1 to i8*
%3 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%4 = call i32 @selectKth(i32* %3, i32 0, i32 5, i32 0)
%5 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @selectKth(i32* %3, i32 0, i32 5, i32 1)
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @selectKth(i32* %3, i32 0, i32 5, i32 2)
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 @selectKth(i32* %3, i32 0, i32 5, i32 3)
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @selectKth(i32* %3, i32 0, i32 5, i32 4)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = call i32 @selectKth(i32* %3, i32 0, i32 5, i32 5)
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
ret i32 0
}