#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*/ assert(int);
int is_partially_overlapping(const void *ptr1, const void *ptr2, int len) {
  size_t diff = (size_t)ptr1 - (size_t)ptr2;
  int overlapped = (len > 0) & (diff != 0) &
                   ((diff < (size_t)len) | (diff > (0 - (size_t)len)));
  assert(!overlapped);
  return overlapped;
}


x86 assembly (clang, -O0):
<is_partially_overlapping>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
cmpq   $0x0,-0x20(%rbp)
setne  %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
mov    -0x20(%rbp),%rcx
movslq -0x14(%rbp),%rdx
cmp    %rdx,%rcx
setb   %cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    -0x20(%rbp),%rdx
movslq -0x14(%rbp),%rdi
xor    %esi,%esi
sub    %rdi,%rsi
cmp    %rsi,%rdx
seta   %dl
and    $0x1,%dl
movzbl %dl,%edx
or     %edx,%ecx
and    %ecx,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_partially_overlapping>:
push   %rbx
sub    %rsi,%rdi
test   %edx,%edx
setg   %al
test   %rdi,%rdi
setne  %cl
and    %al,%cl
movslq %edx,%rax
cmp    %rax,%rdi
setb   %dl
neg    %rax
cmp    %rax,%rdi
seta   %al
or     %dl,%al
and    %cl,%al
movzbl %al,%ebx
mov    %ebx,%eax
xor    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @is_partially_overlapping(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
%10 = ptrtoint i8* %9 to i64
%11 = load i8*, i8** %5
%12 = ptrtoint i8* %11 to i64
%13 = sub i64 %10, %12
store i64 %13, i64* %7
%14 = load i32, i32* %6
%15 = icmp sgt i32 %14, 0
%16 = zext i1 %15 to i32
%17 = load i64, i64* %7
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
%20 = and i32 %16, %19
%21 = load i64, i64* %7
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = icmp ult i64 %21, %23
%25 = zext i1 %24 to i32
%26 = load i64, i64* %7
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = sub i64 0, %28
%30 = icmp ugt i64 %26, %29
%31 = zext i1 %30 to i32
%32 = or i32 %25, %31
%33 = and i32 %20, %32
store i32 %33, i32* %8
%34 = load i32, i32* %8
%35 = icmp ne i32 %34, 0
%36 = xor i1 %35, true
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i32, i32* %8
ret i32 %39
}

LLVM IR (-O2):
define i32 @is_partially_overlapping(i8* %0, i8* %1, i32 %2) {
%4 = ptrtoint i8* %0 to i64
%5 = ptrtoint i8* %1 to i64
%6 = sub i64 %4, %5
%7 = icmp sgt i32 %2, 0
%8 = icmp ne i64 %6, 0
%9 = and i1 %7, %8
%10 = sext i32 %2 to i64
%11 = icmp ult i64 %6, %10
%12 = sub nsw i64 0, %10
%13 = icmp ugt i64 %6, %12
%14 = or i1 %11, %13
%15 = and i1 %9, %14
%16 = zext i1 %15 to i32
%17 = xor i1 %15, true
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
ret i32 %16
}