#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 int *, unsigned int const *, unsigned int);
int /*<<< orphan*/ memmove(unsigned int *, unsigned int const *, unsigned int);
void uintcpy(unsigned int *dst, const unsigned int *src, unsigned int n) {
  if (dst + n <= src)
    memcpy(dst, src, n * sizeof(unsigned int));
  else if (dst != src)
    memmove(dst, src, n * sizeof(unsigned int));
}


x86 assembly (clang, -O0):
<uintcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x2,%rcx
add    %rcx,%rax
cmp    -0x10(%rbp),%rax
ja     1166 <uintcpy+0x46>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edx
call   1030 <memcpy@plt>
jmp    118f <uintcpy+0x6f>
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     118a <uintcpy+0x6a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edx
call   1040 <memmove@plt>
jmp    118f <uintcpy+0x6f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uintcpy>:
mov    %edx,%eax
lea    (%rdi,%rax,4),%rax
cmp    %rsi,%rax
jbe    1138 <uintcpy+0x18>
cmp    %rsi,%rdi
je     1140 <uintcpy+0x20>
shl    $0x2,%edx
jmp    1040 <memmove@plt>
shl    $0x2,%edx
jmp    1030 <memcpy@plt>
ret

LLVM IR (-O0):
define void @uintcpy(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%7 = load i32*, i32** %4
%8 = load i32, i32* %6
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i32, i32* %7, i64 %9
%11 = load i32*, i32** %5
%12 = icmp ule i32* %10, %11
br i1 %12, label %13, label %21
13: ; preds = %3
%14 = load i32*, i32** %4
%15 = load i32*, i32** %5
%16 = load i32, i32* %6
%17 = zext i32 %16 to i64
%18 = mul i64 %17, 4
%19 = trunc i64 %18 to i32
%20 = call i32 @memcpy(i32* %14, i32* %15, i32 %19)
br label %34
21: ; preds = %3
%22 = load i32*, i32** %4
%23 = load i32*, i32** %5
%24 = icmp ne i32* %22, %23
br i1 %24, label %25, label %33
25: ; preds = %21
%26 = load i32*, i32** %4
%27 = load i32*, i32** %5
%28 = load i32, i32* %6
%29 = zext i32 %28 to i64
%30 = mul i64 %29, 4
%31 = trunc i64 %30 to i32
%32 = call i32 @memmove(i32* %26, i32* %27, i32 %31)
br label %33
33: ; preds = %25, %21
br label %34
34: ; preds = %33, %13
ret void
}

LLVM IR (-O2):
define void @uintcpy(i32* %0, i32* %1, i32 %2) {
%4 = zext i32 %2 to i64
%5 = getelementptr inbounds i32, i32* %0, i64 %4
%6 = icmp ugt i32* %5, %1
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = shl i32 %2, 2
%9 = tail call i32 @memcpy(i32* %0, i32* %1, i32 %8)
br label %15
10: ; preds = %3
%11 = icmp eq i32* %0, %1
br i1 %11, label %15, label %12
12: ; preds = %10
%13 = shl i32 %2, 2
%14 = tail call i32 @memmove(i32* %0, i32* %1, i32 %13)
br label %15
15: ; preds = %10, %12, %7
ret void
}