#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 __get_array_size(void const *);
int /*<<< orphan*/ __infer_set_flag(char *, char *);
void *memcpy(void *s1, const void *s2, size_t n) {
  int size_s1;
  int size_s2;
  __infer_set_flag("ignore_return", "");
  size_s1 = __get_array_size(s1);
  size_s2 = __get_array_size(s2);
  if ((n < 0) || (n > size_s1) || (n > size_s2))
    while (1)
      ;
  return s1;
}


x86 assembly (clang, -O0):
<memcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xec5(%rip),%rdi
lea    0xecb(%rip),%rsi
call   1030 <__infer_set_flag@plt>
mov    -0x8(%rbp),%rdi
call   1040 <__get_array_size@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <__get_array_size@plt>
mov    %eax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jb     118c <memcpy+0x6c>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmp    %rcx,%rax
ja     118c <memcpy+0x6c>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmp    %rcx,%rax
jbe    1196 <memcpy+0x76>
jmp    1191 <memcpy+0x71>
jmp    1191 <memcpy+0x71>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memcpy>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xec9(%rip),%rdi
lea    0xecf(%rip),%rsi
call   1030 <__infer_set_flag@plt>
mov    %r14,%rdi
call   1040 <__get_array_size@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1040 <__get_array_size@plt>
movslq %ebp,%rcx
cmp    %rbx,%rcx
jb     1180 <memcpy+0x60>
cltq
cmp    %rbx,%rax
jb     1180 <memcpy+0x60>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
jmp    1180 <memcpy+0x60>

LLVM IR (-O0):
@.str = [14 x i8] c"ignore_return\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @memcpy(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%9 = call i32 @__infer_set_flag(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%10 = load i8*, i8** %4
%11 = call i32 @__get_array_size(i8* %10)
store i32 %11, i32* %7
%12 = load i8*, i8** %5
%13 = call i32 @__get_array_size(i8* %12)
store i32 %13, i32* %8
%14 = load i64, i64* %6
%15 = icmp ult i64 %14, 0
br i1 %15, label %26, label %16
16: ; preds = %3
%17 = load i64, i64* %6
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = icmp ugt i64 %17, %19
br i1 %20, label %26, label %21
21: ; preds = %16
%22 = load i64, i64* %6
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = icmp ugt i64 %22, %24
br i1 %25, label %26, label %28
26: ; preds = %21, %16, %3
br label %27
27: ; preds = %26, %27
br label %27
28: ; preds = %21
%29 = load i8*, i8** %4
ret i8* %29
}

LLVM IR (-O2):
@.str = [14 x i8] c"ignore_return\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @memcpy(i8* returned %0, i8* %1, i64 %2) {
%4 = tail call i32 @__infer_set_flag(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @__get_array_size(i8* %0)
%6 = tail call i32 @__get_array_size(i8* %1)
%7 = sext i32 %5 to i64
%8 = icmp ult i64 %7, %2
%9 = sext i32 %6 to i64
%10 = icmp ult i64 %9, %2
%11 = select i1 %8, i1 true, i1 %10
br i1 %11, label %12, label %13
12: ; preds = %3, %12
br label %12
13: ; preds = %3
ret i8* %0
}