#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 strlen(char *);
char *strstr(char *, char *);
void insert_str(char *object_str, char *mtc_str, char *insert_str) {
  char *s1;
  char ending[80];
  s1 = strstr(object_str, mtc_str);
  if (s1 != NULL) {
    strcpy(ending, s1 + strlen(mtc_str));
    strcpy(s1, insert_str);
    strcat(s1, ending);
  }
}


x86 assembly (clang, -O0):
<insert_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11b8 <insert_str+0x78>
lea    -0x70(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x80(%rbp),%rsi
mov    -0x78(%rbp),%rdi
cltq
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1050 <strcat@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert_str>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
call   1060 <strstr@plt>
test   %rax,%rax
je     118b <insert_str+0x4b>
mov    %rax,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
movslq %eax,%rsi
add    %rbx,%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @insert_str(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [80 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = call i8* @strstr(i8* %9, i8* %10)
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %28
14: ; preds = %3
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%16 = load i8*, i8** %7
%17 = load i8*, i8** %5
%18 = call i32 @strlen(i8* %17)
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
%21 = call i32 @strcpy(i8* %15, i8* %20)
%22 = load i8*, i8** %7
%23 = load i8*, i8** %6
%24 = call i32 @strcpy(i8* %22, i8* %23)
%25 = load i8*, i8** %7
%26 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%27 = call i32 @strcat(i8* %25, i8* %26)
br label %28
28: ; preds = %14, %3
ret void
}

LLVM IR (-O2):
define void @insert_str(i8* %0, i8* %1, i8* %2) {
%4 = alloca [80 x i8]
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%6 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%7 = icmp eq i8* %6, null
br i1 %7, label %15, label %8
8: ; preds = %3
%9 = tail call i32 @strlen(i8* %1)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %6, i64 %10
%12 = call i32 @strcpy(i8* %5, i8* %11)
%13 = call i32 @strcpy(i8* %6, i8* %2)
%14 = call i32 @strcat(i8* %6, i8* %5)
br label %15
15: ; preds = %8, %3
ret void
}