#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 dynamic_lcs(char *, char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int test_count;
  int i, len1, len2, lcs_count, max_str_len;
  char str1[100];
  char str2[100];
  char ch;
  scanf("%d\n", &test_count);
  for (i = 1; i <= test_count; i++) {
    len1 = len2 = 0;
    do {
      scanf("%c", &str1[len1]);
      len1++;
    } while (str1[len1 - 1] != '\n');
    do {
      scanf("%c", &str2[len2]);
      len2++;
    } while (str2[len2 - 1] != '\n');
    lcs_count = dynamic_lcs(str1, str2, len1 - 1, len2 - 1);
    printf("%d# Length of Dynamic longest common subsequence is: %d\n", i,
           lcs_count);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeef(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1231 <main+0x101>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
movslq -0x10(%rbp),%rax
lea    -0x80(%rbp),%rsi
add    %rax,%rsi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    1175 <main+0x45>
jmp    11b2 <main+0x82>
movslq -0x14(%rbp),%rax
lea    -0xf0(%rbp),%rsi
add    %rax,%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0xf0(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    11b2 <main+0x82>
lea    -0x80(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
mov    -0x10(%rbp),%edx
sub    $0x1,%edx
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
call   1050 <dynamic_lcs@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115b <main+0x2b>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
lea    0xee0(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1224 <main+0xe4>
mov    $0x1,%r15d
lea    0x80(%rsp),%rbx
lea    0xe7c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xffffffff,%ebp
mov    %rbx,%r12
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%ebp
cmpb   $0xa,(%rbx)
lea    0x1(%rbx),%rbx
jne    11a0 <main+0x60>
mov    $0xffffffff,%r13d
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%r13d
cmpb   $0xa,(%rbx)
lea    0x1(%rbx),%rbx
jne    11d0 <main+0x90>
mov    %r12,%rbx
mov    %r12,%rdi
lea    0x10(%rsp),%rsi
mov    %ebp,%edx
mov    %r13d,%ecx
call   1060 <dynamic_lcs@plt>
lea    0xdfd(%rip),%rdi
mov    %r15d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1(%r15),%eax
cmp    0xc(%rsp),%r15d
mov    %eax,%r15d
jl     1190 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [57 x i8] c"%d# Length of Dynamic longest common subsequence is: %d\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [100 x i8]
%9 = alloca [100 x i8]
%10 = alloca i8
store i32 0, i32* %1
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %12
12: ; preds = %59, %0
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %62
16: ; preds = %12
store i32 0, i32* %5
store i32 0, i32* %4
br label %17
17: ; preds = %24, %16
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %19
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %24
24: ; preds = %17
%25 = load i32, i32* %4
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 10
br i1 %31, label %17, label %32
32: ; preds = %24
br label %33
33: ; preds = %40, %32
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 %35
%37 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %36)
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %40
40: ; preds = %33
%41 = load i32, i32* %5
%42 = sub nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 10
br i1 %47, label %33, label %48
48: ; preds = %40
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%51 = load i32, i32* %4
%52 = sub nsw i32 %51, 1
%53 = load i32, i32* %5
%54 = sub nsw i32 %53, 1
%55 = call i32 @dynamic_lcs(i8* %49, i8* %50, i32 %52, i32 %54)
store i32 %55, i32* %6
%56 = load i32, i32* %3
%57 = load i32, i32* %6
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i32 %56, i32 %57)
br label %59
59: ; preds = %48
%60 = load i32, i32* %3
%61 = add nsw i32 %60, 1
store i32 %61, i32* %3
br label %12
62: ; preds = %12
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [57 x i8] c"%d# Length of Dynamic longest common subsequence is: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 1
br i1 %9, label %34, label %10
10: ; preds = %0, %26
%11 = phi i32 [ %31, %26 ], [ 1, %0 ]
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %16, %12 ]
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %13
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = add nuw i64 %13, 1
%17 = load i8, i8* %14
%18 = icmp eq i8 %17, 10
br i1 %18, label %19, label %12
19: ; preds = %12, %19
%20 = phi i64 [ %23, %19 ], [ 0, %12 ]
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %20
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = add nuw i64 %20, 1
%24 = load i8, i8* %21
%25 = icmp eq i8 %24, 10
br i1 %25, label %26, label %19
26: ; preds = %19
%27 = trunc i64 %13 to i32
%28 = trunc i64 %20 to i32
%29 = call i32 @dynamic_lcs(i8* %5, i8* %6, i32 %27, i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %29)
%31 = add nuw nsw i32 %11, 1
%32 = load i32, i32* %1
%33 = icmp slt i32 %11, %32
br i1 %33, label %10, label %34
34: ; preds = %26, %0
%35 = call i32 @putchar(i32 10)
ret i32 0
}