int main() {
  printf("Found1 at %i\n", findString("chatterbox", "hat"));
  printf("Found2 at %i\n", findString("chatterbox", "att"));
  printf("Found3 at %i\n", findString("chatterbox", "box"));
  printf("Found4 at %i\n", findString("chatterbox", "boxx"));
  char str3[20] = "chatterbox";
  removeString(str3, 9, 1);
  printf("\nAfter remove1 = %s\n", str3);
  char str4[20] = "chatterbox";
  removeString(str4, 9, 2);
  printf("After remove2 = %s\n", str4);
  char str5[20] = "chatterbox";
  removeString(str5, 0, 9);
  printf("After remove3 = %s\n", str5);
  char str8[20] = "the wrong son";
  insertString(str8, "per", 14);
  printf("\nAfter insert1  = %s\n", str8);
  insertString(str8, "per", 10);
  printf("After insert2  = %s\n", str8);
  insertString(str8, "You are ", 0);
  printf("After insert3  = %s\n\n", str8);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb5(%rip),%rdi
lea    0xeb9(%rip),%rsi
mov    $0x0,%al
call   1040 <findString@plt>
mov    %eax,%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe90(%rip),%rdi
lea    0xea6(%rip),%rsi
mov    $0x0,%al
call   1040 <findString@plt>
mov    %eax,%esi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
lea    0xe6b(%rip),%rsi
mov    $0x0,%al
call   1040 <findString@plt>
mov    %eax,%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe46(%rip),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1040 <findString@plt>
mov    %eax,%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xef3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xef0(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeee(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    $0x0,%al
call   1060 <removeString@plt>
lea    -0x20(%rbp),%rsi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xecd(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xec8(%rip),%eax
mov    %eax,-0x30(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0x9,%esi
mov    $0x2,%edx
mov    $0x0,%al
call   1060 <removeString@plt>
lea    -0x40(%rbp),%rsi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xea7(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xea4(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xea2(%rip),%eax
mov    %eax,-0x50(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x9,%edx
mov    $0x0,%al
call   1060 <removeString@plt>
lea    -0x60(%rbp),%rsi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xe84(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xe81(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xe7f(%rip),%eax
mov    %eax,-0x70(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xdae(%rip),%rsi
mov    $0xe,%edx
mov    $0x0,%al
call   1050 <insertString@plt>
lea    -0x80(%rbp),%rsi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    0xd85(%rip),%rsi
mov    $0xa,%edx
mov    $0x0,%al
call   1050 <insertString@plt>
lea    -0x80(%rbp),%rsi
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    0xd8b(%rip),%rsi
xor    %edx,%edx
mov    $0x0,%al
call   1050 <insertString@plt>
lea    -0x80(%rbp),%rsi
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
lea    0xec0(%rip),%rbx
lea    0xec4(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <findString@plt>
lea    0xe9a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <findString@plt>
lea    0xe96(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <findString@plt>
lea    0xe87(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe93(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <findString@plt>
lea    0xe74(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movaps 0xf07(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movl   $0x0,0x70(%rsp)
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1060 <removeString@plt>
lea    0xe4a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movl   $0x0,0x50(%rsp)
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1060 <removeString@plt>
lea    0xe21(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movaps 0xe8b(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x30(%rsp)
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x9,%edx
xor    %eax,%eax
call   1060 <removeString@plt>
lea    0xdfa(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movaps 0xe70(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xdea(%rip),%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xe,%edx
xor    %eax,%eax
call   1050 <insertString@plt>
lea    0xdd2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
xor    %eax,%eax
call   1050 <insertString@plt>
lea    0xdc5(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdc9(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <insertString@plt>
lea    0xdbf(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Found1 at %i\0A\00"
@.str.1 = [11 x i8] c"chatterbox\00"
@.str.2 = [4 x i8] c"hat\00"
@.str.3 = [14 x i8] c"Found2 at %i\0A\00"
@.str.4 = [4 x i8] c"att\00"
@.str.5 = [14 x i8] c"Found3 at %i\0A\00"
@.str.6 = [4 x i8] c"box\00"
@.str.7 = [14 x i8] c"Found4 at %i\0A\00"
@.str.8 = [5 x i8] c"boxx\00"
@__const.main.str3 = [20 x i8] c"chatterbox\00\00\00\00\00\00\00\00\00\00"
@.str.9 = [21 x i8] c"\0AAfter remove1 = %s\0A\00"
@__const.main.str4 = [20 x i8] c"chatterbox\00\00\00\00\00\00\00\00\00\00"
@.str.10 = [20 x i8] c"After remove2 = %s\0A\00"
@__const.main.str5 = [20 x i8] c"chatterbox\00\00\00\00\00\00\00\00\00\00"
@.str.11 = [20 x i8] c"After remove3 = %s\0A\00"
@__const.main.str8 = [20 x i8] c"the wrong son\00\00\00\00\00\00\00"
@.str.12 = [4 x i8] c"per\00"
@.str.13 = [22 x i8] c"\0AAfter insert1 = %s\0A\00"
@.str.14 = [21 x i8] c"After insert2 = %s\0A\00"
@.str.15 = [9 x i8] c"You are \00"
@.str.16 = [22 x i8] c"After insert3 = %s\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = alloca [20 x i8]
%5 = alloca [20 x i8]
store i32 0, i32* %1
%6 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @findString to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @findString to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%10 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @findString to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %10)
%12 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @findString to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %12)
%14 = bitcast [20 x i8]* %2 to i8*
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%16 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @removeString to i32 (i8*, i32, i32, ...)*)(i8* %15, i32 9, i32 1)
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i8* %17)
%19 = bitcast [20 x i8]* %3 to i8*
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%21 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @removeString to i32 (i8*, i32, i32, ...)*)(i8* %20, i32 9, i32 2)
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i8* %22)
%24 = bitcast [20 x i8]* %4 to i8*
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%26 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @removeString to i32 (i8*, i32, i32, ...)*)(i8* %25, i32 0, i32 9)
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i8* %27)
%29 = bitcast [20 x i8]* %5 to i8*
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%31 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @insertString to i32 (i8*, i8*, i32, ...)*)(i8* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i32 14)
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i8* %32)
%34 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%35 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @insertString to i32 (i8*, i8*, i32, ...)*)(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i32 10)
%36 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.14, i64 0, i64 0), i8* %36)
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%39 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @insertString to i32 (i8*, i8*, i32, ...)*)(i8* %38, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i64 0, i64 0), i32 0)
%40 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.16, i64 0, i64 0), i8* %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"Found1 at %i\0A\00"
@.str.1 = [11 x i8] c"chatterbox\00"
@.str.2 = [4 x i8] c"hat\00"
@.str.3 = [14 x i8] c"Found2 at %i\0A\00"
@.str.4 = [4 x i8] c"att\00"
@.str.5 = [14 x i8] c"Found3 at %i\0A\00"
@.str.6 = [4 x i8] c"box\00"
@.str.7 = [14 x i8] c"Found4 at %i\0A\00"
@.str.8 = [5 x i8] c"boxx\00"
@.str.9 = [21 x i8] c"\0AAfter remove1 = %s\0A\00"
@.str.10 = [20 x i8] c"After remove2 = %s\0A\00"
@__const.main.str5 = [20 x i8] c"chatterbox\00\00\00\00\00\00\00\00\00\00"
@.str.11 = [20 x i8] c"After remove3 = %s\0A\00"
@__const.main.str8 = [20 x i8] c"the wrong son\00\00\00\00\00\00\00"
@.str.12 = [4 x i8] c"per\00"
@.str.13 = [22 x i8] c"\0AAfter insert1 = %s\0A\00"
@.str.14 = [21 x i8] c"After insert2 = %s\0A\00"
@.str.15 = [9 x i8] c"You are \00"
@.str.16 = [22 x i8] c"After insert3 = %s\0A\0A\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = alloca [20 x i8]
%5 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @findString to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @findString to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @findString to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %9)
%11 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @findString to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%14 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @removeString to i32 (i8*, i32, i32, ...)*)(i8* %13, i32 9, i32 1)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i8* %13)
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%17 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @removeString to i32 (i8*, i32, i32, ...)*)(i8* %16, i32 9, i32 2)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i8* %16)
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%20 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @removeString to i32 (i8*, i32, i32, ...)*)(i8* %19, i32 0, i32 9)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i8* %19)
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%23 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @insertString to i32 (i8*, i8*, i32, ...)*)(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i32 14)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i8* %22)
%25 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @insertString to i32 (i8*, i8*, i32, ...)*)(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i32 10)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.14, i64 0, i64 0), i8* %22)
%27 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @insertString to i32 (i8*, i8*, i32, ...)*)(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i64 0, i64 0), i32 0)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.16, i64 0, i64 0), i8* %22)
ret i32 0
}