#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_sequence(char *, char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ random_string(char *, int);
int lcs_test() {
  char s1[19], s2[19], s3[19];
  memset(s1, 0, 19);
  memset(s2, 0, 19);
  memset(s3, 0, 19);
  random_string(s1, 19 - 1);
  random_string(s2, 19 - 1);
  int lcs = longest_common_sequence(s1, s2, s3);
  printf("s1:%s\n", s1);
  printf("s2:%s\n", s2);
  printf("%d\n", lcs);
  char *s4 = "abcab";
  char *s5 = "abccd";
  lcs = longest_common_sequence(s4, s5, s3);
  printf("s4:%s\n", s4);
  printf("s5:%s\n", s5);
  printf("%d\n", lcs);
}


x86 assembly (clang, -O0):
<lcs_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x13,%edx
call   1050 <memset@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x13,%edx
call   1050 <memset@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x13,%edx
call   1050 <memset@plt>
lea    -0x20(%rbp),%rdi
mov    $0x12,%esi
call   1030 <random_string@plt>
lea    -0x40(%rbp),%rdi
mov    $0x12,%esi
call   1030 <random_string@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1060 <longest_common_sequence@plt>
mov    %eax,-0x64(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x64(%rbp),%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe2b(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xe26(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1060 <longest_common_sequence@plt>
mov    %eax,-0x64(%rbp)
mov    -0x70(%rbp),%rsi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x78(%rbp),%rsi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x64(%rbp),%esi
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcs_test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x60,%rsp
lea    0x40(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x13,%edx
call   1050 <memset@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x13,%edx
call   1050 <memset@plt>
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x13,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
mov    $0x12,%esi
call   1030 <random_string@plt>
mov    %rbx,%rdi
mov    $0x12,%esi
call   1030 <random_string@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <longest_common_sequence@plt>
mov    %eax,%ebp
lea    0xe49(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe35(%rip),%r15
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe26(%rip),%rbp
lea    0xe25(%rip),%r12
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1060 <longest_common_sequence@plt>
mov    %eax,%ebx
lea    0xe14(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe0a(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"s1:%s\0A\00"
@.str.1 = [7 x i8] c"s2:%s\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [6 x i8] c"abcab\00"
@.str.4 = [6 x i8] c"abccd\00"
@.str.5 = [7 x i8] c"s4:%s\0A\00"
@.str.6 = [7 x i8] c"s5:%s\0A\00"
define i32 @lcs_test() {
%1 = alloca i32
%2 = alloca [19 x i8]
%3 = alloca [19 x i8]
%4 = alloca [19 x i8]
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 19)
%10 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%11 = call i32 @memset(i8* %10, i32 0, i32 19)
%12 = getelementptr inbounds [19 x i8], [19 x i8]* %4, i64 0, i64 0
%13 = call i32 @memset(i8* %12, i32 0, i32 19)
%14 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 0
%15 = call i32 @random_string(i8* %14, i32 18)
%16 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%17 = call i32 @random_string(i8* %16, i32 18)
%18 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 0
%19 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%20 = getelementptr inbounds [19 x i8], [19 x i8]* %4, i64 0, i64 0
%21 = call i32 @longest_common_sequence(i8* %18, i8* %19, i8* %20)
store i32 %21, i32* %5
%22 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load i32, i32* %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %26)
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %7
%28 = load i8*, i8** %6
%29 = load i8*, i8** %7
%30 = getelementptr inbounds [19 x i8], [19 x i8]* %4, i64 0, i64 0
%31 = call i32 @longest_common_sequence(i8* %28, i8* %29, i8* %30)
store i32 %31, i32* %5
%32 = load i8*, i8** %6
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %7
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %34)
%36 = load i32, i32* %5
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
@.str = [7 x i8] c"s1:%s\0A\00"
@.str.1 = [7 x i8] c"s2:%s\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [6 x i8] c"abcab\00"
@.str.4 = [6 x i8] c"abccd\00"
@.str.5 = [7 x i8] c"s4:%s\0A\00"
@.str.6 = [7 x i8] c"s5:%s\0A\00"
define i32 @lcs_test() {
%1 = alloca [19 x i8]
%2 = alloca [19 x i8]
%3 = alloca [19 x i8]
%4 = getelementptr inbounds [19 x i8], [19 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%7 = call i32 @memset(i8* %4, i32 0, i32 19)
%8 = call i32 @memset(i8* %5, i32 0, i32 19)
%9 = call i32 @memset(i8* %6, i32 0, i32 19)
%10 = call i32 @random_string(i8* %4, i32 18)
%11 = call i32 @random_string(i8* %5, i32 18)
%12 = call i32 @longest_common_sequence(i8* %4, i8* %5, i8* %6)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %4)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%16 = call i32 @longest_common_sequence(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
ret i32 undef
}