#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*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ findLCS(char *, char *, int, int, int);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
size_t strcspn(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  int rc;
  int BUFFSIZE = 100000;
  char *buffer = malloc(BUFFSIZE * sizeof(char));
  char *cdbs1 = malloc(BUFFSIZE * sizeof(char));
  char *cdbs2 = malloc(BUFFSIZE * sizeof(char));
  char *substring = malloc(BUFFSIZE * sizeof(char));
  int sub_len;
  int cdbs1_len;
  int cdbs2_len;
  int i;
  int first = 1;
  int k;
  char begin_tdp[20];
  char end_tdp[20];
  strcpy(begin_tdp, "BEGIN TDP CODEBASE");
  strcpy(end_tdp, "END TDP CODEBASE");
  char begin_jcn[20];
  char end_jcn[20];
  strcpy(begin_jcn, "BEGIN JCN CODEBASE");
  strcpy(end_jcn, "END JCN CODEBASE");
  char newline[2] = "\n";
  while (1) {
    if (fgets(buffer, BUFFSIZE, stdin) == NULL) {
      return (0);
    }
    sscanf(buffer, "%d", &k);
    if (k == 0) {
      return 0;
    }
    if (fgets(buffer, BUFFSIZE, stdin) == NULL) {
      printf("error!\n");
      return 1;
    }
    buffer[strcspn(buffer, "\n\r")] = '\0';
    if (strcmp(buffer, begin_tdp) == 0) {
      if (fgets(buffer, BUFFSIZE, stdin) == NULL) {
        printf("error!\n");
        return 1;
      }
      buffer[strcspn(buffer, "\n\r")] = '\0';
      int first = 1;
      while (strcmp(buffer, end_tdp) != 0) {
        strcat(buffer, newline);
        if (first == 1) {
          strcpy(cdbs1, buffer);
          first = 0;
        } else {
          strcat(cdbs1, buffer);
        }
        if (fgets(buffer, BUFFSIZE, stdin) == NULL) {
          printf("error!\n");
          return 1;
        }
        buffer[strcspn(buffer, "\n\r")] = '\0';
      }
    }
    if (fgets(buffer, BUFFSIZE, stdin) == NULL) {
      printf("error!\n");
      return 1;
    }
    buffer[strcspn(buffer, "\n\r")] = '\0';
    if (strcmp(buffer, begin_jcn) == 0) {
      if (fgets(buffer, BUFFSIZE, stdin) == NULL) {
        printf("error reading 'begin jcn'\n");
        return 1;
      }
      buffer[strcspn(buffer, "\n\r")] = '\0';
      int first = 1;
      while (strcmp(buffer, end_jcn) != 0) {
        strcat(buffer, newline);
        if (first == 1) {
          strcpy(cdbs2, buffer);
          first = 0;
        } else {
          strcat(cdbs2, buffer);
        }
        if (fgets(buffer, BUFFSIZE, stdin) == NULL) {
          printf("error reading next line of input!\n");
          return 1;
        }
        buffer[strcspn(buffer, "\n\r")] = '\0';
      }
    }
    cdbs1_len = strlen(cdbs1);
    cdbs2_len = strlen(cdbs2);
    if (first == 0) {
      printf("\n");
    }
    first = 0;
    findLCS(cdbs1, cdbs2, cdbs1_len, cdbs2_len, k);
  }
  free(buffer);
  free(cdbs1);
  free(cdbs2);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x186a0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x20(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x1,-0x4c(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xde2(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x90(%rbp),%rdi
lea    0xde2(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0xb0(%rbp),%rdi
lea    0xde0(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0xd0(%rbp),%rdi
lea    0xde0(%rip),%rsi
call   1030 <strcpy@plt>
mov    0xdee(%rip),%ax
mov    %ax,-0xd2(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2d70(%rip),%rax
mov    (%rax),%edx
call   1080 <fgets@plt>
cmp    $0x0,%rax
jne    1295 <main+0xf5>
movl   $0x0,-0x4(%rbp)
jmp    1669 <main+0x4c9>
mov    -0x20(%rbp),%rdi
lea    0xda8(%rip),%rsi
lea    -0x50(%rbp),%rdx
call   10b0 <sscanf@plt>
cmpl   $0x0,-0x50(%rbp)
jne    12bf <main+0x11f>
movl   $0x0,-0x4(%rbp)
jmp    1669 <main+0x4c9>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2d1b(%rip),%rax
mov    (%rax),%edx
call   1080 <fgets@plt>
cmp    $0x0,%rax
jne    12f6 <main+0x156>
lea    0xd66(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1669 <main+0x4c9>
mov    -0x20(%rbp),%rax
mov    %rax,-0xe8(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xd47(%rip),%rsi
call   1070 <strcspn@plt>
mov    %rax,%rcx
mov    -0xe8(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    146a <main+0x2ca>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2ca4(%rip),%rax
mov    (%rax),%edx
call   1080 <fgets@plt>
cmp    $0x0,%rax
jne    136d <main+0x1cd>
lea    0xcef(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1669 <main+0x4c9>
mov    -0x20(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xcd0(%rip),%rsi
call   1070 <strcspn@plt>
mov    %rax,%rcx
mov    -0xf0(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0xd8(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     1465 <main+0x2c5>
mov    -0x20(%rbp),%rdi
lea    -0xd2(%rbp),%rsi
call   10c0 <strcat@plt>
cmpl   $0x1,-0xd8(%rbp)
jne    13f3 <main+0x253>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0xd8(%rbp)
jmp    1400 <main+0x260>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10c0 <strcat@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2bda(%rip),%rax
mov    (%rax),%edx
call   1080 <fgets@plt>
cmp    $0x0,%rax
jne    1437 <main+0x297>
lea    0xc25(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1669 <main+0x4c9>
mov    -0x20(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xc06(%rip),%rsi
call   1070 <strcspn@plt>
mov    %rax,%rcx
mov    -0xf8(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
jmp    13a0 <main+0x200>
jmp    146a <main+0x2ca>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2b70(%rip),%rax
mov    (%rax),%edx
call   1080 <fgets@plt>
cmp    $0x0,%rax
jne    14a1 <main+0x301>
lea    0xbbb(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1669 <main+0x4c9>
mov    -0x20(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xb9c(%rip),%rsi
call   1070 <strcspn@plt>
mov    %rax,%rcx
mov    -0x100(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1618 <main+0x478>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2af6(%rip),%rax
mov    (%rax),%edx
call   1080 <fgets@plt>
cmp    $0x0,%rax
jne    151b <main+0x37b>
lea    0xb4c(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1669 <main+0x4c9>
mov    -0x20(%rbp),%rax
mov    %rax,-0x108(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xb22(%rip),%rsi
call   1070 <strcspn@plt>
mov    %rax,%rcx
mov    -0x108(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0xdc(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     1613 <main+0x473>
mov    -0x20(%rbp),%rdi
lea    -0xd2(%rbp),%rsi
call   10c0 <strcat@plt>
cmpl   $0x1,-0xdc(%rbp)
jne    15a1 <main+0x401>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0xdc(%rbp)
jmp    15ae <main+0x40e>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10c0 <strcat@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2a2c(%rip),%rax
mov    (%rax),%edx
call   1080 <fgets@plt>
cmp    $0x0,%rax
jne    15e5 <main+0x445>
lea    0xa9d(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1669 <main+0x4c9>
mov    -0x20(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xa58(%rip),%rsi
call   1070 <strcspn@plt>
mov    %rax,%rcx
mov    -0x110(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
jmp    154e <main+0x3ae>
jmp    1618 <main+0x478>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jne    1646 <main+0x4a6>
lea    0xa10(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x40(%rbp),%edx
mov    -0x44(%rbp),%ecx
mov    -0x50(%rbp),%r8d
call   1040 <findLCS@plt>
jmp    126a <main+0xca>
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    $0x186a0,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
mov    $0x186a0,%edi
call   10b0 <malloc@plt>
mov    %rax,%r14
mov    $0x186a0,%edi
call   10b0 <malloc@plt>
mov    %rax,%r15
lea    0xe11(%rip),%rsi
lea    0x80(%rsp),%rdi
call   1040 <strcpy@plt>
lea    0xe10(%rip),%rsi
lea    0x60(%rsp),%rdi
call   1040 <strcpy@plt>
lea    0xe10(%rip),%rsi
lea    0x40(%rsp),%rdi
call   1040 <strcpy@plt>
lea    0xe12(%rip),%rsi
lea    0x20(%rsp),%rdi
call   1040 <strcpy@plt>
movw   $0xa,0x2(%rsp)
mov    0x2dab(%rip),%r12
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x186a0,%esi
call   1090 <fgets@plt>
test   %rax,%rax
je     152c <main+0x37c>
mov    %r14,0x18(%rsp)
mov    %r15,0x8(%rsp)
lea    0xde3(%rip),%r15
lea    0x60(%rsp),%r14
lea    0x2(%rsp),%r13
xor    %ebp,%ebp
jmp    12be <main+0x10e>
cs nopw 0x0(%rax,%rax,1)
mov    0x4(%rsp),%r8d
mov    0x18(%rsp),%rdi
mov    0x8(%rsp),%rsi
mov    %r12d,%edx
mov    %ebp,%ecx
call   1060 <findLCS@plt>
mov    %r13,%r12
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x186a0,%esi
call   1090 <fgets@plt>
mov    $0x1,%bpl
test   %rax,%rax
lea    0x2(%rsp),%r13
je     152c <main+0x37c>
mov    %rbx,%rdi
lea    0xd80(%rip),%rsi
lea    0x4(%rsp),%rdx
call   10c0 <sscanf@plt>
cmpl   $0x0,0x4(%rsp)
je     152c <main+0x37c>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x186a0,%esi
call   1090 <fgets@plt>
test   %rax,%rax
je     1530 <main+0x380>
mov    %ebp,0x14(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strcspn@plt>
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rdi
lea    0x80(%rsp),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
mov    0x18(%rsp),%rbp
je     13a0 <main+0x1f0>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x186a0,%esi
call   1090 <fgets@plt>
test   %rax,%rax
je     1530 <main+0x380>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strcspn@plt>
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rdi
lea    0x40(%rsp),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1460 <main+0x2b0>
mov    %r12,%r13
mov    %rbp,%rdi
call   1070 <strlen@plt>
mov    %eax,%r12d
mov    0x8(%rsp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ebp
testb  $0x1,0x14(%rsp)
je     1280 <main+0xd0>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1280 <main+0xd0>
nopw   0x0(%rax,%rax,1)
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x186a0,%esi
call   1090 <fgets@plt>
test   %rax,%rax
je     1530 <main+0x380>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strcspn@plt>
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1324 <main+0x174>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10d0 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x186a0,%esi
call   1090 <fgets@plt>
test   %rax,%rax
je     1530 <main+0x380>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strcspn@plt>
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1324 <main+0x174>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10d0 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10d0 <strcat@plt>
jmp    1400 <main+0x250>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x186a0,%esi
call   1090 <fgets@plt>
test   %rax,%rax
je     1553 <main+0x3a3>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strcspn@plt>
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rdi
lea    0x20(%rsp),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1363 <main+0x1b3>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10d0 <strcat@plt>
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x186a0,%esi
call   1090 <fgets@plt>
test   %rax,%rax
je     1523 <main+0x373>
nopl   (%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strcspn@plt>
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rdi
lea    0x20(%rsp),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1363 <main+0x1b3>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10d0 <strcat@plt>
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   10d0 <strcat@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x186a0,%esi
call   1090 <fgets@plt>
test   %rax,%rax
jne    14d0 <main+0x320>
lea    0xb24(%rip),%rdi
jmp    1537 <main+0x387>
xor    %eax,%eax
jmp    1541 <main+0x391>
lea    0xb53(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb16(%rip),%rdi
jmp    1537 <main+0x387>

LLVM IR (-O0):
@.str = [19 x i8] c"BEGIN TDP CODEBASE\00"
@.str.1 = [17 x i8] c"END TDP CODEBASE\00"
@.str.2 = [19 x i8] c"BEGIN JCN CODEBASE\00"
@.str.3 = [17 x i8] c"END JCN CODEBASE\00"
@__const.main.newline = [2 x i8] c"\0A\00"
@stdin = global i32 0
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [8 x i8] c"error!\0A\00"
@.str.6 = [3 x i8] c"\0A\0D\00"
@.str.7 = [27 x i8] c"error reading 'begin jcn'\0A\00"
@.str.8 = [35 x i8] c"error reading next line of input!\0A\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [20 x i8]
%19 = alloca [20 x i8]
%20 = alloca [20 x i8]
%21 = alloca [20 x i8]
%22 = alloca [2 x i8]
%23 = alloca i32
%24 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 100000, i32* %7
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 1
%28 = trunc i64 %27 to i32
%29 = call i8* @malloc(i32 %28)
store i8* %29, i8** %8
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = mul i64 %31, 1
%33 = trunc i64 %32 to i32
%34 = call i8* @malloc(i32 %33)
store i8* %34, i8** %9
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = mul i64 %36, 1
%38 = trunc i64 %37 to i32
%39 = call i8* @malloc(i32 %38)
store i8* %39, i8** %10
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = mul i64 %41, 1
%43 = trunc i64 %42 to i32
%44 = call i8* @malloc(i32 %43)
store i8* %44, i8** %11
store i32 1, i32* %16
%45 = getelementptr inbounds [20 x i8], [20 x i8]* %18, i64 0, i64 0
%46 = call i32 @strcpy(i8* %45, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%47 = getelementptr inbounds [20 x i8], [20 x i8]* %19, i64 0, i64 0
%48 = call i32 @strcpy(i8* %47, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%49 = getelementptr inbounds [20 x i8], [20 x i8]* %20, i64 0, i64 0
%50 = call i32 @strcpy(i8* %49, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%51 = getelementptr inbounds [20 x i8], [20 x i8]* %21, i64 0, i64 0
%52 = call i32 @strcpy(i8* %51, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%53 = bitcast [2 x i8]* %22 to i8*
br label %54
54: ; preds = %2, %202
%55 = load i8*, i8** %8
%56 = load i32, i32* %7
%57 = load i32, i32* @stdin
%58 = call i32* @fgets(i8* %55, i32 %56, i32 %57)
%59 = icmp eq i32* %58, null
br i1 %59, label %60, label %61
60: ; preds = %54
store i32 0, i32* %3
br label %209
61: ; preds = %54
%62 = load i8*, i8** %8
%63 = call i32 @sscanf(i8* %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %17)
%64 = load i32, i32* %17
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %61
store i32 0, i32* %3
br label %209
67: ; preds = %61
%68 = load i8*, i8** %8
%69 = load i32, i32* %7
%70 = load i32, i32* @stdin
%71 = call i32* @fgets(i8* %68, i32 %69, i32 %70)
%72 = icmp eq i32* %71, null
br i1 %72, label %73, label %75
73: ; preds = %67
%74 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %209
75: ; preds = %67
%76 = load i8*, i8** %8
%77 = load i8*, i8** %8
%78 = call i64 @strcspn(i8* %77, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%79 = getelementptr inbounds i8, i8* %76, i64 %78
store i8 0, i8* %79
%80 = load i8*, i8** %8
%81 = getelementptr inbounds [20 x i8], [20 x i8]* %18, i64 0, i64 0
%82 = call i64 @strcmp(i8* %80, i8* %81)
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %130
84: ; preds = %75
%85 = load i8*, i8** %8
%86 = load i32, i32* %7
%87 = load i32, i32* @stdin
%88 = call i32* @fgets(i8* %85, i32 %86, i32 %87)
%89 = icmp eq i32* %88, null
br i1 %89, label %90, label %92
90: ; preds = %84
%91 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %209
92: ; preds = %84
%93 = load i8*, i8** %8
%94 = load i8*, i8** %8
%95 = call i64 @strcspn(i8* %94, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%96 = getelementptr inbounds i8, i8* %93, i64 %95
store i8 0, i8* %96
store i32 1, i32* %23
br label %97
97: ; preds = %124, %92
%98 = load i8*, i8** %8
%99 = getelementptr inbounds [20 x i8], [20 x i8]* %19, i64 0, i64 0
%100 = call i64 @strcmp(i8* %98, i8* %99)
%101 = icmp ne i64 %100, 0
br i1 %101, label %102, label %129
102: ; preds = %97
%103 = load i8*, i8** %8
%104 = getelementptr inbounds [2 x i8], [2 x i8]* %22, i64 0, i64 0
%105 = call i32 @strcat(i8* %103, i8* %104)
%106 = load i32, i32* %23
%107 = icmp eq i32 %106, 1
br i1 %107, label %108, label %112
108: ; preds = %102
%109 = load i8*, i8** %9
%110 = load i8*, i8** %8
%111 = call i32 @strcpy(i8* %109, i8* %110)
store i32 0, i32* %23
br label %116
112: ; preds = %102
%113 = load i8*, i8** %9
%114 = load i8*, i8** %8
%115 = call i32 @strcat(i8* %113, i8* %114)
br label %116
116: ; preds = %112, %108
%117 = load i8*, i8** %8
%118 = load i32, i32* %7
%119 = load i32, i32* @stdin
%120 = call i32* @fgets(i8* %117, i32 %118, i32 %119)
%121 = icmp eq i32* %120, null
br i1 %121, label %122, label %124
122: ; preds = %116
%123 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %209
124: ; preds = %116
%125 = load i8*, i8** %8
%126 = load i8*, i8** %8
%127 = call i64 @strcspn(i8* %126, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%128 = getelementptr inbounds i8, i8* %125, i64 %127
store i8 0, i8* %128
br label %97
129: ; preds = %97
br label %130
130: ; preds = %129, %75
%131 = load i8*, i8** %8
%132 = load i32, i32* %7
%133 = load i32, i32* @stdin
%134 = call i32* @fgets(i8* %131, i32 %132, i32 %133)
%135 = icmp eq i32* %134, null
br i1 %135, label %136, label %138
136: ; preds = %130
%137 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %209
138: ; preds = %130
%139 = load i8*, i8** %8
%140 = load i8*, i8** %8
%141 = call i64 @strcspn(i8* %140, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%142 = getelementptr inbounds i8, i8* %139, i64 %141
store i8 0, i8* %142
%143 = load i8*, i8** %8
%144 = getelementptr inbounds [20 x i8], [20 x i8]* %20, i64 0, i64 0
%145 = call i64 @strcmp(i8* %143, i8* %144)
%146 = icmp eq i64 %145, 0
br i1 %146, label %147, label %193
147: ; preds = %138
%148 = load i8*, i8** %8
%149 = load i32, i32* %7
%150 = load i32, i32* @stdin
%151 = call i32* @fgets(i8* %148, i32 %149, i32 %150)
%152 = icmp eq i32* %151, null
br i1 %152, label %153, label %155
153: ; preds = %147
%154 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %209
155: ; preds = %147
%156 = load i8*, i8** %8
%157 = load i8*, i8** %8
%158 = call i64 @strcspn(i8* %157, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%159 = getelementptr inbounds i8, i8* %156, i64 %158
store i8 0, i8* %159
store i32 1, i32* %24
br label %160
160: ; preds = %187, %155
%161 = load i8*, i8** %8
%162 = getelementptr inbounds [20 x i8], [20 x i8]* %21, i64 0, i64 0
%163 = call i64 @strcmp(i8* %161, i8* %162)
%164 = icmp ne i64 %163, 0
br i1 %164, label %165, label %192
165: ; preds = %160
%166 = load i8*, i8** %8
%167 = getelementptr inbounds [2 x i8], [2 x i8]* %22, i64 0, i64 0
%168 = call i32 @strcat(i8* %166, i8* %167)
%169 = load i32, i32* %24
%170 = icmp eq i32 %169, 1
br i1 %170, label %171, label %175
171: ; preds = %165
%172 = load i8*, i8** %10
%173 = load i8*, i8** %8
%174 = call i32 @strcpy(i8* %172, i8* %173)
store i32 0, i32* %24
br label %179
175: ; preds = %165
%176 = load i8*, i8** %10
%177 = load i8*, i8** %8
%178 = call i32 @strcat(i8* %176, i8* %177)
br label %179
179: ; preds = %175, %171
%180 = load i8*, i8** %8
%181 = load i32, i32* %7
%182 = load i32, i32* @stdin
%183 = call i32* @fgets(i8* %180, i32 %181, i32 %182)
%184 = icmp eq i32* %183, null
br i1 %184, label %185, label %187
185: ; preds = %179
%186 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %209
187: ; preds = %179
%188 = load i8*, i8** %8
%189 = load i8*, i8** %8
%190 = call i64 @strcspn(i8* %189, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%191 = getelementptr inbounds i8, i8* %188, i64 %190
store i8 0, i8* %191
br label %160
192: ; preds = %160
br label %193
193: ; preds = %192, %138
%194 = load i8*, i8** %9
%195 = call i32 @strlen(i8* %194)
store i32 %195, i32* %13
%196 = load i8*, i8** %10
%197 = call i32 @strlen(i8* %196)
store i32 %197, i32* %14
%198 = load i32, i32* %16
%199 = icmp eq i32 %198, 0
br i1 %199, label %200, label %202
200: ; preds = %193
%201 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %202
202: ; preds = %200, %193
store i32 0, i32* %16
%203 = load i8*, i8** %9
%204 = load i8*, i8** %10
%205 = load i32, i32* %13
%206 = load i32, i32* %14
%207 = load i32, i32* %17
%208 = call i32 @findLCS(i8* %203, i8* %204, i32 %205, i32 %206, i32 %207)
br label %54
209: ; preds = %185, %153, %136, %122, %90, %73, %66, %60
%210 = load i32, i32* %3
ret i32 %210
}

LLVM IR (-O2):
@.str = [19 x i8] c"BEGIN TDP CODEBASE\00"
@.str.1 = [17 x i8] c"END TDP CODEBASE\00"
@.str.2 = [19 x i8] c"BEGIN JCN CODEBASE\00"
@.str.3 = [17 x i8] c"END JCN CODEBASE\00"
@stdin = global i32 0
@.str.4 = [3 x i8] c"%d\00"
@.str.6 = [3 x i8] c"\0A\0D\00"
@str = [34 x i8] c"error reading next line of input!\00"
@str.10 = [26 x i8] c"error reading 'begin jcn'\00"
@str.14 = [7 x i8] c"error!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [20 x i8]
%5 = alloca [20 x i8]
%6 = alloca [20 x i8]
%7 = alloca [20 x i8]
%8 = alloca i16
%9 = tail call dereferenceable_or_null(100000) i8* @malloc(i32 100000)
%10 = tail call dereferenceable_or_null(100000) i8* @malloc(i32 100000)
%11 = tail call dereferenceable_or_null(100000) i8* @malloc(i32 100000)
%12 = bitcast i32* %3 to i8*
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%15 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%19 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%21 = bitcast i16* %8 to i8*
store i16 10, i16* %8
%22 = load i32, i32* @stdin
%23 = call i32* @fgets(i8* %9, i32 100000, i32 %22)
%24 = icmp eq i32* %23, null
br i1 %24, label %114, label %25
25: ; preds = %2, %105
%26 = phi i1 [ true, %105 ], [ false, %2 ]
%27 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%28 = load i32, i32* %3
%29 = icmp eq i32 %28, 0
br i1 %29, label %114, label %30
30: ; preds = %25
%31 = load i32, i32* @stdin
%32 = call i32* @fgets(i8* %9, i32 100000, i32 %31)
%33 = icmp eq i32* %32, null
br i1 %33, label %111, label %34
34: ; preds = %30
%35 = call i64 @strcspn(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%36 = getelementptr inbounds i8, i8* %9, i64 %35
store i8 0, i8* %36
%37 = call i64 @strcmp(i8* %9, i8* %13)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %65
39: ; preds = %34
%40 = load i32, i32* @stdin
%41 = call i32* @fgets(i8* %9, i32 100000, i32 %40)
%42 = icmp eq i32* %41, null
br i1 %42, label %111, label %43
43: ; preds = %39
%44 = call i64 @strcspn(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%45 = getelementptr inbounds i8, i8* %9, i64 %44
store i8 0, i8* %45
%46 = call i64 @strcmp(i8* %9, i8* %14)
%47 = icmp eq i64 %46, 0
br i1 %47, label %65, label %48
48: ; preds = %43
%49 = call i32 @strcat(i8* %9, i8* %21)
%50 = call i32 @strcpy(i8* %10, i8* %9)
%51 = load i32, i32* @stdin
%52 = call i32* @fgets(i8* %9, i32 100000, i32 %51)
%53 = icmp eq i32* %52, null
br i1 %53, label %111, label %60
54: ; preds = %60
%55 = call i32 @strcat(i8* %9, i8* %21)
%56 = call i32 @strcat(i8* %10, i8* %9)
%57 = load i32, i32* @stdin
%58 = call i32* @fgets(i8* %9, i32 100000, i32 %57)
%59 = icmp eq i32* %58, null
br i1 %59, label %111, label %60
60: ; preds = %48, %54
%61 = call i64 @strcspn(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%62 = getelementptr inbounds i8, i8* %9, i64 %61
store i8 0, i8* %62
%63 = call i64 @strcmp(i8* %9, i8* %14)
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %54
65: ; preds = %60, %43, %34
%66 = load i32, i32* @stdin
%67 = call i32* @fgets(i8* %9, i32 100000, i32 %66)
%68 = icmp eq i32* %67, null
br i1 %68, label %111, label %69
69: ; preds = %65
%70 = call i64 @strcspn(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%71 = getelementptr inbounds i8, i8* %9, i64 %70
store i8 0, i8* %71
%72 = call i64 @strcmp(i8* %9, i8* %17)
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %100
74: ; preds = %69
%75 = load i32, i32* @stdin
%76 = call i32* @fgets(i8* %9, i32 100000, i32 %75)
%77 = icmp eq i32* %76, null
br i1 %77, label %111, label %78
78: ; preds = %74
%79 = call i64 @strcspn(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%80 = getelementptr inbounds i8, i8* %9, i64 %79
store i8 0, i8* %80
%81 = call i64 @strcmp(i8* %9, i8* %18)
%82 = icmp eq i64 %81, 0
br i1 %82, label %100, label %83
83: ; preds = %78
%84 = call i32 @strcat(i8* %9, i8* %21)
%85 = call i32 @strcpy(i8* %11, i8* %9)
%86 = load i32, i32* @stdin
%87 = call i32* @fgets(i8* %9, i32 100000, i32 %86)
%88 = icmp eq i32* %87, null
br i1 %88, label %111, label %95
89: ; preds = %95
%90 = call i32 @strcat(i8* %9, i8* %21)
%91 = call i32 @strcat(i8* %11, i8* %9)
%92 = load i32, i32* @stdin
%93 = call i32* @fgets(i8* %9, i32 100000, i32 %92)
%94 = icmp eq i32* %93, null
br i1 %94, label %111, label %95
95: ; preds = %83, %89
%96 = call i64 @strcspn(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%97 = getelementptr inbounds i8, i8* %9, i64 %96
store i8 0, i8* %97
%98 = call i64 @strcmp(i8* %9, i8* %18)
%99 = icmp eq i64 %98, 0
br i1 %99, label %100, label %89
100: ; preds = %95, %78, %69
%101 = call i32 @strlen(i8* %10)
%102 = call i32 @strlen(i8* %11)
br i1 %26, label %103, label %105
103: ; preds = %100
%104 = call i32 @putchar(i32 10)
br label %105
105: ; preds = %103, %100
%106 = load i32, i32* %3
%107 = call i32 @findLCS(i8* %10, i8* %11, i32 %101, i32 %102, i32 %106)
%108 = load i32, i32* @stdin
%109 = call i32* @fgets(i8* %9, i32 100000, i32 %108)
%110 = icmp eq i32* %109, null
br i1 %110, label %114, label %25
111: ; preds = %74, %65, %39, %30, %48, %83, %54, %89
%112 = phi i8* [ getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0), %89 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.14, i64 0, i64 0), %54 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.14, i64 0, i64 0), %30 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.14, i64 0, i64 0), %39 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.14, i64 0, i64 0), %65 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @str.10, i64 0, i64 0), %74 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.14, i64 0, i64 0), %48 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0), %83 ]
%113 = call i32 @puts(i8* dereferenceable(1) %112)
br label %114
114: ; preds = %105, %25, %111, %2
%115 = phi i32 [ 0, %2 ], [ 1, %111 ], [ 0, %25 ], [ 0, %105 ]
ret i32 %115
}