#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 */
int /*<<< orphan*/ memccpy(unsigned char *, unsigned char *, int, int);
void overlappingWriteFunction_memccpy(unsigned char *src, unsigned char *dest,
                                      int c, size_t count) {
  (void)memccpy(dest, src, c, count);
  (void)memccpy(dest, src, 42, count);
  (void)memccpy(dest, dest, c, 4);
  (void)memccpy(dest, dest + 3, c, 4);
}


x86 assembly (clang, -O0):
<overlappingWriteFunction_memccpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
call   1030 <memccpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    $0x2a,%edx
call   1030 <memccpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0x4,%ecx
call   1030 <memccpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x3,%rsi
mov    -0x14(%rbp),%edx
mov    $0x4,%ecx
call   1030 <memccpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<overlappingWriteFunction_memccpy>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %rbx,%rsi
call   1030 <memccpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x2a,%edx
mov    %r15d,%ecx
call   1030 <memccpy@plt>
lea    0x3(%rbp),%rsi
mov    %rbp,%rdi
mov    %r14d,%edx
mov    $0x4,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <memccpy@plt>

LLVM IR (-O0):
define void @overlappingWriteFunction_memccpy(i8* %0, i8* %1, i32 %2, i64 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i64 %3, i64* %8
%9 = load i8*, i8** %6
%10 = load i8*, i8** %5
%11 = load i32, i32* %7
%12 = load i64, i64* %8
%13 = trunc i64 %12 to i32
%14 = call i32 @memccpy(i8* %9, i8* %10, i32 %11, i32 %13)
%15 = load i8*, i8** %6
%16 = load i8*, i8** %5
%17 = load i64, i64* %8
%18 = trunc i64 %17 to i32
%19 = call i32 @memccpy(i8* %15, i8* %16, i32 42, i32 %18)
%20 = load i8*, i8** %6
%21 = load i8*, i8** %6
%22 = load i32, i32* %7
%23 = call i32 @memccpy(i8* %20, i8* %21, i32 %22, i32 4)
%24 = load i8*, i8** %6
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i64 3
%27 = load i32, i32* %7
%28 = call i32 @memccpy(i8* %24, i8* %26, i32 %27, i32 4)
ret void
}

LLVM IR (-O2):
define void @overlappingWriteFunction_memccpy(i8* nocapture %0, i8* %1, i32 %2, i64 %3) {
%5 = trunc i64 %3 to i32
%6 = tail call i32 @memccpy(i8* %1, i8* %0, i32 %2, i32 %5)
%7 = tail call i32 @memccpy(i8* %1, i8* %0, i32 42, i32 %5)
%8 = getelementptr inbounds i8, i8* %1, i64 3
%9 = tail call i32 @memccpy(i8* %1, i8* %8, i32 %2, i32 4)
ret void
}