#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 *, char);
void strcpy_my_2(char *dest, int pos) {
  int i = 0;
  extern char *arr2[10];
  extern int arr2_ptr;
  while (*(arr2[pos] + i) != '\0') {
    *(dest + i) = *(arr2[pos] + i);
    printf("* ( dest + i ) = * ( arr2 [ pos ] + i ) = %c;\n",
           *(dest + i) = *(arr2[pos] + i));
    i++;
  }
}


x86 assembly (clang, -O0):
<strcpy_my_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movslq -0xc(%rbp),%rcx
mov    0x2eb7(%rip),%rax
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11a5 <strcpy_my_2+0x95>
movslq -0xc(%rbp),%rcx
mov    0x2e97(%rip),%rax
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
movslq -0xc(%rbp),%rcx
mov    0x2e76(%rip),%rax
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rdx
mov    %al,(%rcx,%rdx,1)
lea    0xe71(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <strcpy_my_2+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcpy_my_2>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
movslq %esi,%r13
mov    0x2ec5(%rip),%r12
mov    (%r12,%r13,8),%rax
mov    (%rax),%al
test   %al,%al
je     1169 <strcpy_my_2+0x59>
mov    %rdi,%r15
xor    %ebx,%ebx
lea    0xec7(%rip),%r14
nopl   0x0(%rax)
mov    %al,(%r15,%rbx,1)
mov    (%r12,%r13,8),%rax
movsbl (%rax,%rbx,1),%esi
mov    %sil,(%r15,%rbx,1)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%r12,%r13,8),%rax
movzbl 0x1(%rax,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <strcpy_my_2+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@arr2 = external global [10 x i8*]
@.str = [47 x i8] c"* ( dest + i ) = * ( arr2 [ pos ] + i ) = %c;\0A\00"
define void @strcpy_my_2(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %17, %2
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [10 x i8*], [10 x i8*]* @arr2, i64 0, i64 %8
%10 = load i8*, i8** %9
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %45
17: ; preds = %6
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [10 x i8*], [10 x i8*]* @arr2, i64 0, i64 %19
%21 = load i8*, i8** %20
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = load i8*, i8** %3
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 %25, i8* %29
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [10 x i8*], [10 x i8*]* @arr2, i64 0, i64 %31
%33 = load i8*, i8** %32
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = load i8*, i8** %3
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 %37, i8* %41
%42 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8 signext %37)
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %6
45: ; preds = %6
ret void
}

LLVM IR (-O2):
@arr2 = external global [10 x i8*]
@.str = [47 x i8] c"* ( dest + i ) = * ( arr2 [ pos ] + i ) = %c;\0A\00"
define void @strcpy_my_2(i8* nocapture writeonly %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds [10 x i8*], [10 x i8*]* @arr2, i64 0, i64 %3
%5 = load i8*, i8** %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %21, label %8
8: ; preds = %2, %8
%9 = phi i64 [ %16, %8 ], [ 0, %2 ]
%10 = phi i8 [ %19, %8 ], [ %6, %2 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %9
store i8 %10, i8* %11
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 %9
%14 = load i8, i8* %13
store i8 %14, i8* %11
%15 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8 signext %14)
%16 = add nuw i64 %9, 1
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 %16
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %8
21: ; preds = %8, %2
ret void
}