#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ msort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int t;
  scanf("%d", &t);
  int a;
  for (a = 1; a <= t; a++) {
    int n;
    scanf("%d", &n);
    int *a = (int *)calloc(n, 4);
    int i;
    for (i = 0; i < n; i++)
      scanf("%d", a + i);
    printf("%lld\n", msort(a, 0, n - 1));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11fc <main+0xbc>
lea    0xe87(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11cf <main+0x8f>
mov    -0x18(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe44(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119a <main+0x5a>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1030 <msort@plt>
mov    %eax,%esi
lea    0xe1a(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1166 <main+0x26>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11ee <main+0xae>
mov    $0x1,%ebp
lea    0xe8d(%rip),%r13
lea    0xe89(%rip),%r15
jmp    11a2 <main+0x62>
nopl   0x0(%rax)
add    $0xffffffff,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1030 <msort@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    0x1(%rbp),%eax
cmp    0x4(%rsp),%ebp
mov    %eax,%ebp
jge    11ee <main+0xae>
mov    %r13,%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,%r12
mov    (%rsp),%edx
test   %edx,%edx
jle    1180 <main+0x40>
mov    %r12,%rbx
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x1,%r14
movslq (%rsp),%rdx
add    $0x4,%rbx
cmp    %rdx,%r14
jl     11d0 <main+0x90>
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0x8,%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 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32 0, i32* %1
%7 = 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 %8
8: ; preds = %36, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %39
12: ; preds = %8
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%14 = load i32, i32* %4
%15 = call i64 @calloc(i32 %14, i32 4)
%16 = inttoptr i64 %15 to i32*
store i32* %16, i32** %5
store i32 0, i32* %6
br label %17
17: ; preds = %27, %12
%18 = load i32, i32* %6
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load i32*, i32** %5
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %25)
br label %27
27: ; preds = %21
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %17
30: ; preds = %17
%31 = load i32*, i32** %5
%32 = load i32, i32* %4
%33 = sub nsw i32 %32, 1
%34 = call i32 @msort(i32* %31, i32 0, i32 %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %30
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %8
39: ; preds = %8
ret i32 0
}

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