#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 computeLongestPalindromeSubseq(char *, int);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
scalar_t__ strlen(char *);
int main(void) {
  int T, len;
  char str[1001 + 1], trash[2 + 1];
  scanf("%d", &T);
  gets(trash);
  while (T) {
    gets(str);
    len = (int)strlen(str);
    printf("%d\n", computeLongestPalindromeSubseq(str, len));
    T--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
lea    -0x403(%rbp),%rdi
call   1060 <gets@plt>
cmpl   $0x0,-0x8(%rbp)
je     11ce <main+0x7e>
lea    -0x400(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x400(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <computeLongestPalindromeSubseq@plt>
mov    %eax,%esi
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    117e <main+0x2e>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
lea    0xe9f(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
lea    0xd(%rsp),%rdi
call   1060 <gets@plt>
cmpl   $0x0,0x8(%rsp)
je     11bb <main+0x6b>
lea    0x10(%rsp),%rbx
lea    0xe7b(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <computeLongestPalindromeSubseq@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
addl   $0xffffffff,0x8(%rsp)
jne    1190 <main+0x40>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

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

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