#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*/ myCopy(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void replaceStr(char *input, int so, int eo, char *repl) {
  char tmp[256];
  int l;
  myCopy(tmp, input + eo + 1, 256);
  l = strlen(repl);
  strncpy(input + so, repl, l);
  strcpy(input + so + l, tmp);
}


x86 assembly (clang, -O0):
<replaceStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rax
add    %rax,%rsi
add    $0x1,%rsi
mov    $0x100,%edx
call   1060 <myCopy@plt>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x124(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x124(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
movslq -0x124(%rbp),%rax
add    %rax,%rdi
lea    -0x120(%rbp),%rsi
call   1040 <strcpy@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<replaceStr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rcx,%r12
mov    %esi,%r14d
mov    %rdi,%r13
movslq %edx,%rax
lea    0x1(%rdi,%rax,1),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x100,%edx
call   1060 <myCopy@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
movslq %r14d,%rbp
add    %r13,%rbp
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
movslq %ebx,%rdi
add    %rbp,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @replaceStr(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [256 x i8]
%10 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%12 = load i8*, i8** %5
%13 = load i32, i32* %7
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = call i32 @myCopy(i8* %11, i8* %16, i32 256)
%18 = load i8*, i8** %8
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %10
%20 = load i8*, i8** %5
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8*, i8** %8
%25 = load i32, i32* %10
%26 = call i32 @strncpy(i8* %23, i8* %24, i32 %25)
%27 = load i8*, i8** %5
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%35 = call i32 @strcpy(i8* %33, i8* %34)
ret void
}

LLVM IR (-O2):
define void @replaceStr(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = sext i32 %2 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = call i32 @myCopy(i8* %6, i8* %9, i32 256)
%11 = call i32 @strlen(i8* %3)
%12 = sext i32 %1 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = call i32 @strncpy(i8* %13, i8* %3, i32 %11)
%15 = sext i32 %11 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = call i32 @strcpy(i8* %16, i8* %6)
ret void
}