int main(void) {
  char test1[] = "yuzhihui";
  char test2[1024] = {};
  char test3[1024] = {};
  my_memory(test2, test1, sizeof(test1));
  MyMemcpy(test3, test1, sizeof(test1));
  printf("test1:%s\n", test1);
  printf("test2:%s\n", test2);
  printf("test3:%s\n", test3);
  int t1 = 100;
  int t2 = 0;
  int t3 = 0;
  my_memory(&t2, &t1, sizeof(t1));
  MyMemcpy(&t3, &t1, sizeof(t1));
  printf("t1:%d\n", t1);
  printf("t2:%d\n", t2);
  printf("t3:%d\n", t3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0xd(%rbp)
mov    0xea5(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x410(%rbp),%rdi
lea    -0xd(%rbp),%rsi
mov    $0x9,%edx
mov    $0x0,%al
call   1030 <my_memory@plt>
lea    -0x810(%rbp),%rdi
lea    -0xd(%rbp),%rsi
mov    $0x9,%edx
mov    $0x0,%al
call   1060 <MyMemcpy@plt>
lea    -0xd(%rbp),%rsi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x410(%rbp),%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x810(%rbp),%rsi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x64,-0x814(%rbp)
movl   $0x0,-0x818(%rbp)
movl   $0x0,-0x81c(%rbp)
lea    -0x818(%rbp),%rdi
lea    -0x814(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <my_memory@plt>
lea    -0x81c(%rbp),%rdi
lea    -0x814(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1060 <MyMemcpy@plt>
mov    -0x814(%rbp),%esi
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x818(%rbp),%esi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x81c(%rbp),%esi
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x820,%rsp
movabs $0x69756869687a7579,%rax
68 75 69
mov    %rax,0x10(%rsp)
movb   $0x0,0x18(%rsp)
lea    0x420(%rsp),%r14
mov    $0x400,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0x20(%rsp),%r15
mov    $0x400,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0x10(%rsp),%rbx
mov    $0x9,%edx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <my_memory@plt>
mov    $0x9,%edx
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <MyMemcpy@plt>
lea    0xe4e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe47(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe40(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x64,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rbx
mov    $0x4,%edx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <my_memory@plt>
lea    0x4(%rsp),%rdi
mov    $0x4,%edx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <MyMemcpy@plt>
mov    0xc(%rsp),%esi
lea    0xdf0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xde5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xdda(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.test1 = [9 x i8] c"yuzhihui\00"
@.str = [10 x i8] c"test1:%s\0A\00"
@.str.1 = [10 x i8] c"test2:%s\0A\00"
@.str.2 = [10 x i8] c"test3:%s\0A\00"
@.str.3 = [7 x i8] c"t1:%d\0A\00"
@.str.4 = [7 x i8] c"t2:%d\0A\00"
@.str.5 = [7 x i8] c"t3:%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i8]
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [9 x i8]* %2 to i8*
%9 = bitcast [1024 x i8]* %3 to i8*
%10 = bitcast [1024 x i8]* %4 to i8*
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%13 = call i32 (i8*, i8*, i64, ...) bitcast (i32 (...)* @my_memory to i32 (i8*, i8*, i64, ...)*)(i8* %11, i8* %12, i64 9)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%16 = call i32 (i8*, i8*, i64, ...) bitcast (i32 (...)* @MyMemcpy to i32 (i8*, i8*, i64, ...)*)(i8* %14, i8* %15, i64 9)
%17 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %21)
store i32 100, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%23 = call i32 (i32*, i32*, i64, ...) bitcast (i32 (...)* @my_memory to i32 (i32*, i32*, i64, ...)*)(i32* %6, i32* %5, i64 4)
%24 = call i32 (i32*, i32*, i64, ...) bitcast (i32 (...)* @MyMemcpy to i32 (i32*, i32*, i64, ...)*)(i32* %7, i32* %5, i64 4)
%25 = load i32, i32* %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %6
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %7
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %29)
ret i32 0
}

LLVM IR (-O2):
@__const.main.test1 = [9 x i8] c"yuzhihui\00"
@.str = [10 x i8] c"test1:%s\0A\00"
@.str.1 = [10 x i8] c"test2:%s\0A\00"
@.str.2 = [10 x i8] c"test3:%s\0A\00"
@.str.3 = [7 x i8] c"t1:%d\0A\00"
@.str.4 = [7 x i8] c"t2:%d\0A\00"
@.str.5 = [7 x i8] c"t3:%d\0A\00"
define i32 @main() {
%1 = alloca [9 x i8]
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%10 = call i32 (i8*, i8*, i64, ...) bitcast (i32 (...)* @my_memory to i32 (i8*, i8*, i64, ...)*)(i8* %8, i8* %7, i64 9)
%11 = call i32 (i8*, i8*, i64, ...) bitcast (i32 (...)* @MyMemcpy to i32 (i8*, i8*, i64, ...)*)(i8* %9, i8* %7, i64 9)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %7)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%15 = bitcast i32* %4 to i8*
store i32 100, i32* %4
%16 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%17 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%18 = call i32 (i32*, i32*, i64, ...) bitcast (i32 (...)* @my_memory to i32 (i32*, i32*, i64, ...)*)(i32* %5, i32* %4, i64 4)
%19 = call i32 (i32*, i32*, i64, ...) bitcast (i32 (...)* @MyMemcpy to i32 (i32*, i32*, i64, ...)*)(i32* %6, i32* %4, i64 4)
%20 = load i32, i32* %4
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %5
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %6
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %24)
ret i32 0
}