#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*/ init(int **);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int similarity(char *, int, char *, int, int **);
int main() {
  int n;
  char a[200];
  char b[200];
  int a_len;
  int b_len;
  int score[256][256] = {0};
  init(score);
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a_len);
    scanf("%s", a);
    scanf("%d", &b_len);
    scanf("%s", b);
    printf("%d\n", similarity(a, a_len, b, b_len, score));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x401c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x401b0(%rbp),%rdi
xor    %esi,%esi
mov    $0x40000,%edx
call   1040 <memset@plt>
lea    -0x401b0(%rbp),%rdi
call   1050 <init@plt>
lea    0xe78(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x0,-0x401b4(%rbp)
mov    -0x401b4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1248 <main+0xf8>
lea    0xe4d(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0xd0(%rbp),%rsi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xe23(%rip),%rdi
lea    -0x1a8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x1a0(%rbp),%rsi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0xd0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
lea    -0x1a0(%rbp),%rdx
mov    -0x1a8(%rbp),%ecx
lea    -0x401b0(%rbp),%r8
call   1070 <similarity@plt>
mov    %eax,%esi
lea    0xdd7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x401b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x401b4(%rbp)
jmp    119d <main+0x4d>
xor    %eax,%eax
add    $0x401c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x401b8,%rsp
lea    0x1b0(%rsp),%rbx
mov    $0x40000,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %rbx,%rdi
call   1050 <init@plt>
lea    0xe79(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1238 <main+0xe8>
lea    0xe5b(%rip),%r15
lea    0xe57(%rip),%r12
lea    0xe0(%rsp),%rbx
lea    0x10(%rsp),%rbp
lea    0xe46(%rip),%r13
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r15,%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%ecx
mov    %rbx,%rdi
mov    %rbp,%rdx
lea    0x1b0(%rsp),%r8
call   1070 <similarity@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0x1,%r14d
cmp    0x4(%rsp),%r14d
jl     11d0 <main+0x80>
xor    %eax,%eax
add    $0x401b8,%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 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [200 x i8]
%4 = alloca [200 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca [256 x [256 x i32]]
%8 = alloca i32
store i32 0, i32* %1
%9 = bitcast [256 x [256 x i32]]* %7 to i8*
%10 = getelementptr inbounds [256 x [256 x i32]], [256 x [256 x i32]]* %7, i64 0, i64 0
%11 = bitcast [256 x i32]* %10 to i32**
%12 = call i32 @init(i32** %11)
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %8
br label %14
14: ; preds = %33, %0
%15 = load i32, i32* %8
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %36
18: ; preds = %14
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%20 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%23 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%26 = load i32, i32* %5
%27 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%28 = load i32, i32* %6
%29 = getelementptr inbounds [256 x [256 x i32]], [256 x [256 x i32]]* %7, i64 0, i64 0
%30 = bitcast [256 x i32]* %29 to i32**
%31 = call i32 @similarity(i8* %25, i32 %26, i8* %27, i32 %28, i32** %30)
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %18
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %14
36: ; preds = %14
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 = alloca [200 x i8]
%3 = alloca [200 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca [256 x [256 x i32]]
%7 = bitcast i32* %1 to i8*
%8 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast [256 x [256 x i32]]* %6 to i8*
%13 = bitcast [256 x [256 x i32]]* %6 to i32**
%14 = call i32 @init(i32** %13)
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = icmp sgt i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %19, %0
ret i32 0
19: ; preds = %0, %19
%20 = phi i32 [ %29, %19 ], [ 0, %0 ]
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = call i32 @similarity(i8* %8, i32 %25, i8* %9, i32 %26, i32** %13)
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = add nuw nsw i32 %20, 1
%30 = load i32, i32* %1
%31 = icmp slt i32 %29, %30
br i1 %31, label %19, label %18
}