#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*/ memcpy(unsigned char *, unsigned char *, unsigned int);
void pktcpy(unsigned char *dest, unsigned char *src, int n) {
  if (n > 1514)
    return;
  if ((unsigned int)(src + n) < (unsigned int)(0xa1840000 + 16384))
    memcpy(dest, src, n);
  else {
    memcpy(dest, src, (0xa1840000 + 16384) - (unsigned int)src);
    memcpy(dest + ((0xa1840000 + 16384) - (unsigned int)src),
           (unsigned char *)0xa1840000,
           (unsigned int)(src + n) - (0xa1840000 + 16384));
  }
}


x86 assembly (clang, -O0):
<pktcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x5ea,-0x14(%rbp)
jle    1135 <pktcpy+0x25>
jmp    11ab <pktcpy+0x9b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
cmp    $0xa1844000,%eax
jae    1160 <pktcpy+0x50>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <memcpy@plt>
jmp    11ab <pktcpy+0x9b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    $0xa1844000,%edx
sub    %eax,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %eax,%ecx
mov    $0xa1844000,%eax
sub    %ecx,%eax
mov    %eax,%eax
add    %rax,%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %eax,%edx
sub    $0xa1844000,%edx
mov    $0xa1840000,%esi
call   1030 <memcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pktcpy>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x5ea,%edx
jle    1121 <pktcpy+0x11>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rdi,%r14
lea    (%rsi,%rdx,1),%ebp
cmp    $0xa1843fff,%ebp
ja     1134 <pktcpy+0x24>
mov    %r14,%rdi
jmp    1158 <pktcpy+0x48>
mov    $0xa1844000,%ebx
sub    %esi,%ebx
mov    %r14,%rdi
mov    %ebx,%edx
call   1030 <memcpy@plt>
add    %r14,%rbx
add    $0x5e7bc000,%ebp
mov    $0xa1840000,%esi
mov    %rbx,%rdi
mov    %ebp,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <memcpy@plt>

LLVM IR (-O0):
define void @pktcpy(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = icmp sgt i32 %7, 1514
br i1 %8, label %9, label %10
9: ; preds = %3
br label %42
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = ptrtoint i8* %14 to i32
%16 = icmp ult i32 %15, -1585168384
br i1 %16, label %17, label %22
17: ; preds = %10
%18 = load i8*, i8** %4
%19 = load i8*, i8** %5
%20 = load i32, i32* %6
%21 = call i32 @memcpy(i8* %18, i8* %19, i32 %20)
br label %42
22: ; preds = %10
%23 = load i8*, i8** %4
%24 = load i8*, i8** %5
%25 = load i8*, i8** %5
%26 = ptrtoint i8* %25 to i32
%27 = sub i32 -1585168384, %26
%28 = call i32 @memcpy(i8* %23, i8* %24, i32 %27)
%29 = load i8*, i8** %4
%30 = load i8*, i8** %5
%31 = ptrtoint i8* %30 to i32
%32 = sub i32 -1585168384, %31
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %29, i64 %33
%35 = load i8*, i8** %5
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = ptrtoint i8* %38 to i32
%40 = sub i32 %39, -1585168384
%41 = call i32 @memcpy(i8* %34, i8* inttoptr (i64 2709782528 to i8*), i32 %40)
br label %42
42: ; preds = %9, %22, %17
ret void
}

LLVM IR (-O2):
define void @pktcpy(i8* %0, i8* %1, i32 %2) {
%4 = icmp sgt i32 %2, 1514
br i1 %4, label %22, label %5
5: ; preds = %3
%6 = sext i32 %2 to i64
%7 = getelementptr inbounds i8, i8* %1, i64 %6
%8 = ptrtoint i8* %7 to i64
%9 = trunc i64 %8 to i32
%10 = icmp ult i32 %9, -1585168384
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = tail call i32 @memcpy(i8* %0, i8* %1, i32 %2)
br label %22
13: ; preds = %5
%14 = ptrtoint i8* %1 to i64
%15 = trunc i64 %14 to i32
%16 = sub i32 -1585168384, %15
%17 = tail call i32 @memcpy(i8* %0, i8* %1, i32 %16)
%18 = zext i32 %16 to i64
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = add nsw i32 %9, 1585168384
%21 = tail call i32 @memcpy(i8* %19, i8* inttoptr (i64 2709782528 to i8*), i32 %20)
br label %22
22: ; preds = %3, %13, %11
ret void
}