#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*/ kthSmallest(int *, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int t, i, j, k;
  int a, b, c, arr[100];
  int n, m;
  scanf("%d", &t);
  for (i = 1; i <= t; i++) {
    scanf("%d", &n);
    for (j = 0; j < n; j++) {
      scanf("%d", &arr[j]);
    }
    scanf("%d", &k);
    printf("K'th smallest element is\n", kthSmallest(arr, 0, n - 1, k));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1200 <main+0xd0>
lea    0xe94(%rip),%rdi
lea    -0x1b4(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x1b4(%rbp),%eax
jge    11ba <main+0x8a>
movslq -0x10(%rbp),%rax
lea    -0x1b0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe59(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117f <main+0x4f>
lea    0xe3f(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
lea    -0x1b0(%rbp),%rdi
mov    -0x1b4(%rbp),%edx
sub    $0x1,%edx
mov    -0x14(%rbp),%ecx
xor    %esi,%esi
call   1030 <kthSmallest@plt>
mov    %eax,%esi
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1159 <main+0x29>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0xeb8(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11ff <main+0xcf>
mov    $0x1,%r14d
lea    0xe96(%rip),%rbx
lea    0x10(%rsp),%r15
lea    0xe8d(%rip),%r13
jmp    11ba <main+0x8a>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edx
add    $0xffffffff,%edx
mov    0xc(%rsp),%ecx
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <kthSmallest@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    0x1(%r14),%eax
cmp    0x8(%rsp),%r14d
mov    %eax,%r14d
jge    11ff <main+0xcf>
mov    %rbx,%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1180 <main+0x50>
mov    %r15,%rbp
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
add    $0x1,%r12
movslq 0x4(%rsp),%rax
add    $0x4,%rbp
cmp    %rax,%r12
jl     11e0 <main+0xb0>
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [26 x i8] c"K'th smallest element is\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [100 x i32]
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %13
13: ; preds = %39, %0
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %42
17: ; preds = %13
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %10)
store i32 0, i32* %4
br label %19
19: ; preds = %28, %17
%20 = load i32, i32* %4
%21 = load i32, i32* %10
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %31
23: ; preds = %19
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %9, i64 0, i64 %25
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %26)
br label %28
28: ; preds = %23
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %19
31: ; preds = %19
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%33 = getelementptr inbounds [100 x i32], [100 x i32]* %9, i64 0, i64 0
%34 = load i32, i32* %10
%35 = sub nsw i32 %34, 1
%36 = load i32, i32* %5
%37 = call i32 @kthSmallest(i32* %33, i32 0, i32 %35, i32 %36)
%38 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %31
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %13
42: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [26 x i8] c"K'th smallest element is\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i32]
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast [100 x i32]* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 1
br i1 %11, label %37, label %12
12: ; preds = %0
%13 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
br label %14
14: ; preds = %12, %27
%15 = phi i32 [ 1, %12 ], [ %34, %27 ]
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %14, %19
%20 = phi i64 [ %23, %19 ], [ 0, %14 ]
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %20
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
%23 = add nuw nsw i64 %20, 1
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %19, label %27
27: ; preds = %19, %14
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%29 = load i32, i32* %4
%30 = add nsw i32 %29, -1
%31 = load i32, i32* %2
%32 = call i32 @kthSmallest(i32* %13, i32 0, i32 %30, i32 %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = add nuw nsw i32 %15, 1
%35 = load i32, i32* %1
%36 = icmp slt i32 %15, %35
br i1 %36, label %14, label %37
37: ; preds = %27, %0
ret i32 0
}