#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 /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
size_t strcspn(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  int rc;
  int BUFFSIZE = 10000;
  char *dna1 = malloc(BUFFSIZE * sizeof(char));
  char *dna2 = malloc(BUFFSIZE * sizeof(char));
  char *substring = malloc(BUFFSIZE * sizeof(char));
  int sub_len;
  int dna1_len;
  int dna2_len;
  int i;
  int first = 1;
  while (1) {
    if (fgets(dna1, BUFFSIZE, stdin) == NULL) {
      return (0);
    }
    if (fgets(dna2, BUFFSIZE, stdin) == NULL) {
      return (0);
    }
    dna1[strcspn(dna1, "\n\r")] = '\0';
    dna2[strcspn(dna2, "\n\r")] = '\0';
    dna1_len = strlen(dna1);
    dna2_len = strlen(dna2);
    if (first == 0) {
      printf("\n");
    }
    first = 0;
    findLCS(dna1, dna2, dna1_len, dna2_len);
    if (fgets(dna1, BUFFSIZE, stdin) == NULL) {
      return (0);
    }
  }
  free(dna1);
  free(dna2);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x2710,-0x18(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2e1d(%rip),%rax
mov    (%rax),%edx
call   1070 <fgets@plt>
cmp    $0x0,%rax
jne    11e8 <main+0x88>
movl   $0x0,-0x4(%rbp)
jmp    12d1 <main+0x171>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2df2(%rip),%rax
mov    (%rax),%edx
call   1070 <fgets@plt>
cmp    $0x0,%rax
jne    1213 <main+0xb3>
movl   $0x0,-0x4(%rbp)
jmp    12d1 <main+0x171>
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xdda(%rip),%rsi
call   1060 <strcspn@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xdb7(%rip),%rsi
call   1060 <strcspn@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x44(%rbp)
jne    1287 <main+0x127>
lea    0xd81(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x38(%rbp),%edx
mov    -0x3c(%rbp),%ecx
call   1030 <findLCS@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    0x2d39(%rip),%rax
mov    (%rax),%edx
call   1070 <fgets@plt>
cmp    $0x0,%rax
jne    12cc <main+0x16c>
movl   $0x0,-0x4(%rbp)
jmp    12d1 <main+0x171>
jmp    11bd <main+0x5d>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x2710,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    $0x2710,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
xor    %r15d,%r15d
mov    0x2e59(%rip),%r13
jmp    11cd <main+0x6d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
mov    %ebp,%ecx
call   1040 <findLCS@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x2710,%esi
call   1070 <fgets@plt>
mov    $0x1,%r15b
test   %rax,%rax
je     124d <main+0xed>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x2710,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     124d <main+0xed>
mov    0x0(%r13),%edx
mov    %r14,%rdi
mov    $0x2710,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     124d <main+0xed>
mov    %rbx,%rdi
lea    0xdfd(%rip),%rbp
mov    %rbp,%rsi
call   1060 <strcspn@plt>
movb   $0x0,(%rbx,%rax,1)
mov    %r14,%rdi
mov    %rbp,%rsi
call   1060 <strcspn@plt>
movb   $0x0,(%r14,%rax,1)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%r12d
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
test   $0x1,%r15b
je     11a0 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11a0 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"\0A\0D\00"
@.str.1 = [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 i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 10000, i32* %7
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 1
%19 = trunc i64 %18 to i32
%20 = call i8* @malloc(i32 %19)
store i8* %20, i8** %8
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 1
%24 = trunc i64 %23 to i32
%25 = call i8* @malloc(i32 %24)
store i8* %25, i8** %9
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = mul i64 %27, 1
%29 = trunc i64 %28 to i32
%30 = call i8* @malloc(i32 %29)
store i8* %30, i8** %10
store i32 1, i32* %15
br label %31
31: ; preds = %2, %74
%32 = load i8*, i8** %8
%33 = load i32, i32* %7
%34 = load i32, i32* @stdin
%35 = call i32* @fgets(i8* %32, i32 %33, i32 %34)
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 0, i32* %3
br label %75
38: ; preds = %31
%39 = load i8*, i8** %9
%40 = load i32, i32* %7
%41 = load i32, i32* @stdin
%42 = call i32* @fgets(i8* %39, i32 %40, i32 %41)
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %45
44: ; preds = %38
store i32 0, i32* %3
br label %75
45: ; preds = %38
%46 = load i8*, i8** %8
%47 = load i8*, i8** %8
%48 = call i64 @strcspn(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%49 = getelementptr inbounds i8, i8* %46, i64 %48
store i8 0, i8* %49
%50 = load i8*, i8** %9
%51 = load i8*, i8** %9
%52 = call i64 @strcspn(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%53 = getelementptr inbounds i8, i8* %50, i64 %52
store i8 0, i8* %53
%54 = load i8*, i8** %8
%55 = call i32 @strlen(i8* %54)
store i32 %55, i32* %12
%56 = load i8*, i8** %9
%57 = call i32 @strlen(i8* %56)
store i32 %57, i32* %13
%58 = load i32, i32* %15
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %45
%61 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %62
62: ; preds = %60, %45
store i32 0, i32* %15
%63 = load i8*, i8** %8
%64 = load i8*, i8** %9
%65 = load i32, i32* %12
%66 = load i32, i32* %13
%67 = call i32 @findLCS(i8* %63, i8* %64, i32 %65, i32 %66)
%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 %74
73: ; preds = %62
store i32 0, i32* %3
br label %75
74: ; preds = %62
br label %31
75: ; preds = %73, %44, %37
%76 = load i32, i32* %3
ret i32 %76
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"\0A\0D\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(10000) i8* @malloc(i32 10000)
%4 = tail call dereferenceable_or_null(10000) i8* @malloc(i32 10000)
br label %5
5: ; preds = %23, %2
%6 = phi i1 [ true, %23 ], [ false, %2 ]
%7 = load i32, i32* @stdin
%8 = tail call i32* @fgets(i8* %3, i32 10000, i32 %7)
%9 = icmp eq i32* %8, null
br i1 %9, label %28, label %10
10: ; preds = %5
%11 = load i32, i32* @stdin
%12 = tail call i32* @fgets(i8* %4, i32 10000, i32 %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %28, label %14
14: ; preds = %10
%15 = tail call i64 @strcspn(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds i8, i8* %3, i64 %15
store i8 0, i8* %16
%17 = tail call i64 @strcspn(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = getelementptr inbounds i8, i8* %4, i64 %17
store i8 0, i8* %18
%19 = tail call i32 @strlen(i8* %3)
%20 = tail call i32 @strlen(i8* %4)
br i1 %6, label %21, label %23
21: ; preds = %14
%22 = tail call i32 @putchar(i32 10)
br label %23
23: ; preds = %21, %14
%24 = tail call i32 @findLCS(i8* %3, i8* %4, i32 %19, i32 %20)
%25 = load i32, i32* @stdin
%26 = tail call i32* @fgets(i8* %3, i32 10000, i32 %25)
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %5
28: ; preds = %23, %10, %5
ret i32 0
}