#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*/ printf(char *, ...);
void strcpy_my(char *dest, char source[10]) {
  short int i = 0;
  extern char *arr2[10];
  extern int arr2_ptr;
  dest = source;
  printf("dest = '%p';\n", dest);
  i = 0;
  while (*dest != '\0' && i < 10) {
    printf("* ( dest + %d ) = '%c';\n", i, *(dest + i));
    i++;
  }
  printf("dest string:'%s';\n", dest);
}


x86 assembly (clang, -O0):
<strcpy_my>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movw   $0x0,-0x12(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movw   $0x0,-0x12(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x13(%rbp)
je     1168 <strcpy_my+0x58>
movswl -0x12(%rbp),%eax
cmp    $0xa,%eax
setl   %al
mov    %al,-0x13(%rbp)
mov    -0x13(%rbp),%al
test   $0x1,%al
jne    1178 <strcpy_my+0x68>
jmp    11aa <strcpy_my+0x9a>
movswl -0x12(%rbp),%esi
mov    -0x8(%rbp),%rax
movswl -0x12(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    1146 <strcpy_my+0x36>
mov    -0x8(%rbp),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcpy_my>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
lea    0xee1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movsbl (%r15),%edx
test   %edx,%edx
je     1174 <strcpy_my+0x64>
lea    0xed9(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmpb   $0x0,(%r15)
je     1174 <strcpy_my+0x64>
mov    $0x1,%ebx
lea    0xebe(%rip),%r14
movsbl (%r15,%rbx,1),%edx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmpb   $0x0,(%r15)
je     1174 <strcpy_my+0x64>
lea    0x1(%rbx),%rax
cmp    $0x9,%rbx
mov    %rax,%rbx
jb     1150 <strcpy_my+0x40>
lea    0xeac(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"dest = '%p';\0A\00"
@.str.1 = [25 x i8] c"* ( dest + %d ) = '%c';\0A\00"
@.str.2 = [19 x i8] c"dest string:'%s';\0A\00"
define void @strcpy_my(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i16
store i8* %0, i8** %3
store i8* %1, i8** %4
store i16 0, i16* %5
%6 = load i8*, i8** %4
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %7)
store i16 0, i16* %5
br label %9
9: ; preds = %20, %2
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i16, i16* %5
%16 = sext i16 %15 to i32
%17 = icmp slt i32 %16, 10
br label %18
18: ; preds = %14, %9
%19 = phi i1 [ false, %9 ], [ %17, %14 ]
br i1 %19, label %20, label %33
20: ; preds = %18
%21 = load i16, i16* %5
%22 = sext i16 %21 to i32
%23 = load i8*, i8** %3
%24 = load i16, i16* %5
%25 = sext i16 %24 to i32
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %29)
%31 = load i16, i16* %5
%32 = add i16 %31, 1
store i16 %32, i16* %5
br label %9
33: ; preds = %18
%34 = load i8*, i8** %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %34)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"dest = '%p';\0A\00"
@.str.1 = [25 x i8] c"* ( dest + %d ) = '%c';\0A\00"
@.str.2 = [19 x i8] c"dest string:'%s';\0A\00"
define void @strcpy_my(i8* nocapture readnone %0, i8* %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %1)
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 0
br i1 %5, label %23, label %6
6: ; preds = %2
%7 = sext i8 %4 to i32
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %7)
%9 = load i8, i8* %1
%10 = icmp eq i8 %9, 0
br i1 %10, label %23, label %11
11: ; preds = %6, %11
%12 = phi i64 [ %18, %11 ], [ 1, %6 ]
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = load i8, i8* %13
%15 = trunc i64 %12 to i32
%16 = sext i8 %14 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %16)
%18 = add nuw nsw i64 %12, 1
%19 = load i8, i8* %1
%20 = icmp ne i8 %19, 0
%21 = icmp ult i64 %12, 9
%22 = select i1 %20, i1 %21, i1 false
br i1 %22, label %11, label %23
23: ; preds = %11, %6, %2
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %1)
ret void
}