#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 lcsubstr(char *, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char **argv) {
  char p1[] = "abcdefg";
  char p2[] = "macdefh";
  int result = lcsubstr(p1, p2, strlen(p1), strlen(p2));
  printf("%d\n", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    %eax,%ecx
call   1050 <lcsubstr@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movabs $0x67666564636261,%rax
mov    %rax,0x8(%rsp)
movabs $0x6866656463616d,%rax
mov    %rax,(%rsp)
lea    0x8(%rsp),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1050 <lcsubstr@plt>
lea    0xe7b(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.p1 = [8 x i8] c"abcdefg\00"
@__const.main.p2 = [8 x i8] c"macdefh\00"
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [8 x i8]
%7 = alloca [8 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [8 x i8]* %6 to i8*
%10 = bitcast [8 x i8]* %7 to i8*
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = call i32 @lcsubstr(i8* %11, i8* %12, i32 %14, i32 %16)
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = alloca i64
%5 = bitcast i64* %3 to i8*
store i64 29104508263162465, i64* %3
%6 = bitcast i64* %4 to i8*
store i64 29385983239872877, i64* %4
%7 = call i32 @strlen(i8* %5)
%8 = call i32 @strlen(i8* %6)
%9 = call i32 @lcsubstr(i8* %5, i8* %6, i32 %7, i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
ret i32 0
}