// File: /workspace/github_cpp_makefile_star2_O2/thierry7100[P]CutOptim/src/Geometry.cpp
// Function: Polygon::Intersect(Polygon*)
bool Polygon::Intersect(Polygon *Poly2)
{
Segment *pSeg2;
bool ShareSegment = false;      //  If true, one segment is included in another

    for ( int i = 0; i < Poly2->nVertices - 1; i++)
    {
        pSeg2 = &Poly2->_Segments[i];
        if ( pSeg2->xM <= BoundingBox.A.x ) continue;           //  Segment couldn't cross, right from polygon 1
        if ( pSeg2->xm >= BoundingBox.B.x ) continue;           //  Segment couldn't cross, left from polygon 1
        if ( pSeg2->yM <= BoundingBox.A.y ) continue;           //  Segment couldn't cross, below from polygon 1
        if ( pSeg2->ym >= BoundingBox.B.y ) continue;           //  Segment couldn't cross, above from polygon 1
        //  Possible, so check with all edges of polygon 1
        for ( int j = 0; j < nVertices - 1; j++)
        {
            if ( _Segments[j].isCrossingNoEnd(pSeg2, NULL, &ShareSegment) ) //  Cross return true
                return true;
            //  If lines are parallel checks for inclusion, at least partial
            if ( ShareSegment )
            {
                Point ptA1 = pSeg2->getPointA();
                Point ptB1 = pSeg2->getPointB();
                Point ptA2 = _Segments[j].getPointA();
                Point ptB2 = _Segments[j].getPointB();
                if ( _Segments[j].InSegmentNoEnd(ptA1) )
                {
                    //cout << "Shared point A of " << *pSeg2 << " in " << _Segments[j] << " with same rotation side\n";
                    return true;
                }
                if ( _Segments[j].InSegmentNoEnd(ptB1) )
                {
                    //cout << "Shared point B of " << *pSeg2 << " in " << _Segments[j] << " with same rotation side\n";
                    return true;
                }
                if ( pSeg2->InSegmentNoEnd(ptA2) )
                {
                    //cout << "Shared point A of " << _Segments[j] << " in " <<  pSeg2 << " with same rotation side\n";
                    return true;
                }
                if ( pSeg2->InSegmentNoEnd(ptB2) )
                {
                    //cout << "Shared point B of " << _Segments[j] << " in " <<  pSeg2 << " with same rotation side\n";
                    return true;
                }
            }
        }
    }
    return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r14
leaq 0xf(%rsp), %rax
movb $0x0, (%rax)
xorl %r13d, %r13d
movslq 0x8(%rsi), %r12
decq %r12
cmpq %r12, %r13
jge 0x23e2a
movq 0x28(%rsi), %rbp
imulq $0x58, %r13, %rax
movsd 0x58(%r14), %xmm0
ucomisd 0x40(%rbp,%rax), %xmm0
jae 0x23e22
addq %rax, %rbp
movsd 0x38(%rbp), %xmm0
ucomisd 0x68(%r14), %xmm0
jae 0x23e22
movsd 0x60(%r14), %xmm0
ucomisd 0x50(%rbp), %xmm0
jae 0x23e22
movsd 0x48(%rbp), %xmm0
ucomisd 0x70(%r14), %xmm0
jae 0x23e22
xorl %r15d, %r15d
xorl %ecx, %ecx
movslq 0x8(%r14), %rax
decq %rax
cmpq %rax, %rcx
jge 0x23e22
movq %rcx, 0x10(%rsp)
movq 0x28(%r14), %rdi
addq %r15, %rdi
movq %rsi, %rbx
movq %rbp, %rsi
xorl %edx, %edx
leaq 0xf(%rsp), %rcx
callq 0x248be
testl %eax, %eax
jne 0x23e2a
movq %rbx, %rsi
cmpb $0x1, 0xf(%rsp)
jne 0x23e11
movsd 0x18(%rbp), %xmm0
movsd 0x28(%rbp), %xmm1
movsd %xmm0, 0x48(%rsp)
movsd %xmm1, 0x50(%rsp)
movsd 0x20(%rbp), %xmm0
movsd 0x30(%rbp), %xmm1
movsd %xmm0, 0x38(%rsp)
movsd %xmm1, 0x40(%rsp)
movq 0x28(%r14), %rax
leaq (%rax,%r15), %rdi
movsd 0x18(%rax,%r15), %xmm0
movsd 0x28(%rax,%r15), %xmm1
movsd %xmm0, 0x28(%rsp)
movsd %xmm1, 0x30(%rsp)
movsd 0x20(%rax,%r15), %xmm0
movsd 0x30(%rax,%r15), %xmm1
movsd %xmm0, 0x18(%rsp)
movsd %xmm1, 0x20(%rsp)
leaq 0x48(%rsp), %rsi
callq 0x2497e
testl %eax, %eax
jne 0x23e2a
movq 0x28(%r14), %rdi
addq %r15, %rdi
leaq 0x38(%rsp), %rsi
callq 0x2497e
testl %eax, %eax
jne 0x23e2a
movq %rbp, %rdi
leaq 0x28(%rsp), %rsi
callq 0x2497e
testl %eax, %eax
jne 0x23e2a
movq %rbp, %rdi
leaq 0x18(%rsp), %rsi
callq 0x2497e
testl %eax, %eax
movq %rbx, %rsi
jne 0x23e2a
movq 0x10(%rsp), %rcx
incq %rcx
addq $0x58, %r15
jmp 0x23d1d
incq %r13
jmp 0x23cb8
cmpq %r12, %r13
setl %al
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop