#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*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ mymemcpy1(char *, char *, int);
int /*<<< orphan*/ mymemcpy2(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char buf[16] = "abcdefghijk";
  char buf1[16] = "abcdefghijk";
  char buf2[16] = "abcdefghijk";
  char buf3[16] = "abcdefghijk";
  memcpy(buf + 2, buf, 5);
  memmove(buf1 + 2, buf1, 5);
  mymemcpy1(buf2 + 2, buf2, 5);
  mymemcpy2(buf3 + 2, buf3, 5);
  printf(" end of memcpy(buf +2,buf,5), buf is :%s\n", buf);
  printf(" end of memmove(buf1 +2,buf1,5), buf1 is :%s\n", buf1);
  printf(" end of mymemcpy1(buf2 +2,buf2,5), buf2 is :%s\n", buf2);
  printf(" end of mymemcpy2(buf3 +2,buf3,5), buf3 is :%s\n", buf3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe84(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe81(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe6e(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe6b(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe58(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe55(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    -0x20(%rbp),%rdi
add    $0x2,%rdi
lea    -0x20(%rbp),%rsi
mov    $0x5,%edx
call   1050 <memcpy@plt>
lea    -0x30(%rbp),%rdi
add    $0x2,%rdi
lea    -0x30(%rbp),%rsi
mov    $0x5,%edx
call   1070 <memmove@plt>
lea    -0x40(%rbp),%rdi
add    $0x2,%rdi
lea    -0x40(%rbp),%rsi
mov    $0x5,%edx
call   1060 <mymemcpy1@plt>
lea    -0x50(%rbp),%rdi
add    $0x2,%rdi
lea    -0x50(%rbp),%rsi
mov    $0x5,%edx
call   1030 <mymemcpy2@plt>
lea    -0x20(%rbp),%rsi
lea    0xdf6(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe10(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
lea    -0x50(%rbp),%rsi
lea    0xe4e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
movaps 0xe9e(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0x32(%rsp),%rdi
lea    0x30(%rsp),%r14
mov    %r14,%rsi
mov    $0x5,%edx
call   1050 <memcpy@plt>
lea    0x22(%rsp),%rdi
lea    0x20(%rsp),%r15
mov    %r15,%rsi
mov    $0x5,%edx
call   1070 <memmove@plt>
lea    0x12(%rsp),%rdi
lea    0x10(%rsp),%r12
mov    %r12,%rsi
mov    $0x5,%edx
call   1060 <mymemcpy1@plt>
lea    0x2(%rsp),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0x5,%edx
call   1030 <mymemcpy2@plt>
lea    0xe3a(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
lea    0xe55(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
lea    0xe74(%rip),%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
lea    0xe95(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.buf = [16 x i8] c"abcdefghijk\00\00\00\00\00"
@__const.main.buf1 = [16 x i8] c"abcdefghijk\00\00\00\00\00"
@__const.main.buf2 = [16 x i8] c"abcdefghijk\00\00\00\00\00"
@__const.main.buf3 = [16 x i8] c"abcdefghijk\00\00\00\00\00"
@.str = [42 x i8] c" end of memcpy(buf +2,buf,5), buf is :%s\0A\00"
@.str.1 = [46 x i8] c" end of memmove(buf1 +2,buf1,5), buf1 is :%s\0A\00"
@.str.2 = [48 x i8] c" end of mymemcpy1(buf2 +2,buf2,5), buf2 is :%s\0A\00"
@.str.3 = [48 x i8] c" end of mymemcpy2(buf3 +2,buf3,5), buf3 is :%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = alloca [16 x i8]
%4 = alloca [16 x i8]
%5 = alloca [16 x i8]
store i32 0, i32* %1
%6 = bitcast [16 x i8]* %2 to i8*
%7 = bitcast [16 x i8]* %3 to i8*
%8 = bitcast [16 x i8]* %4 to i8*
%9 = bitcast [16 x i8]* %5 to i8*
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds i8, i8* %10, i64 2
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%13 = call i32 @memcpy(i8* %11, i8* %12, i32 5)
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds i8, i8* %14, i64 2
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%17 = call i32 @memmove(i8* %15, i8* %16, i32 5)
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%19 = getelementptr inbounds i8, i8* %18, i64 2
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%21 = call i32 @mymemcpy1(i8* %19, i8* %20, i32 5)
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%23 = getelementptr inbounds i8, i8* %22, i64 2
%24 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%25 = call i32 @mymemcpy2(i8* %23, i8* %24, i32 5)
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%27 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%29 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%31 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %32)
ret i32 0
}

LLVM IR (-O2):
@__const.main.buf3 = [16 x i8] c"abcdefghijk\00\00\00\00\00"
@.str = [42 x i8] c" end of memcpy(buf +2,buf,5), buf is :%s\0A\00"
@.str.1 = [46 x i8] c" end of memmove(buf1 +2,buf1,5), buf1 is :%s\0A\00"
@.str.2 = [48 x i8] c" end of mymemcpy1(buf2 +2,buf2,5), buf2 is :%s\0A\00"
@.str.3 = [48 x i8] c" end of mymemcpy2(buf3 +2,buf3,5), buf3 is :%s\0A\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = alloca [16 x i8]
%3 = alloca [16 x i8]
%4 = alloca [16 x i8]
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 2
%10 = call i32 @memcpy(i8* %9, i8* %5, i32 5)
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 2
%12 = call i32 @memmove(i8* %11, i8* %6, i32 5)
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 2
%14 = call i32 @mymemcpy1(i8* %13, i8* %7, i32 5)
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 2
%16 = call i32 @mymemcpy2(i8* %15, i8* %8, i32 5)
%17 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %5)
%18 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%19 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%20 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %8)
ret i32 0
}