#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*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
void removeLCP(char *str1, char *lcs, int len1, int max_lcp) {
  char *result = strstr(str1, lcs);
  int pos = result - str1;
  char buffer1[60000];
  strncpy(buffer1, str1, pos);
  buffer1[pos] = '#';
  buffer1[pos + 1] = '\0';
  char buffer2[60000];
  result = result + max_lcp;
  strncpy(buffer2, result, len1);
  buffer2[len1 - pos + max_lcp] = '\0';
  strcpy(str1, buffer1);
  strcat(str1, buffer2);
}


x86 assembly (clang, -O0):
<removeLCP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d4f0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x24(%rbp)
lea    -0xea90(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0x24(%rbp),%rax
movb   $0x23,-0xea90(%rbp,%rax,1)
23
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0xea90(%rbp,%rax,1)
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
lea    -0x1d4f0(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x14(%rbp),%eax
sub    -0x24(%rbp),%eax
add    -0x18(%rbp),%eax
cltq
movb   $0x0,-0x1d4f0(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
lea    -0xea90(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1d4f0(%rbp),%rsi
call   1050 <strcat@plt>
add    $0x1d4f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeLCP>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1d4c8,%rsp
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %rdi,%r13
call   1060 <strstr@plt>
mov    %rax,%rbx
mov    %rax,%rbp
sub    %r13,%rbp
mov    %rsp,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1030 <strncpy@plt>
movslq %ebp,%r14
movb   $0x23,(%rsp,%r14,1)
lea    0x1(%r14),%eax
cltq
movb   $0x0,(%rsp,%rax,1)
movslq %r15d,%rbp
add    %rbp,%rbx
lea    0xea60(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
add    %r12d,%ebp
sub    %r14d,%ebp
movslq %ebp,%rax
movb   $0x0,0xea60(%rsp,%rax,1)
mov    %r13,%rdi
mov    %rsp,%rsi
call   1040 <strcpy@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
add    $0x1d4c8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @removeLCP(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [60000 x i8]
%12 = alloca [60000 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = call i8* @strstr(i8* %13, i8* %14)
store i8* %15, i8** %9
%16 = load i8*, i8** %9
%17 = load i8*, i8** %5
%18 = ptrtoint i8* %16 to i64
%19 = ptrtoint i8* %17 to i64
%20 = sub i64 %18, %19
%21 = trunc i64 %20 to i32
store i32 %21, i32* %10
%22 = getelementptr inbounds [60000 x i8], [60000 x i8]* %11, i64 0, i64 0
%23 = load i8*, i8** %5
%24 = load i32, i32* %10
%25 = call i32 @strncpy(i8* %22, i8* %23, i32 %24)
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [60000 x i8], [60000 x i8]* %11, i64 0, i64 %27
store i8 35, i8* %28
%29 = load i32, i32* %10
%30 = add nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [60000 x i8], [60000 x i8]* %11, i64 0, i64 %31
store i8 0, i8* %32
%33 = load i8*, i8** %9
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8* %36, i8** %9
%37 = getelementptr inbounds [60000 x i8], [60000 x i8]* %12, i64 0, i64 0
%38 = load i8*, i8** %9
%39 = load i32, i32* %7
%40 = call i32 @strncpy(i8* %37, i8* %38, i32 %39)
%41 = load i32, i32* %7
%42 = load i32, i32* %10
%43 = sub nsw i32 %41, %42
%44 = load i32, i32* %8
%45 = add nsw i32 %43, %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [60000 x i8], [60000 x i8]* %12, i64 0, i64 %46
store i8 0, i8* %47
%48 = load i8*, i8** %5
%49 = getelementptr inbounds [60000 x i8], [60000 x i8]* %11, i64 0, i64 0
%50 = call i32 @strcpy(i8* %48, i8* %49)
%51 = load i8*, i8** %5
%52 = getelementptr inbounds [60000 x i8], [60000 x i8]* %12, i64 0, i64 0
%53 = call i32 @strcat(i8* %51, i8* %52)
ret void
}

LLVM IR (-O2):
define void @removeLCP(i8* %0, i8* nocapture %1, i32 %2, i32 %3) {
%5 = alloca [60000 x i8]
%6 = alloca [60000 x i8]
%7 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%8 = ptrtoint i8* %7 to i64
%9 = ptrtoint i8* %0 to i64
%10 = sub i64 %8, %9
%11 = trunc i64 %10 to i32
%12 = getelementptr inbounds [60000 x i8], [60000 x i8]* %5, i64 0, i64 0
%13 = call i32 @strncpy(i8* %12, i8* %0, i32 %11)
%14 = shl i64 %10, 32
%15 = ashr exact i64 %14, 32
%16 = getelementptr inbounds [60000 x i8], [60000 x i8]* %5, i64 0, i64 %15
store i8 35, i8* %16
%17 = add i64 %14, 4294967296
%18 = ashr exact i64 %17, 32
%19 = getelementptr inbounds [60000 x i8], [60000 x i8]* %5, i64 0, i64 %18
store i8 0, i8* %19
%20 = getelementptr inbounds [60000 x i8], [60000 x i8]* %6, i64 0, i64 0
%21 = sext i32 %3 to i64
%22 = getelementptr inbounds i8, i8* %7, i64 %21
%23 = call i32 @strncpy(i8* %20, i8* %22, i32 %2)
%24 = add i32 %3, %2
%25 = sub i32 %24, %11
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [60000 x i8], [60000 x i8]* %6, i64 0, i64 %26
store i8 0, i8* %27
%28 = call i32 @strcpy(i8* %0, i8* %12)
%29 = call i32 @strcat(i8* %0, i8* %20)
ret void
}