#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*/ memset(char *, char, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
char *strcpy(char *strDest, const char *strSrc) {
  if (strDest == strSrc)
    return strDest;
  char *tmpStr = strDest;
  memset(strDest, '\0', strlen(strDest));
  for (unsigned int i = 0; *(strSrc + i) != '\0'; i++)
    *(strDest + i) = *(strSrc + i);
  return tmpStr;
}


x86 assembly (clang, -O0):
<strcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    114b <strcpy+0x2b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b6 <strcpy+0x96>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11ae <strcpy+0x8e>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1178 <strcpy+0x58>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcpy>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
cmp    %rsi,%rdi
je     1171 <strcpy+0x51>
mov    %rsi,%r14
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1040 <memset@plt>
mov    (%r14),%al
test   %al,%al
je     1171 <strcpy+0x51>
mov    $0x1,%ecx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %al,(%rbx,%rdx,1)
mov    %ecx,%edx
movzbl (%r14,%rdx,1),%eax
add    $0x1,%ecx
test   %al,%al
jne    1160 <strcpy+0x40>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @strcpy(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = icmp eq i8* %8, %9
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i8*, i8** %4
store i8* %12, i8** %3
br label %42
13: ; preds = %2
%14 = load i8*, i8** %4
store i8* %14, i8** %6
%15 = load i8*, i8** %4
%16 = load i8*, i8** %4
%17 = call i32 @strlen(i8* %16)
%18 = call i32 @memset(i8* %15, i8 signext 0, i32 %17)
store i32 0, i32* %7
br label %19
19: ; preds = %37, %13
%20 = load i8*, i8** %5
%21 = load i32, i32* %7
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %40
27: ; preds = %19
%28 = load i8*, i8** %5
%29 = load i32, i32* %7
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = load i8*, i8** %4
%34 = load i32, i32* %7
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8 %32, i8* %36
br label %37
37: ; preds = %27
%38 = load i32, i32* %7
%39 = add i32 %38, 1
store i32 %39, i32* %7
br label %19
40: ; preds = %19
%41 = load i8*, i8** %6
store i8* %41, i8** %3
br label %42
42: ; preds = %40, %11
%43 = load i8*, i8** %3
ret i8* %43
}

LLVM IR (-O2):
define i8* @strcpy(i8* returned %0, i8* %1) {
%3 = icmp eq i8* %0, %1
br i1 %3, label %19, label %4
4: ; preds = %2
%5 = tail call i32 @strlen(i8* %0)
%6 = tail call i32 @memset(i8* %0, i8 signext 0, i32 %5)
%7 = load i8, i8* %1
%8 = icmp eq i8 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %4, %9
%10 = phi i8 [ %17, %9 ], [ %7, %4 ]
%11 = phi i64 [ %15, %9 ], [ 0, %4 ]
%12 = phi i32 [ %14, %9 ], [ 0, %4 ]
%13 = getelementptr inbounds i8, i8* %0, i64 %11
store i8 %10, i8* %13
%14 = add i32 %12, 1
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %1, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %9
19: ; preds = %9, %4, %2
ret i8* %0
}