#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(void *, void const *, unsigned int);
int /*<<< orphan*/ sink(void *);
void warn_memcpy(const void *s) {
  extern char cpy_a5[5];
  unsigned n = sizeof cpy_a5;
  void *p = cpy_a5;
  p = memcpy(p, s, n);
  sink(p);
  memcpy(p, s, n + 1);
  sink(p);
  p = cpy_a5;
  p = memcpy(p, s, n);
  sink(p);
  memcpy(p, s, n + 1);
  sink(p);
  p = cpy_a5 + 1;
  p = memcpy(p, s, n - 1);
  sink(p);
  memcpy(p, s, n);
  sink(p);
}


x86 assembly (clang, -O0):
<warn_memcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x5,-0xc(%rbp)
mov    0x2ea6(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <memcpy@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <sink@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
add    $0x1,%edx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rdi
call   1040 <sink@plt>
mov    0x2e62(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <memcpy@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <sink@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
add    $0x1,%edx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rdi
call   1040 <sink@plt>
mov    0x2e1e(%rip),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
call   1030 <memcpy@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <sink@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rdi
call   1040 <sink@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<warn_memcpy>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    0x2eb1(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <memcpy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <sink@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
mov    %rbx,%rdi
call   1040 <sink@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <memcpy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <sink@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
mov    %rbx,%rdi
call   1040 <sink@plt>
add    $0x1,%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <sink@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <memcpy@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <sink@plt>

LLVM IR (-O0):
@cpy_a5 = external global [5 x i8]
define void @warn_memcpy(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
store i32 5, i32* %3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @cpy_a5, i64 0, i64 0), i8** %4
%5 = load i8*, i8** %4
%6 = load i8*, i8** %2
%7 = load i32, i32* %3
%8 = call i8* @memcpy(i8* %5, i8* %6, i32 %7)
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = call i32 @sink(i8* %9)
%11 = load i8*, i8** %4
%12 = load i8*, i8** %2
%13 = load i32, i32* %3
%14 = add i32 %13, 1
%15 = call i8* @memcpy(i8* %11, i8* %12, i32 %14)
%16 = load i8*, i8** %4
%17 = call i32 @sink(i8* %16)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @cpy_a5, i64 0, i64 0), i8** %4
%18 = load i8*, i8** %4
%19 = load i8*, i8** %2
%20 = load i32, i32* %3
%21 = call i8* @memcpy(i8* %18, i8* %19, i32 %20)
store i8* %21, i8** %4
%22 = load i8*, i8** %4
%23 = call i32 @sink(i8* %22)
%24 = load i8*, i8** %4
%25 = load i8*, i8** %2
%26 = load i32, i32* %3
%27 = add i32 %26, 1
%28 = call i8* @memcpy(i8* %24, i8* %25, i32 %27)
%29 = load i8*, i8** %4
%30 = call i32 @sink(i8* %29)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @cpy_a5, i64 0, i64 1), i8** %4
%31 = load i8*, i8** %4
%32 = load i8*, i8** %2
%33 = load i32, i32* %3
%34 = sub i32 %33, 1
%35 = call i8* @memcpy(i8* %31, i8* %32, i32 %34)
store i8* %35, i8** %4
%36 = load i8*, i8** %4
%37 = call i32 @sink(i8* %36)
%38 = load i8*, i8** %4
%39 = load i8*, i8** %2
%40 = load i32, i32* %3
%41 = call i8* @memcpy(i8* %38, i8* %39, i32 %40)
%42 = load i8*, i8** %4
%43 = call i32 @sink(i8* %42)
ret void
}

LLVM IR (-O2):
@cpy_a5 = external global [5 x i8]
define void @warn_memcpy(i8* %0) {
%2 = tail call i8* @memcpy(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @cpy_a5, i64 0, i64 0), i8* %0, i32 5)
%3 = tail call i32 @sink(i8* %2)
%4 = tail call i8* @memcpy(i8* %2, i8* %0, i32 6)
%5 = tail call i32 @sink(i8* %2)
%6 = tail call i8* @memcpy(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @cpy_a5, i64 0, i64 0), i8* %0, i32 5)
%7 = tail call i32 @sink(i8* %6)
%8 = tail call i8* @memcpy(i8* %6, i8* %0, i32 6)
%9 = tail call i32 @sink(i8* %6)
%10 = tail call i8* @memcpy(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @cpy_a5, i64 0, i64 1), i8* %0, i32 4)
%11 = tail call i32 @sink(i8* %10)
%12 = tail call i8* @memcpy(i8* %10, i8* %0, i32 5)
%13 = tail call i32 @sink(i8* %10)
ret void
}