#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 *memcpy(char *, void const *, int);
int /*<<< orphan*/ sink(char *);
void nowarn_memcpy_chain(const void *s) {
  extern char cpy_a8[8];
  char *p = cpy_a8;
  p = memcpy(p + 1, s, 7);
  sink(p);
  p = memcpy(p + 2, s, 5);
  sink(p);
  p = memcpy(p + 3, s, 2);
  sink(p);
  p = memcpy(p + 1, s, 1);
  sink(p);
  p = memcpy(p - 7, s, 8);
  sink(p);
  memcpy(p + 1, s, 7);
}


x86 assembly (clang, -O0):
<nowarn_memcpy_chain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2eb5(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x7,%edx
call   1030 <memcpy@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <sink@plt>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x5,%edx
call   1030 <memcpy@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <sink@plt>
mov    -0x10(%rbp),%rdi
add    $0x3,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x2,%edx
call   1030 <memcpy@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <sink@plt>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x1,%edx
call   1030 <memcpy@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <sink@plt>
mov    -0x10(%rbp),%rdi
add    $0xfffffffffffffff9,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <sink@plt>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x7,%edx
call   1030 <memcpy@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nowarn_memcpy_chain>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2eba(%rip),%rdi
add    $0x1,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   1030 <memcpy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <sink@plt>
add    $0x2,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <memcpy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <sink@plt>
add    $0x3,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1030 <memcpy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <sink@plt>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <memcpy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <sink@plt>
add    $0xfffffffffffffff9,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <sink@plt>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <memcpy@plt>

LLVM IR (-O0):
@cpy_a8 = external global [8 x i8]
define void @nowarn_memcpy_chain(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @cpy_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* @memcpy(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 2
%12 = load i8*, i8** %2
%13 = call i8* @memcpy(i8* %11, i8* %12, i32 5)
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 3
%18 = load i8*, i8** %2
%19 = call i8* @memcpy(i8* %17, i8* %18, i32 2)
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 1
%24 = load i8*, i8** %2
%25 = call i8* @memcpy(i8* %23, i8* %24, i32 1)
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 -7
%30 = load i8*, i8** %2
%31 = call i8* @memcpy(i8* %29, i8* %30, i32 8)
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* @memcpy(i8* %35, i8* %36, i32 7)
ret void
}

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