#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 *s, char *argv) {
  char exit = 0;
  printf("\n");
  while (exit == 0) {
    printf("( * s = * t ) = '%c'; * t = '%c';\n", (*s = *argv), *argv);
    *s++ = *argv++;
    if (*argv == '\0') {
      *s++ = *argv++;
      exit = 1;
    }
  };
}


x86 assembly (clang, -O0):
<strcpy_my>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
lea    0xef6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jne    11c0 <strcpy_my+0xb0>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    -0x8(%rbp),%rcx
mov    %al,(%rcx)
movsbl %al,%esi
mov    -0x10(%rbp),%rax
movsbl (%rax),%edx
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11bb <strcpy_my+0xab>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
movb   $0x1,-0x11(%rbp)
jmp    1132 <strcpy_my+0x22>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcpy_my>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xec1(%rip),%r15
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rax,%rbx
movsbl (%r12,%rax,1),%esi
mov    %sil,(%r14,%rax,1)
movsbl (%r12,%rax,1),%edx
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%r12,%rbx,1),%eax
mov    %al,(%r14,%rbx,1)
lea    0x1(%rbx),%rax
cmpb   $0x0,0x1(%r12,%rbx,1)
jne    1150 <strcpy_my+0x30>
movb   $0x0,(%r14,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str.1 = [35 x i8] c"( * s = * t ) = '%c'; * t = '%c';\0A\00"
define void @strcpy_my(i8* nocapture writeonly %0, i8* nocapture %1) {
%3 = tail call i32 @putchar(i32 10)
br label %4
4: ; preds = %4, %2
%5 = phi i8* [ %1, %2 ], [ %12, %4 ]
%6 = phi i8* [ %0, %2 ], [ %14, %4 ]
%7 = load i8, i8* %5
store i8 %7, i8* %6
%8 = sext i8 %7 to i32
%9 = load i8, i8* %5
%10 = sext i8 %9 to i32
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %10)
%12 = getelementptr inbounds i8, i8* %5, i64 1
%13 = load i8, i8* %5
%14 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %13, i8* %6
%15 = load i8, i8* %12
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %4
17: ; preds = %4
store i8 0, i8* %14
ret void
}