#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 my_strcpy4(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ system(char *);
int main(void) {
  char src[] = "abcedfdgds";
  char dst[100] = {0};
  int ret = 0;
  ret = my_strcpy4(dst, src);
  if (ret != 0) {
    printf("my_strcpy4 err:%d\n", ret);
    return ret;
  }
  printf("%s\n", dst);
  printf("\n");
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0xf(%rbp)
mov    0xea4(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xe9c(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1060 <memset@plt>
movl   $0x0,-0x84(%rbp)
lea    -0x80(%rbp),%rdi
lea    -0xf(%rbp),%rsi
call   1030 <my_strcpy4@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
je     11cd <main+0x8d>
mov    -0x84(%rbp),%esi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x84(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1200 <main+0xc0>
lea    -0x80(%rbp),%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe2e(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
movabs $0x6764666465636261,%rax
66 64 67
mov    %rax,(%rsp)
movl   $0x736467,0x7(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <my_strcpy4@plt>
mov    %eax,%ebx
test   %eax,%eax
je     11bc <main+0x6c>
lea    0xe5a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    11dc <main+0x8c>
lea    0x10(%rsp),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xe47(%rip),%rdi
call   1060 <system@plt>
mov    %ebx,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.src = [11 x i8] c"abcedfdgds\00"
@.str = [19 x i8] c"my_strcpy4 err:%d\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [11 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [11 x i8]* %2 to i8*
%6 = bitcast [100 x i8]* %3 to i8*
store i32 0, i32* %4
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%9 = call i32 @my_strcpy4(i8* %7, i8* %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %0
%13 = load i32, i32* %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %4
store i32 %15, i32* %1
br label %21
16: ; preds = %0
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %21
21: ; preds = %16, %12
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@__const.main.src = [11 x i8] c"abcedfdgds\00"
@.str = [19 x i8] c"my_strcpy4 err:%d\0A\00"
@.str.3 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca [11 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 @my_strcpy4(i8* %4, i8* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %13
9: ; preds = %0
%10 = call i32 @puts(i8* %4)
%11 = call i32 @putchar(i32 10)
%12 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %9, %7
ret i32 %5
}