#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 *, char *, char **, char **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int main() {
  char *s1 = "thisisatest";
  char *s2 = "testing123testing";
  char *beg, *end, *it;
  lcs(s1, s2, &beg, &end);
  for (it = beg; it != end; it++) {
    putchar(*it);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xebb(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1040 <lcs@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     119d <main+0x6d>
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1172 <main+0x42>
lea    0xe7a(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
lea    0xed9(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
call   1040 <lcs@plt>
mov    0x8(%rsp),%rbx
cmp    (%rsp),%rbx
je     1162 <main+0x42>
nopl   0x0(%rax,%rax,1)
movsbl (%rbx),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    (%rsp),%rbx
jne    1150 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"thisisatest\00"
@.str.1 = [18 x i8] c"testing123testing\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8** %3
%7 = load i8*, i8** %2
%8 = load i8*, i8** %3
%9 = call i32 @lcs(i8* %7, i8* %8, i8** %4, i8** %5)
%10 = load i8*, i8** %4
store i8* %10, i8** %6
br label %11
11: ; preds = %19, %0
%12 = load i8*, i8** %6
%13 = load i8*, i8** %5
%14 = icmp ne i8* %12, %13
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = load i8*, i8** %6
%17 = load i8, i8* %16
%18 = call i32 @putchar(i8 signext %17)
br label %19
19: ; preds = %15
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %6
br label %11
22: ; preds = %11
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"thisisatest\00"
@.str.1 = [18 x i8] c"testing123testing\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = bitcast i8** %1 to i8*
%4 = bitcast i8** %2 to i8*
%5 = call i32 @lcs(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8** %1, i8** %2)
%6 = load i8*, i8** %1
%7 = load i8*, i8** %2
%8 = icmp eq i8* %6, %7
br i1 %8, label %16, label %9
9: ; preds = %0, %9
%10 = phi i8* [ %13, %9 ], [ %6, %0 ]
%11 = load i8, i8* %10
%12 = call i32 @putchar(i8 signext %11)
%13 = getelementptr inbounds i8, i8* %10, i64 1
%14 = load i8*, i8** %2
%15 = icmp eq i8* %13, %14
br i1 %15, label %16, label %9
16: ; preds = %9, %0
%17 = call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
ret i32 0
}