#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*/ getchar();
int lcs(char *, char *, int, int);
int /*<<< orphan*/ printf(char *, int, ...);
int strlen(char *);
int main() {
  char X[] = "AGGTAB";
  char Y[] = "GXTXAYB";
  int m = strlen(X);
  int n = strlen(Y);
  printf("len1: %d len2: %d\n", m, n);
  printf("Length of LCS is %d\n", lcs(X, Y, m, n));
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeab(%rip),%eax
mov    %eax,-0xb(%rbp)
mov    0xea5(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xe9d(%rip),%al
mov    %al,-0x5(%rbp)
mov    0xe94(%rip),%rax
mov    %rax,-0x13(%rbp)
lea    -0xb(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
lea    -0x13(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xb(%rbp),%rdi
lea    -0x13(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1040 <lcs@plt>
mov    %eax,%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movl   $0x424154,0xb(%rsp)
movl   $0x54474741,0x8(%rsp)
54
movabs $0x42594158545847,%rax
mov    %rax,0x10(%rsp)
lea    0x8(%rsp),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0x10(%rsp),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
lea    0xe79(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1040 <lcs@plt>
lea    0xe6b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.X = [7 x i8] c"AGGTAB\00"
@__const.main.Y = [8 x i8] c"GXTXAYB\00"
@.str = [19 x i8] c"len1: %d len2: %d\0A\00"
@.str.1 = [21 x i8] c"Length of LCS is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [7 x i8]
%3 = alloca [8 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [7 x i8]* %2 to i8*
%7 = bitcast [8 x i8]* %3 to i8*
%8 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %4
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %5
%12 = load i32, i32* %4
%13 = load i32, i32* %5
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
%15 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = call i32 @lcs(i8* %15, i8* %16, i32 %17, i32 %18)
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@__const.main.X = [7 x i8] c"AGGTAB\00"
@.str = [19 x i8] c"len1: %d len2: %d\0A\00"
@.str.1 = [21 x i8] c"Length of LCS is %d\0A\00"
define i32 @main() {
%1 = alloca [7 x i8]
%2 = alloca i64
%3 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%4 = bitcast i64* %2 to i8*
store i64 18675485652572231, i64* %2
%5 = call i32 @strlen(i8* %3)
%6 = call i32 @strlen(i8* %4)
%7 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = call i32 @lcs(i8* %3, i8* %4, i32 %5, i32 %6)
%9 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = call i32 (...) @getchar()
ret i32 0
}