#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 */
void *memcpy_flash(void *dst, const void *src, size_t n) {
  const char *s = src;
  char *d = dst;
  while (n > 0) {
    *d++ = *s++;
    *d++ = *s++;
    s = s + 2;
    n = n - 2;
  }
  return dst;
}


x86 assembly (clang, -O0):
<memcpy_flash>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
jbe    118c <memcpy_flash+0x8c>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
sub    $0x2,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <memcpy_flash+0x20>
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<memcpy_flash>:
mov    %rdi,%rax
test   %rdx,%rdx
je     1129 <memcpy_flash+0x29>
xor    %edi,%edi
nopw   0x0(%rax,%rax,1)
movzbl (%rsi,%rdi,2),%ecx
mov    %cl,(%rax,%rdi,1)
movzbl 0x1(%rsi,%rdi,2),%ecx
mov    %cl,0x1(%rax,%rdi,1)
add    $0x2,%rdi
cmp    %rdi,%rdx
jne    1110 <memcpy_flash+0x10>
ret

LLVM IR (-O0):
define i8* @memcpy_flash(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%9 = load i8*, i8** %5
store i8* %9, i8** %7
%10 = load i8*, i8** %4
store i8* %10, i8** %8
br label %11
11: ; preds = %14, %3
%12 = load i64, i64* %6
%13 = icmp ugt i64 %12, 0
br i1 %13, label %14, label %29
14: ; preds = %11
%15 = load i8*, i8** %7
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %7
%17 = load i8, i8* %15
%18 = load i8*, i8** %8
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %8
store i8 %17, i8* %18
%20 = load i8*, i8** %7
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %7
%22 = load i8, i8* %20
%23 = load i8*, i8** %8
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %8
store i8 %22, i8* %23
%25 = load i8*, i8** %7
%26 = getelementptr inbounds i8, i8* %25, i64 2
store i8* %26, i8** %7
%27 = load i64, i64* %6
%28 = sub i64 %27, 2
store i64 %28, i64* %6
br label %11
29: ; preds = %11
%30 = load i8*, i8** %4
ret i8* %30
}

LLVM IR (-O2):
define i8* @memcpy_flash(i8* returned writeonly %0, i8* nocapture %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %17, label %5
5: ; preds = %3, %5
%6 = phi i8* [ %13, %5 ], [ %0, %3 ]
%7 = phi i8* [ %14, %5 ], [ %1, %3 ]
%8 = phi i64 [ %15, %5 ], [ %2, %3 ]
%9 = getelementptr inbounds i8, i8* %7, i64 1
%10 = load i8, i8* %7
%11 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %10, i8* %6
%12 = load i8, i8* %9
%13 = getelementptr inbounds i8, i8* %6, i64 2
store i8 %12, i8* %11
%14 = getelementptr inbounds i8, i8* %7, i64 4
%15 = add i64 %8, -2
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %5
17: ; preds = %5, %3
ret i8* %0
}