#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*/ vassert(int /*<<< orphan*/, char *);
char *strcpy(char *to, const char *from) {
  char *res = to;
  vassert(from != NULL, "from == NULL");
  vassert(to != NULL, "to == NULL");
  while (*from) {
    *to++ = *from++;
  }
  *to = '\0';
  return res;
}


x86 assembly (clang, -O0):
<strcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
lea    0xec4(%rip),%rsi
call   1030 <vassert@plt>
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
lea    0xeb8(%rip),%rsi
call   1030 <vassert@plt>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     118e <strcpy+0x7e>
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)
jmp    115a <strcpy+0x4a>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcpy>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %edi,%edi
test   %rsi,%rsi
setne  %dil
lea    0xed6(%rip),%rsi
call   1030 <vassert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
lea    0xece(%rip),%rsi
call   1030 <vassert@plt>
mov    (%rbx),%al
mov    %r14,%rcx
test   %al,%al
je     1171 <strcpy+0x61>
add    $0x1,%rbx
mov    %r14,%rcx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %al,(%rcx)
add    $0x1,%rcx
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <strcpy+0x50>
movb   $0x0,(%rcx)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"from == NULL\00"
@.str.1 = [11 x i8] c"to == NULL\00"
define i8* @strcpy(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
store i8* %6, i8** %5
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
%9 = zext i1 %8 to i32
%10 = call i32 @vassert(i32 %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
%13 = zext i1 %12 to i32
%14 = call i32 @vassert(i32 %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %19, %2
%16 = load i8*, i8** %4
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %15
%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
br label %15
25: ; preds = %15
%26 = load i8*, i8** %3
store i8 0, i8* %26
%27 = load i8*, i8** %5
ret i8* %27
}

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