#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 nowarn_mempcpy_chain(const void *s) {
  extern char pcpy_a8[8];
  char *p = pcpy_a8;
  p = mempcpy(p + 1, s, 7);
  sink(p);
  p = mempcpy(p - 7, s, 7);
  sink(p);
  p = mempcpy(p - 5, s, 5);
  sink(p);
  p = mempcpy(p - 3, s, 3);
  sink(p);
  p = mempcpy(p - 2, s, 2);
  sink(p);
  mempcpy(p - 1, s, 1);
  sink(p);
  mempcpy(p - 8, s, 8);
}


x86 assembly (clang, -O0):
<nowarn_mempcpy_chain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ebd(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x7,%edx
call   1040 <mempcpy@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <sink@plt>
mov    -0x10(%rbp),%rdi
add    $0xfffffffffffffff9,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x7,%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    $0x5,%edx
call   1040 <mempcpy@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <sink@plt>
mov    -0x10(%rbp),%rdi
add    $0xfffffffffffffffd,%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    $0xfffffffffffffffe,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x2,%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    $0x1,%edx
call   1040 <mempcpy@plt>
mov    -0x10(%rbp),%rdi
call   1030 <sink@plt>
mov    -0x10(%rbp),%rdi
add    $0xfffffffffffffff8,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   1040 <mempcpy@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nowarn_mempcpy_chain>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2ec2(%rip),%rdi
add    $0x1,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   1040 <mempcpy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <sink@plt>
add    $0xfffffffffffffff9,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   1040 <mempcpy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <sink@plt>
add    $0xfffffffffffffffb,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1040 <mempcpy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <sink@plt>
add    $0xfffffffffffffffd,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1040 <mempcpy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <sink@plt>
add    $0xfffffffffffffffe,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1040 <mempcpy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <sink@plt>
lea    -0x1(%rbx),%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <mempcpy@plt>
mov    %rbx,%rdi
call   1030 <sink@plt>
add    $0xfffffffffffffff8,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <mempcpy@plt>

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

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