#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*/ memcpy(void *, void const *, size_t);
void *memory_vm_memcpy(void *dest, const void *src, size_t n) {
  unsigned int i;
  memcpy(dest, src, n & (~3));
  for (i = n & (~3); i < n; i++) {
    ((char *)dest)[i ^ 2] = ((char *)src)[i ^ 2];
  }
  return dest;
}


x86 assembly (clang, -O0):
<memory_vm_memcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
and    $0xfffffffffffffffc,%rdx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rax
and    $0xfffffffffffffffc,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%rax
jae    117d <memory_vm_memcpy+0x6d>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
xor    $0x2,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
xor    $0x2,%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1144 <memory_vm_memcpy+0x34>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memory_vm_memcpy>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rdx,%rbx
and    $0xfffffffffffffffc,%rbx
mov    %rbx,%rdx
call   1030 <memcpy@plt>
mov    %r12d,%eax
and    $0xfffffffc,%eax
cmp    %r12,%rax
jae    1157 <memory_vm_memcpy+0x47>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    $0x2,%rax
movzbl (%r15,%rax,1),%ecx
mov    %cl,(%r14,%rax,1)
add    $0x1,%ebx
cmp    %r12,%rbx
jb     1140 <memory_vm_memcpy+0x30>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @memory_vm_memcpy(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = load i64, i64* %6
%11 = and i64 %10, -4
%12 = call i32 @memcpy(i8* %8, i8* %9, i64 %11)
%13 = load i64, i64* %6
%14 = and i64 %13, -4
%15 = trunc i64 %14 to i32
store i32 %15, i32* %7
br label %16
16: ; preds = %33, %3
%17 = load i32, i32* %7
%18 = zext i32 %17 to i64
%19 = load i64, i64* %6
%20 = icmp ult i64 %18, %19
br i1 %20, label %21, label %36
21: ; preds = %16
%22 = load i8*, i8** %5
%23 = load i32, i32* %7
%24 = xor i32 %23, 2
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = load i8, i8* %26
%28 = load i8*, i8** %4
%29 = load i32, i32* %7
%30 = xor i32 %29, 2
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
store i8 %27, i8* %32
br label %33
33: ; preds = %21
%34 = load i32, i32* %7
%35 = add i32 %34, 1
store i32 %35, i32* %7
br label %16
36: ; preds = %16
%37 = load i8*, i8** %4
ret i8* %37
}

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