#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 */
char *rtxStrncpy(char *, size_t, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char const *);
char *rtxStrcpy(char *dest, size_t bufsiz, const char *src) {
  if (0 == dest || 0 == bufsiz || 0 == src)
    return (char *)0;
  else
    return rtxStrncpy(dest, bufsiz, src, strlen(src));
}


x86 assembly (clang, -O0):
<rtxStrcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     1158 <rtxStrcpy+0x38>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
je     1158 <rtxStrcpy+0x38>
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    1165 <rtxStrcpy+0x45>
movq   $0x0,-0x8(%rbp)
jmp    119d <rtxStrcpy+0x7d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    %eax,%ecx
call   1040 <rtxStrncpy@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtxStrcpy>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     115a <rtxStrcpy+0x3a>
mov    %rsi,%r14
test   %rsi,%rsi
je     115a <rtxStrcpy+0x3a>
mov    %rdx,%rbx
test   %rdx,%rdx
je     115a <rtxStrcpy+0x3a>
mov    %rdi,%r15
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <rtxStrncpy@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @rtxStrcpy(i8* %0, i64 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
%8 = load i8*, i8** %5
%9 = icmp eq i8* null, %8
br i1 %9, label %16, label %10
10: ; preds = %3
%11 = load i64, i64* %6
%12 = icmp eq i64 0, %11
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i8*, i8** %7
%15 = icmp eq i8* null, %14
br i1 %15, label %16, label %17
16: ; preds = %13, %10, %3
store i8* null, i8** %4
br label %24
17: ; preds = %13
%18 = load i8*, i8** %5
%19 = load i64, i64* %6
%20 = load i8*, i8** %7
%21 = load i8*, i8** %7
%22 = call i32 @strlen(i8* %21)
%23 = call i8* @rtxStrncpy(i8* %18, i64 %19, i8* %20, i32 %22)
store i8* %23, i8** %4
br label %24
24: ; preds = %17, %16
%25 = load i8*, i8** %4
ret i8* %25
}

LLVM IR (-O2):
define i8* @rtxStrcpy(i8* %0, i64 %1, i8* %2) {
%4 = icmp eq i8* %0, null
%5 = icmp eq i64 %1, 0
%6 = or i1 %4, %5
%7 = icmp eq i8* %2, null
%8 = or i1 %6, %7
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = tail call i32 @strlen(i8* %2)
%11 = tail call i8* @rtxStrncpy(i8* %0, i64 %1, i8* %2, i32 %10)
br label %12
12: ; preds = %3, %9
%13 = phi i8* [ %11, %9 ], [ null, %3 ]
ret i8* %13
}