int main() {
  char *s;
  int *index;
  int T, i;
  scanf("%d", &T);
  index = (int *)malloc(T * sizeof(*index));
  for (i = 0; i < T; i++) {
    s = (char *)malloc((10 * 10 * 10 * 10 * 10 + 6) * sizeof(*s));
    scanf("%s", s);
    index[i] = make_string_palindrom(s, 0, strlen(s) - 1);
    free(s);
  }
  for (i = 0; i < T; i++)
    printf("%d\n", index[i]);
  free(index);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
movslq -0x1c(%rbp),%rdi
shl    $0x2,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    120e <main+0xae>
mov    $0x186a6,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rdx
sub    $0x1,%rdx
xor    %esi,%esi
mov    $0x0,%al
call   1040 <make_string_palindrom@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1199 <main+0x39>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1248 <main+0xe8>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1215 <main+0xb5>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe91(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
movslq 0x4(%rsp),%rbx
lea    0x0(,%rbx,4),%rdi
call   1070 <malloc@plt>
mov    %rax,%r15
test   %rbx,%rbx
jle    122c <main+0xcc>
lea    0xe63(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x186a6,%edi
call   1070 <malloc@plt>
mov    %rax,%r12
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
lea    -0x1(%rax),%rdx
mov    %r12,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <make_string_palindrom@plt>
mov    %eax,(%r15,%rbx,4)
mov    %r12,%rdi
call   1030 <free@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     11b0 <main+0x50>
test   %eax,%eax
jle    122c <main+0xcc>
lea    0xdff(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     1210 <main+0xb0>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = mul i64 %8, 4
%10 = call i8* @malloc(i64 %9)
%11 = bitcast i8* %10 to i32*
store i32* %11, i32** %3
store i32 0, i32* %5
br label %12
12: ; preds = %30, %0
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %33
16: ; preds = %12
%17 = call i8* @malloc(i64 100006)
store i8* %17, i8** %2
%18 = load i8*, i8** %2
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %2
%21 = load i8*, i8** %2
%22 = call i64 @strlen(i8* %21)
%23 = sub i64 %22, 1
%24 = call i32 (i8*, i32, i64, ...) bitcast (i32 (...)* @make_string_palindrom to i32 (i8*, i32, i64, ...)*)(i8* %20, i32 0, i64 %23)
%25 = load i32*, i32** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
store i32 %24, i32* %28
%29 = load i8*, i8** %2
br label %30
30: ; preds = %16
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %12
33: ; preds = %12
store i32 0, i32* %5
br label %34
34: ; preds = %45, %33
%35 = load i32, i32* %5
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %48
38: ; preds = %34
%39 = load i32*, i32** %3
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %38
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %34
48: ; preds = %34
%49 = load i32*, i32** %3
%50 = bitcast i32* %49 to i8*
ret i32 0
}

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