// File: jstaursky[P]hutch/src/Sleigh/slgh_compile.cc
// Function: ConsistencyChecker::possibleIntersection(VarnodeTpl const*, VarnodeTpl const*)
bool ConsistencyChecker::possibleIntersection(const VarnodeTpl *vn1,const VarnodeTpl *vn2)

{ // Conservatively test whether vn1 and vn2 can intersect
  if (vn1->getSpace().isConstSpace()) return false;
  if (vn2->getSpace().isConstSpace()) return false;

  bool u1 = vn1->getSpace().isUniqueSpace();
  bool u2 = vn2->getSpace().isUniqueSpace();

  if (u1 != u2) return false;

  if (vn1->getSpace().getType() != ConstTpl::spaceid) return true;
  if (vn2->getSpace().getType() != ConstTpl::spaceid) return true;
  AddrSpace *spc = vn1->getSpace().getSpace();
  if (spc != vn2->getSpace().getSpace()) return false;


  if (vn2->getOffset().getType() != ConstTpl::real) return true;
  if (vn2->getSize().getType() != ConstTpl::real) return true;

  if (vn1->getOffset().getType() != ConstTpl::real) return true;
  if (vn1->getSize().getType() != ConstTpl::real) return true;

  uintb offset = vn1->getOffset().getReal();
  uintb size = vn1->getSize().getReal();

  uintb off = vn2->getOffset().getReal();
  if (off+vn2->getSize().getReal()-1 < offset) return false;
  if (off > (offset+size-1)) return false;
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x40220
movq %rax, %rdi
callq 0x49fb0
testb $0x1, %al
jne 0x5ee47
jmp 0x5ee50
movb $0x0, -0x1(%rbp)
jmp 0x5f048
movq -0x18(%rbp), %rdi
callq 0x40220
movq %rax, %rdi
callq 0x49fb0
testb $0x1, %al
jne 0x5ee67
jmp 0x5ee70
movb $0x0, -0x1(%rbp)
jmp 0x5f048
movq -0x10(%rbp), %rdi
callq 0x40220
movq %rax, %rdi
callq 0x4a000
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x18(%rbp), %rdi
callq 0x40220
movq %rax, %rdi
callq 0x4a000
andb $0x1, %al
movb %al, -0x1a(%rbp)
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movb -0x1a(%rbp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x5eeba
movb $0x0, -0x1(%rbp)
jmp 0x5f048
movq -0x10(%rbp), %rdi
callq 0x40220
movq %rax, %rdi
callq 0x3fc10
cmpl $0x6, %eax
je 0x5eed9
movb $0x1, -0x1(%rbp)
jmp 0x5f048
movq -0x18(%rbp), %rdi
callq 0x40220
movq %rax, %rdi
callq 0x3fc10
cmpl $0x6, %eax
je 0x5eef8
movb $0x1, -0x1(%rbp)
jmp 0x5f048
movq -0x10(%rbp), %rdi
callq 0x40220
movq %rax, %rdi
callq 0x40230
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
callq 0x40220
movq %rax, %rdi
callq 0x40230
movq %rax, %rcx
movq -0x48(%rbp), %rax
cmpq %rcx, %rax
je 0x5ef3b
movb $0x0, -0x1(%rbp)
jmp 0x5f048
movq -0x18(%rbp), %rdi
callq 0x3fca0
movq %rax, %rdi
callq 0x3fc10
cmpl $0x0, %eax
je 0x5ef5a
movb $0x1, -0x1(%rbp)
jmp 0x5f048
movq -0x18(%rbp), %rdi
callq 0x3fbf0
movq %rax, %rdi
callq 0x3fc10
cmpl $0x0, %eax
je 0x5ef79
movb $0x1, -0x1(%rbp)
jmp 0x5f048
movq -0x10(%rbp), %rdi
callq 0x3fca0
movq %rax, %rdi
callq 0x3fc10
cmpl $0x0, %eax
je 0x5ef98
movb $0x1, -0x1(%rbp)
jmp 0x5f048
movq -0x10(%rbp), %rdi
callq 0x3fbf0
movq %rax, %rdi
callq 0x3fc10
cmpl $0x0, %eax
je 0x5efb7
movb $0x1, -0x1(%rbp)
jmp 0x5f048
movq -0x10(%rbp), %rdi
callq 0x3fca0
movq %rax, %rdi
callq 0x3fc20
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3fbf0
movq %rax, %rdi
callq 0x3fc20
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3fca0
movq %rax, %rdi
callq 0x3fc20
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3fbf0
movq %rax, %rdi
callq 0x3fc20
movq %rax, %rcx
movq -0x50(%rbp), %rax
addq %rcx, %rax
subq $0x1, %rax
cmpq -0x30(%rbp), %rax
jae 0x5f029
movb $0x0, -0x1(%rbp)
jmp 0x5f048
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
addq -0x38(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jbe 0x5f044
movb $0x0, -0x1(%rbp)
jmp 0x5f048
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)