#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 longest_common_subseq(char *, char *, int /*<<< orphan*/,
                          int /*<<< orphan*/, int, int, int **);
int longest_common_substr(char *, char *, int /*<<< orphan*/,
                          int /*<<< orphan*/, int, int, int **);
int /*<<< orphan*/ printf(char *, int);
int strlen(char *);
void main() {
  char str1[] = "iavinashrameshpatil";
  char str2[] = "helloavinashrpatlmdncv";
  int len1 = strlen(str1);
  int len2 = strlen(str2);
  int table[100][100];
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      table[i][j] = -1;
    }
  }
  printf("longest common subseq length is %d",
         longest_common_subseq(str1, str2, 0, 0, len1, len2, table));
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      table[i][j] = -1;
    }
  }
  printf("longest common substr length is %d",
         longest_common_substr(str1, str2, 0, 0, len1, len2, table));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9cb0,%rsp
mov    0xeae(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea9(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xeaf(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeac(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xeaa(%rip),%eax
mov    %eax,-0x30(%rbp)
mov    0xea4(%rip),%ax
mov    %ax,-0x2c(%rbp)
mov    0xe9c(%rip),%al
mov    %al,-0x2a(%rbp)
lea    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x44(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x9c94(%rbp)
cmpl   $0x64,-0x9c94(%rbp)
jge    1236 <main+0xf6>
movl   $0x0,-0x9c98(%rbp)
cmpl   $0x64,-0x9c98(%rbp)
jge    121d <main+0xdd>
movslq -0x9c94(%rbp),%rcx
lea    -0x9c90(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0x9c98(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x9c98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c98(%rbp)
jmp    11d6 <main+0x96>
jmp    1222 <main+0xe2>
mov    -0x9c94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c94(%rbp)
jmp    11bf <main+0x7f>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    -0x44(%rbp),%r8d
mov    -0x48(%rbp),%r9d
lea    -0x9c90(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
mov    %rax,(%rsp)
call   1030 <longest_common_subseq@plt>
mov    %eax,%esi
lea    0xdd4(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x9c9c(%rbp)
cmpl   $0x64,-0x9c9c(%rbp)
jge    12e9 <main+0x1a9>
movl   $0x0,-0x9ca0(%rbp)
cmpl   $0x64,-0x9ca0(%rbp)
jge    12d0 <main+0x190>
movslq -0x9c9c(%rbp),%rcx
lea    -0x9c90(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0x9ca0(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x9ca0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9ca0(%rbp)
jmp    1289 <main+0x149>
jmp    12d5 <main+0x195>
mov    -0x9c9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c9c(%rbp)
jmp    1272 <main+0x132>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    -0x44(%rbp),%r8d
mov    -0x48(%rbp),%r9d
lea    -0x9c90(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
mov    %rax,(%rsp)
call   1060 <longest_common_substr@plt>
mov    %eax,%esi
lea    0xd44(%rip),%rdi
call   1050 <printf@plt>
add    $0x9cb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x9c90,%rsp
movaps 0xe9a(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x6c6974,0x20(%rsp)
movaps 0xea6(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movabs $0x76636e646d6c74,%rax
mov    %rax,0x3f(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%r12d
lea    0x30(%rsp),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
lea    0x50(%rsp),%rbp
mov    $0x9c40,%edx
mov    %rbp,%rdi
mov    $0xff,%esi
call   1060 <memset@plt>
mov    %rbp,(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r12d,%r8d
mov    %ebx,%r9d
call   1030 <longest_common_subseq@plt>
lea    0xe53(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    $0x9c40,%edx
mov    %rbp,%rdi
mov    $0xff,%esi
call   1060 <memset@plt>
mov    %rbp,(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r12d,%r8d
mov    %ebx,%r9d
call   1070 <longest_common_substr@plt>
lea    0xe3d(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
add    $0x9c90,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.str1 = [20 x i8] c"iavinashrameshpatil\00"
@__const.main.str2 = [23 x i8] c"helloavinashrpatlmdncv\00"
@.str = [35 x i8] c"longest common subseq length is %d\00"
@.str.1 = [35 x i8] c"longest common substr length is %d\00"
define void @main() {
%1 = alloca [20 x i8]
%2 = alloca [23 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x [100 x i32]]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = bitcast [20 x i8]* %1 to i8*
%11 = bitcast [23 x i8]* %2 to i8*
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %3
%14 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %4
store i32 0, i32* %6
br label %16
16: ; preds = %34, %0
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 100
br i1 %18, label %19, label %37
19: ; preds = %16
store i32 0, i32* %7
br label %20
20: ; preds = %30, %19
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 100
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %5, i64 0, i64 %25
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %26, i64 0, i64 %28
store i32 -1, i32* %29
br label %30
30: ; preds = %23
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %20
33: ; preds = %20
br label %34
34: ; preds = %33
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %16
37: ; preds = %16
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%39 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%40 = load i32, i32* %3
%41 = load i32, i32* %4
%42 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %5, i64 0, i64 0
%43 = bitcast [100 x i32]* %42 to i32**
%44 = call i32 @longest_common_subseq(i8* %38, i8* %39, i32 0, i32 0, i32 %40, i32 %41, i32** %43)
%45 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %44)
store i32 0, i32* %8
br label %46
46: ; preds = %64, %37
%47 = load i32, i32* %8
%48 = icmp slt i32 %47, 100
br i1 %48, label %49, label %67
49: ; preds = %46
store i32 0, i32* %9
br label %50
50: ; preds = %60, %49
%51 = load i32, i32* %9
%52 = icmp slt i32 %51, 100
br i1 %52, label %53, label %63
53: ; preds = %50
%54 = load i32, i32* %8
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %5, i64 0, i64 %55
%57 = load i32, i32* %9
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [100 x i32], [100 x i32]* %56, i64 0, i64 %58
store i32 -1, i32* %59
br label %60
60: ; preds = %53
%61 = load i32, i32* %9
%62 = add nsw i32 %61, 1
store i32 %62, i32* %9
br label %50
63: ; preds = %50
br label %64
64: ; preds = %63
%65 = load i32, i32* %8
%66 = add nsw i32 %65, 1
store i32 %66, i32* %8
br label %46
67: ; preds = %46
%68 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%69 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%70 = load i32, i32* %3
%71 = load i32, i32* %4
%72 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %5, i64 0, i64 0
%73 = bitcast [100 x i32]* %72 to i32**
%74 = call i32 @longest_common_substr(i8* %68, i8* %69, i32 0, i32 0, i32 %70, i32 %71, i32** %73)
%75 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %74)
ret void
}

LLVM IR (-O2):
@__const.main.str1 = [20 x i8] c"iavinashrameshpatil\00"
@__const.main.str2 = [23 x i8] c"helloavinashrpatlmdncv\00"
@.str = [35 x i8] c"longest common subseq length is %d\00"
@.str.1 = [35 x i8] c"longest common substr length is %d\00"
define void @main() {
%1 = alloca [20 x i8]
%2 = alloca [23 x i8]
%3 = alloca [100 x [100 x i32]]
%4 = bitcast [100 x [100 x i32]]* %3 to i8*
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%7 = call i32 @strlen(i8* %5)
%8 = call i32 @strlen(i8* %6)
%9 = bitcast [100 x [100 x i32]]* %3 to i32**
%10 = call i32 @longest_common_subseq(i8* %5, i8* %6, i32 0, i32 0, i32 %7, i32 %8, i32** %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @longest_common_substr(i8* %5, i8* %6, i32 0, i32 0, i32 %7, i32 %8, i32** %9)
%13 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %12)
ret void
}