#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*/ _lcs(char const *, int /*<<< orphan*/, char const *,
                        int /*<<< orphan*/, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strlen(char const *);
char *LCS(const char *a, const char *b) {
  char *p = (char *)malloc(sizeof(char) * 256);
  if (p == NULL) {
    printf("malloc error\n");
    return NULL;
  }
  _lcs(a, strlen(a), b, strlen(b), p);
  return p;
}


x86 assembly (clang, -O0):
<LCS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x100,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1182 <LCS+0x42>
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11c5 <LCS+0x85>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    %eax,%ecx
mov    -0x20(%rbp),%r8
call   1050 <_lcs@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LCS>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x100,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1185 <LCS+0x45>
mov    %rax,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
mov    %eax,%ecx
mov    %rbx,%r8
call   1050 <_lcs@plt>
jmp    1193 <LCS+0x53>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"malloc error\0A\00"
define i8* @LCS(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = call i64 @malloc(i32 256)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %3
br label %23
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = load i8*, i8** %4
%16 = call i32 @strlen(i8* %15)
%17 = load i8*, i8** %5
%18 = load i8*, i8** %5
%19 = call i32 @strlen(i8* %18)
%20 = load i8*, i8** %6
%21 = call i32 @_lcs(i8* %14, i32 %16, i8* %17, i32 %19, i8* %20)
%22 = load i8*, i8** %6
store i8* %22, i8** %3
br label %23
23: ; preds = %13, %11
%24 = load i8*, i8** %3
ret i8* %24
}

LLVM IR (-O2):
@str = [13 x i8] c"malloc error\00"
define i8* @LCS(i8* %0, i8* %1) {
%3 = tail call i64 @malloc(i32 256)
%4 = inttoptr i64 %3 to i8*
%5 = icmp eq i64 %3, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %12
8: ; preds = %2
%9 = tail call i32 @strlen(i8* %0)
%10 = tail call i32 @strlen(i8* %1)
%11 = tail call i32 @_lcs(i8* %0, i32 %9, i8* %1, i32 %10, i8* %4)
br label %12
12: ; preds = %8, %6
%13 = phi i8* [ null, %6 ], [ %4, %8 ]
ret i8* %13
}