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


x86 assembly (clang, -O0):
<strcpy_my_3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x4(%rbp),%esi
movslq -0x4(%rbp),%rcx
mov    0x2eb4(%rip),%rax
mov    (%rax,%rcx,8),%rdx
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11b6 <strcpy_my_3+0xa6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
movslq -0x4(%rbp),%rcx
mov    0x2e4b(%rip),%rax
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1158 <strcpy_my_3+0x48>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcpy_my_3>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r13
movslq %edi,%r14
mov    0x2ec2(%rip),%r12
mov    (%r12,%r14,8),%rdx
lea    0xecf(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x0(%r13),%al
test   %al,%al
je     1188 <strcpy_my_3+0x78>
lea    0xeee(%rip),%r15
xor    %ebx,%ebx
nopl   (%rax)
movsbl %al,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0x0(%r13,%rbx,1),%eax
mov    (%r12,%r14,8),%rcx
mov    %al,(%rcx,%rbx,1)
movzbl 0x1(%r13,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <strcpy_my_3+0x50>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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