#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 LCSubseq(char *, char *, int, int);
int LCSubstr(char *, char *, int, int);
int /*<<< orphan*/ printf(char *, int);
int strlen(char *);
void main() {
  char a[] = "abviznash";
  char b[] = "avinashpatil";
  int m = strlen(a);
  int n = strlen(b);
  int res = LCSubseq(a, b, m - 1, n - 1);
  printf("LCSubseq is %d\n", res);
  res = 0;
  res = LCSubstr(a, b, m - 1, n - 1);
  printf("LCSubstr is %d\n", res);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0xa(%rbp)
mov    0xeae(%rip),%ax
mov    %ax,-0x2(%rbp)
mov    0xea5(%rip),%rax
mov    %rax,-0x17(%rbp)
mov    0xea3(%rip),%eax
mov    %eax,-0xf(%rbp)
mov    0xe9e(%rip),%al
mov    %al,-0xb(%rbp)
lea    -0xa(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x17(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
lea    -0xa(%rbp),%rdi
lea    -0x17(%rbp),%rsi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
call   1030 <LCSubseq@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe5e(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x24(%rbp)
lea    -0xa(%rbp),%rdi
lea    -0x17(%rbp),%rsi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
call   1050 <LCSubstr@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe3c(%rip),%rdi
call   1060 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
movabs $0x73616e7a69766261,%rax
6e 61 73
mov    %rax,0x8(%rsp)
movw   $0x68,0x10(%rsp)
movabs $0x6c697461706873,%rax
mov    %rax,0x1d(%rsp)
movabs $0x706873616e697661,%rax
73 68 70
mov    %rax,0x18(%rsp)
lea    0x8(%rsp),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0x18(%rsp),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%ebp
lea    -0x1(%rax),%ebx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1030 <LCSubseq@plt>
lea    0xe61(%rip),%rdi
mov    %eax,%esi
call   1060 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1050 <LCSubstr@plt>
lea    0xe54(%rip),%rdi
mov    %eax,%esi
call   1060 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.a = [10 x i8] c"abviznash\00"
@__const.main.b = [13 x i8] c"avinashpatil\00"
@.str = [16 x i8] c"LCSubseq is %d\0A\00"
@.str.1 = [16 x i8] c"LCSubstr is %d\0A\00"
define void @main() {
%1 = alloca [10 x i8]
%2 = alloca [13 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast [10 x i8]* %1 to i8*
%7 = bitcast [13 x i8]* %2 to i8*
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %3
%10 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %4
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%13 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%14 = load i32, i32* %3
%15 = sub nsw i32 %14, 1
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 1
%18 = call i32 @LCSubseq(i8* %12, i8* %13, i32 %15, i32 %17)
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %19)
store i32 0, i32* %5
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%22 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%23 = load i32, i32* %3
%24 = sub nsw i32 %23, 1
%25 = load i32, i32* %4
%26 = sub nsw i32 %25, 1
%27 = call i32 @LCSubstr(i8* %21, i8* %22, i32 %24, i32 %26)
store i32 %27, i32* %5
%28 = load i32, i32* %5
%29 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %28)
ret void
}

LLVM IR (-O2):
@__const.main.a = [10 x i8] c"abviznash\00"
@__const.main.b = [13 x i8] c"avinashpatil\00"
@.str = [16 x i8] c"LCSubseq is %d\0A\00"
@.str.1 = [16 x i8] c"LCSubstr is %d\0A\00"
define void @main() {
%1 = alloca [10 x i8]
%2 = alloca [13 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%5 = call i32 @strlen(i8* %3)
%6 = call i32 @strlen(i8* %4)
%7 = add nsw i32 %5, -1
%8 = add nsw i32 %6, -1
%9 = call i32 @LCSubseq(i8* %3, i8* %4, i32 %7, i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @LCSubstr(i8* %3, i8* %4, i32 %7, i32 %8)
%12 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %11)
ret void
}