#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*/ CONS_Debug(int, char *, void *, void const *,
                              int /*<<< orphan*/);
void *memcpy(void *, void const *, size_t);
int /*<<< orphan*/ sizeu1(size_t);
void *cpu_cpy(void *dest, const void *src, size_t n) {
  if (src == NULL) {
    CONS_Debug(0x0200, "Memcpy from 0x0?!: %p %p %s\n", dest, src, sizeu1(n));
    return dest;
  }
  if (dest == NULL) {
    CONS_Debug(0x0200, "Memcpy to 0x0?!: %p %p %s\n", dest, src, sizeu1(n));
    return dest;
  }
  return memcpy(dest, src, n);
}


x86 assembly (clang, -O0):
<cpu_cpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1191 <cpu_cpy+0x61>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <sizeu1@plt>
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    %eax,%r8d
mov    $0x200,%edi
lea    0xe81(%rip),%rsi
call   1050 <CONS_Debug@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11fb <cpu_cpy+0xcb>
cmpq   $0x0,-0x10(%rbp)
jne    11de <cpu_cpy+0xae>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <sizeu1@plt>
mov    -0x40(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    %eax,%r8d
mov    $0x200,%edi
lea    0xe51(%rip),%rsi
call   1050 <CONS_Debug@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11fb <cpu_cpy+0xcb>
mov    -0x10(%rbp),%rdi
mov    %rdi,-0x48(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <memcpy@plt>
mov    -0x48(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpu_cpy>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rsi,%rsi
je     1151 <cpu_cpy+0x21>
mov    %rsi,%rbx
test   %r14,%r14
je     116c <cpu_cpy+0x3c>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <memcpy@plt>
jmp    118d <cpu_cpy+0x5d>
mov    %rdx,%rdi
call   1030 <sizeu1@plt>
lea    0xea0(%rip),%rsi
mov    $0x200,%edi
mov    %r14,%rdx
xor    %ecx,%ecx
jmp    1185 <cpu_cpy+0x55>
mov    %rdx,%rdi
call   1030 <sizeu1@plt>
lea    0xea2(%rip),%rsi
mov    $0x200,%edi
xor    %edx,%edx
mov    %rbx,%rcx
mov    %eax,%r8d
call   1050 <CONS_Debug@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Memcpy from 0x0?!: %p %p %s\0A\00"
@.str.1 = [27 x i8] c"Memcpy to 0x0?!: %p %p %s\0A\00"
define i8* @cpu_cpy(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%8 = load i8*, i8** %6
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %17
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = load i64, i64* %7
%14 = call i32 @sizeu1(i64 %13)
%15 = call i32 @CONS_Debug(i32 512, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %12, i32 %14)
%16 = load i8*, i8** %5
store i8* %16, i8** %4
br label %31
17: ; preds = %3
%18 = load i8*, i8** %5
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = load i8*, i8** %5
%22 = load i8*, i8** %6
%23 = load i64, i64* %7
%24 = call i32 @sizeu1(i64 %23)
%25 = call i32 @CONS_Debug(i32 512, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %22, i32 %24)
%26 = load i8*, i8** %5
store i8* %26, i8** %4
br label %31
27: ; preds = %17
%28 = load i8*, i8** %5
%29 = load i8*, i8** %6
%30 = load i64, i64* %7
store i8* %28, i8** %4
br label %31
31: ; preds = %27, %20, %10
%32 = load i8*, i8** %4
ret i8* %32
}

LLVM IR (-O2):
@.str = [29 x i8] c"Memcpy from 0x0?!: %p %p %s\0A\00"
@.str.1 = [27 x i8] c"Memcpy to 0x0?!: %p %p %s\0A\00"
define i8* @cpu_cpy(i8* returned %0, i8* %1, i64 %2) {
%4 = icmp eq i8* %1, null
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = tail call i32 @sizeu1(i64 %2)
%7 = tail call i32 @CONS_Debug(i32 512, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %0, i8* null, i32 %6)
br label %14
8: ; preds = %3
%9 = icmp eq i8* %0, null
br i1 %9, label %10, label %13
10: ; preds = %8
%11 = tail call i32 @sizeu1(i64 %2)
%12 = tail call i32 @CONS_Debug(i32 512, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* null, i8* %1, i32 %11)
br label %14
13: ; preds = %8
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 %1, i64 %2, i1 false)
br label %14
14: ; preds = %13, %10, %5
ret i8* %0
}