#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 computeLongestCommonSubseq(char *, char *, int, int, int **);
int /*<<< orphan*/ reverseStr(char *, int, char *);
int computeLongestPalindromeSubseq(char str[], int len) {
  char rev[1001 + 1];
  int memoTable[1001][1001], row, col;
  reverseStr(str, len, rev);
  for (row = 0; row < len; row++)
    for (col = 0; col < len; col++)
      memoTable[row][col] = -1;
  return computeLongestCommonSubseq(str, rev, len - 1, len - 1, memoTable);
}


x86 assembly (clang, -O0):
<computeLongestPalindromeSubseq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3d2c60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x400(%rbp),%rdx
call   1030 <reverseStr@plt>
movl   $0x0,-0x3d2c54(%rbp)
mov    -0x3d2c54(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ca <computeLongestPalindromeSubseq+0xaa>
movl   $0x0,-0x3d2c58(%rbp)
mov    -0x3d2c58(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b1 <computeLongestPalindromeSubseq+0x91>
movslq -0x3d2c54(%rbp),%rcx
lea    -0x3d2c50(%rbp),%rax
imul   $0xfa4,%rcx,%rcx
add    %rcx,%rax
movslq -0x3d2c58(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x3d2c58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d2c58(%rbp)
jmp    1168 <computeLongestPalindromeSubseq+0x48>
jmp    11b6 <computeLongestPalindromeSubseq+0x96>
mov    -0x3d2c54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d2c54(%rbp)
jmp    114f <computeLongestPalindromeSubseq+0x2f>
mov    -0x8(%rbp),%rdi
lea    -0x400(%rbp),%rsi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
lea    -0x3d2c50(%rbp),%r8
call   1040 <computeLongestCommonSubseq@plt>
add    $0x3d2c60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<computeLongestPalindromeSubseq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3d2c48,%rsp
mov    %esi,%r15d
mov    %rdi,%r13
lea    0x10(%rsp),%rdx
call   1040 <reverseStr@plt>
test   %r15d,%r15d
jle    129d <computeLongestPalindromeSubseq+0x16d>
mov    %r13,0x8(%rsp)
mov    %r15d,%r13d
lea    0x0(,%r13,4),%rbx
lea    -0x1(%r13),%rax
mov    %r13d,%r12d
and    $0x7,%r12d
cmp    $0x7,%rax
jae    1183 <computeLongestPalindromeSubseq+0x53>
xor    %r14d,%r14d
jmp    1250 <computeLongestPalindromeSubseq+0x120>
and    $0xfffffff8,%r13d
lea    0x400(%rsp),%rbp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1030 <memset@plt>
lea    0xfa4(%rbp),%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1030 <memset@plt>
lea    0x1f48(%rbp),%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1030 <memset@plt>
lea    0x2eec(%rbp),%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1030 <memset@plt>
lea    0x3e90(%rbp),%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1030 <memset@plt>
lea    0x4e34(%rbp),%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1030 <memset@plt>
lea    0x5dd8(%rbp),%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1030 <memset@plt>
lea    0x6d7c(%rbp),%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1030 <memset@plt>
add    $0x8,%r14
add    $0x7d20,%rbp
cmp    %r14,%r13
jne    11a0 <computeLongestPalindromeSubseq+0x70>
test   %r12,%r12
mov    0x8(%rsp),%r13
je     129d <computeLongestPalindromeSubseq+0x16d>
imul   $0xfa4,%r14,%rax
lea    (%rsp,%rax,1),%r14
add    $0x400,%r14
imul   $0xfa4,%r12,%r12
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r14,%rbp,1),%rdi
mov    $0xff,%esi
mov    %rbx,%rdx
call   1030 <memset@plt>
add    $0xfa4,%rbp
cmp    %rbp,%r12
jne    1280 <computeLongestPalindromeSubseq+0x150>
add    $0xffffffff,%r15d
lea    0x10(%rsp),%rsi
lea    0x400(%rsp),%r8
mov    %r13,%rdi
mov    %r15d,%edx
mov    %r15d,%ecx
call   1050 <computeLongestCommonSubseq@plt>
add    $0x3d2c48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @computeLongestPalindromeSubseq(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [1002 x i8]
%6 = alloca [1001 x [1001 x i32]]
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = getelementptr inbounds [1002 x i8], [1002 x i8]* %5, i64 0, i64 0
%12 = call i32 @reverseStr(i8* %9, i32 %10, i8* %11)
store i32 0, i32* %7
br label %13
13: ; preds = %33, %2
%14 = load i32, i32* %7
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %36
17: ; preds = %13
store i32 0, i32* %8
br label %18
18: ; preds = %29, %17
%19 = load i32, i32* %8
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %6, i64 0, i64 %24
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [1001 x i32], [1001 x i32]* %25, i64 0, i64 %27
store i32 -1, i32* %28
br label %29
29: ; preds = %22
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %18
32: ; preds = %18
br label %33
33: ; preds = %32
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %13
36: ; preds = %13
%37 = load i8*, i8** %3
%38 = getelementptr inbounds [1002 x i8], [1002 x i8]* %5, i64 0, i64 0
%39 = load i32, i32* %4
%40 = sub nsw i32 %39, 1
%41 = load i32, i32* %4
%42 = sub nsw i32 %41, 1
%43 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %6, i64 0, i64 0
%44 = bitcast [1001 x i32]* %43 to i32**
%45 = call i32 @computeLongestCommonSubseq(i8* %37, i8* %38, i32 %40, i32 %42, i32** %44)
ret i32 %45
}

LLVM IR (-O2):
define i32 @computeLongestPalindromeSubseq(i8* %0, i32 %1) {
%3 = alloca [1002 x i8]
%4 = alloca [1001 x [1001 x i32]]
%5 = getelementptr inbounds [1002 x i8], [1002 x i8]* %3, i64 0, i64 0
%6 = bitcast [1001 x [1001 x i32]]* %4 to i8*
%7 = call i32 @reverseStr(i8* %0, i32 %1, i8* %5)
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %57
9: ; preds = %2
%10 = zext i32 %1 to i64
%11 = shl nuw nsw i64 %10, 2
%12 = add nsw i64 %10, -1
%13 = and i64 %10, 7
%14 = icmp ult i64 %12, 7
br i1 %14, label %46, label %15
15: ; preds = %9
%16 = and i64 %10, 4294967288
br label %17
17: ; preds = %17, %15
%18 = phi i64 [ 0, %15 ], [ %43, %17 ]
%19 = phi i64 [ 0, %15 ], [ %44, %17 ]
%20 = getelementptr [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %4, i64 0, i64 %18, i64 0
%21 = bitcast i32* %20 to i8*
%22 = or i64 %18, 1
%23 = getelementptr [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %4, i64 0, i64 %22, i64 0
%24 = bitcast i32* %23 to i8*
%25 = or i64 %18, 2
%26 = getelementptr [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %4, i64 0, i64 %25, i64 0
%27 = bitcast i32* %26 to i8*
%28 = or i64 %18, 3
%29 = getelementptr [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %4, i64 0, i64 %28, i64 0
%30 = bitcast i32* %29 to i8*
%31 = or i64 %18, 4
%32 = getelementptr [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %4, i64 0, i64 %31, i64 0
%33 = bitcast i32* %32 to i8*
%34 = or i64 %18, 5
%35 = getelementptr [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %4, i64 0, i64 %34, i64 0
%36 = bitcast i32* %35 to i8*
%37 = or i64 %18, 6
%38 = getelementptr [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %4, i64 0, i64 %37, i64 0
%39 = bitcast i32* %38 to i8*
%40 = or i64 %18, 7
%41 = getelementptr [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %4, i64 0, i64 %40, i64 0
%42 = bitcast i32* %41 to i8*
%43 = add nuw nsw i64 %18, 8
%44 = add i64 %19, 8
%45 = icmp eq i64 %44, %16
br i1 %45, label %46, label %17
46: ; preds = %17, %9
%47 = phi i64 [ 0, %9 ], [ %43, %17 ]
%48 = icmp eq i64 %13, 0
br i1 %48, label %57, label %49
49: ; preds = %46, %49
%50 = phi i64 [ %54, %49 ], [ %47, %46 ]
%51 = phi i64 [ %55, %49 ], [ 0, %46 ]
%52 = getelementptr [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %4, i64 0, i64 %50, i64 0
%53 = bitcast i32* %52 to i8*
%54 = add nuw nsw i64 %50, 1
%55 = add i64 %51, 1
%56 = icmp eq i64 %55, %13
br i1 %56, label %57, label %49
57: ; preds = %46, %49, %2
%58 = add nsw i32 %1, -1
%59 = bitcast [1001 x [1001 x i32]]* %4 to i32**
%60 = call i32 @computeLongestCommonSubseq(i8* %0, i8* %5, i32 %58, i32 %58, i32** %59)
ret i32 %60
}