int main(int argc, char **argv) {
  char src[] = "123456789abcdef";
  char *dst;
  int offset;
  int size;
  printf("My Source String Data %s, Length %d\n", src, strlen(src));
  printf("Please select the destination offset within 0 & %d\n", strlen(src));
  scanf("%d", &offset);
  printf("Please select the number of bytes to move within 0 & %d\n",
         strlen(src) - offset);
  scanf("%d", &size);
  dst = my_memmove(&(src[0]) + offset, src, size);
  printf("memmoved: Dst %p Src %p\n", dst, src);
  printf("My Source String Data %s\n", src);
  printf("My Destination String Data %s\n", dst);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rsi
mov    %rax,%rdx
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rsi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
lea    -0x2c(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rsi
movslq -0x2c(%rbp),%rax
sub    %rax,%rsi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8a(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x20(%rbp),%rdi
movslq -0x2c(%rbp),%rax
add    %rax,%rdi
lea    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%edx
mov    $0x0,%al
call   1060 <my_memmove@plt>
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
lea    0xea7(%rip),%rdi
mov    %r15,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
lea    0xeb0(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed3(%rip),%r14
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
movslq 0x8(%rsp),%rcx
sub    %rcx,%rax
lea    0xeb0(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
movslq 0x8(%rsp),%rax
lea    (%rsp,%rax,1),%rdi
add    $0x10,%rdi
mov    0xc(%rsp),%edx
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <my_memmove@plt>
movslq %eax,%rbx
lea    0xeab(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.src = [16 x i8] c"123456789abcdef\00"
@.str = [37 x i8] c"My Source String Data %s, Length %d\0A\00"
@.str.1 = [52 x i8] c"Please select the destination offset within 0 & %d\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [57 x i8] c"Please select the number of bytes to move within 0 & %d\0A\00"
@.str.4 = [25 x i8] c"memmoved: Dst %p Src %p\0A\00"
@.str.5 = [26 x i8] c"My Source String Data %s\0A\00"
@.str.6 = [31 x i8] c"My Destination String Data %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [16 x i8]
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = bitcast [16 x i8]* %5 to i8*
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%12 = call i64 @strlen(i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %10, i64 %12)
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%15 = call i64 @strlen(i8* %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i64 %15)
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%19 = call i64 @strlen(i8* %18)
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = sub i64 %19, %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0), i64 %22)
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%25 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%30 = load i32, i32* %8
%31 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @my_memmove to i32 (i8*, i8*, i32, ...)*)(i8* %28, i8* %29, i32 %30)
%32 = sext i32 %31 to i64
%33 = inttoptr i64 %32 to i8*
store i8* %33, i8** %6
%34 = load i8*, i8** %6
%35 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %34, i8* %35)
%37 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %37)
%39 = load i8*, i8** %6
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %39)
ret i32 0
}

LLVM IR (-O2):
@__const.main.src = [16 x i8] c"123456789abcdef\00"
@.str = [37 x i8] c"My Source String Data %s, Length %d\0A\00"
@.str.1 = [52 x i8] c"Please select the destination offset within 0 & %d\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [57 x i8] c"Please select the number of bytes to move within 0 & %d\0A\00"
@.str.4 = [25 x i8] c"memmoved: Dst %p Src %p\0A\00"
@.str.5 = [26 x i8] c"My Source String Data %s\0A\00"
@.str.6 = [31 x i8] c"My Destination String Data %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [16 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = call i64 @strlen(i8* %6)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %6, i64 %9)
%11 = call i64 @strlen(i8* %6)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i64 %11)
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%14 = call i64 @strlen(i8* %6)
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = sub i64 %14, %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0), i64 %17)
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %21
%23 = load i32, i32* %5
%24 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @my_memmove to i32 (i8*, i8*, i32, ...)*)(i8* %22, i8* %6, i32 %23)
%25 = sext i32 %24 to i64
%26 = inttoptr i64 %25 to i8*
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %26, i8* %6)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %6)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %26)
ret i32 0
}