#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);
int my_strcpy(char *origen, char *destino) {
  unsigned int indice = 0;
  while (*(origen + indice) != '\0') {
    printf("Copiando %c\n", *(origen + indice));
    *(destino + indice) = *(origen + indice);
    indice++;
  };
  *(destino + indice) = '\0';
  return 0;
}


x86 assembly (clang, -O0):
<my_strcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1174 <my_strcpy+0x64>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
lea    0xeb7(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <my_strcpy+0x17>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_strcpy>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    (%rdi),%al
xor    %ebx,%ebx
test   %al,%al
je     1152 <my_strcpy+0x42>
mov    %rdi,%r12
lea    0xed3(%rip),%r15
nopl   (%rax)
movsbl %al,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
movzbl (%r12,%rbx,1),%eax
mov    %al,(%r14,%rbx,1)
add    $0x1,%ebx
movzbl (%r12,%rbx,1),%eax
test   %al,%al
jne    1130 <my_strcpy+0x20>
mov    %ebx,%ebx
movb   $0x0,(%r14,%rbx,1)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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