#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*/ freopen(char *, char *, int /*<<< orphan*/);
int getLongestSubsequence(int *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int main() {
  int n, *arr, i, t;
  freopen("../../TestCase/input21.txt", "r", stdin);
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    arr = (int *)malloc(sizeof(int) * n);
    for (i = 0; i < n; i++) {
      scanf("%d", &arr[i]);
    }
    int lis = getLongestSubsequence(arr, n);
    printf("%d\n", lis);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edx
lea    0xe91(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1040 <freopen@plt>
lea    0xe9b(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
cmp    $0x0,%eax
je     1221 <main+0xd1>
lea    0xe77(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11fe <main+0xae>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe32(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c9 <main+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1070 <getLongestSubsequence@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe09(%rip),%rdi
call   1030 <printf@plt>
jmp    118b <main+0x3b>
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
mov    0x2e86(%rip),%rax
mov    (%rax),%edx
lea    0xe95(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1040 <freopen@plt>
lea    0xe9f(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
subl   $0x1,0x4(%rsp)
jae    11a0 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe76(%rip),%r13
mov    %rsp,%r14
lea    0xe6f(%rip),%r15
jmp    11d9 <main+0x89>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
call   1070 <getLongestSubsequence@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
subl   $0x1,0x4(%rsp)
jb     118f <main+0x3f>
mov    %r13,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    (%rsp),%esi
test   %esi,%esi
jle    11c0 <main+0x70>
mov    %r12,%rbx
xor    %ebp,%ebp
xchg   %ax,%ax
mov    %r13,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbp
movslq (%rsp),%rsi
add    $0x4,%rbx
cmp    %rsi,%rbp
jl     1200 <main+0xb0>
jmp    11c0 <main+0x70>

LLVM IR (-O0):
@.str = [27 x i8] c"../../TestCase/input21.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d\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 = load i32, i32* @stdin
%8 = call i32 @freopen(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
br label %10
10: ; preds = %35, %0
%11 = load i32, i32* %5
%12 = add nsw i32 %11, -1
store i32 %12, i32* %5
%13 = icmp ne i32 %11, 0
br i1 %13, label %14, label %41
14: ; preds = %10
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = mul i64 4, %17
%19 = trunc i64 %18 to i32
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to i32*
store i32* %21, i32** %3
store i32 0, i32* %4
br label %22
22: ; preds = %32, %14
%23 = load i32, i32* %4
%24 = load i32, i32* %2
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %35
26: ; preds = %22
%27 = load i32*, i32** %3
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %30)
br label %32
32: ; preds = %26
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %22
35: ; preds = %22
%36 = load i32*, i32** %3
%37 = load i32, i32* %2
%38 = call i32 @getLongestSubsequence(i32* %36, i32 %37)
store i32 %38, i32* %6
%39 = load i32, i32* %6
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %39)
br label %10
41: ; preds = %10
ret i32 0
}

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