#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 *mempcpy(char *, void const *, int);
int /*<<< orphan*/ sink(char *);
void warn_mempcpy(const void *s) {
  extern char pcpy_a5[5];
  char *p = pcpy_a5;
  p = mempcpy(p, s, 5);
  sink(p);
  mempcpy(p - 5, s, 6);
  sink(p);
  p = pcpy_a5;
  p = mempcpy(p, s, 3);
  sink(p);
  mempcpy(p, s, 3);
  sink(p);
  p = pcpy_a5 + 1;
  p = mempcpy(p, s, 3);
  sink(p);
  mempcpy(p - 1, s, 5);
  sink(p);
}


x86 assembly (clang, -O0):
<warn_mempcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ead(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x5,%edx
call   1040 <mempcpy@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <sink@plt>
mov    -0x10(%rbp),%rdi
add    $0xfffffffffffffffb,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x6,%edx
call   1040 <mempcpy@plt>
mov    -0x10(%rbp),%rdi
call   1030 <sink@plt>
mov    0x2e64(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x3,%edx
call   1040 <mempcpy@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <sink@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x3,%edx
call   1040 <mempcpy@plt>
mov    -0x10(%rbp),%rdi
call   1030 <sink@plt>
mov    0x2e1f(%rip),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x3,%edx
call   1040 <mempcpy@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <sink@plt>
mov    -0x10(%rbp),%rdi
add    $0xffffffffffffffff,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x5,%edx
call   1040 <mempcpy@plt>
mov    -0x10(%rbp),%rdi
call   1030 <sink@plt>
add    $0x10,%rsp
pop    %rbp
ret

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

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

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