// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %rax
movb $0x0, 0x7(%rsp)
cmpl $0x2, 0x8(%rsi)
setge %al
jl 0x29376
movq %rsi, %rbx
movq %rdi, %r15
xorl %ebp, %ebp
movb %al, 0x6(%rsp)
movq 0x28(%rbx), %r13
imulq $0x58, %rbp, %rax
movsd 0x58(%r15), %xmm0
ucomisd 0x40(%r13,%rax), %xmm0
jae 0x2935a
addq %rax, %r13
movsd 0x38(%r13), %xmm0
ucomisd 0x68(%r15), %xmm0
jae 0x2935a
movsd 0x60(%r15), %xmm0
ucomisd 0x50(%r13), %xmm0
jae 0x2935a
movsd 0x48(%r13), %xmm0
ucomisd 0x70(%r15), %xmm0
jae 0x2935a
cmpl $0x2, 0x8(%r15)
jl 0x2935a
xorl %r12d, %r12d
xorl %r14d, %r14d
movq 0x28(%r15), %rdi
addq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
leaq 0x7(%rsp), %rcx
callq 0x29f70
testl %eax, %eax
jne 0x29372
cmpb $0x1, 0x7(%rsp)
jne 0x29343
movsd 0x18(%r13), %xmm5
movsd 0x20(%r13), %xmm3
movsd 0x28(%r13), %xmm4
movsd 0x30(%r13), %xmm1
movq 0x28(%r15), %rax
movsd 0x18(%rax,%r12), %xmm6
movsd 0x20(%rax,%r12), %xmm0
movsd 0x28(%rax,%r12), %xmm7
movsd 0x30(%rax,%r12), %xmm2
movsd 0x38(%rax,%r12), %xmm9
ucomisd %xmm5, %xmm9
movsd 0x40(%rax,%r12), %xmm8
ja 0x29174
ucomisd %xmm8, %xmm5
ja 0x29174
movsd 0x48(%rax,%r12), %xmm10
ucomisd %xmm4, %xmm10
ja 0x29174
ucomisd 0x50(%rax,%r12), %xmm4
ja 0x29174
movapd %xmm5, %xmm10
subsd %xmm6, %xmm10
movapd 0x15f25(%rip), %xmm12   # 0x3f030
andpd %xmm12, %xmm10
movapd %xmm4, %xmm11
subsd %xmm7, %xmm11
andpd %xmm12, %xmm11
addsd %xmm10, %xmm11
movsd 0x15fcb(%rip), %xmm10   # 0x3f0f8
ucomisd %xmm11, %xmm10
ja 0x29174
movapd %xmm5, %xmm10
subsd %xmm0, %xmm10
movapd 0x15ee9(%rip), %xmm12   # 0x3f030
andpd %xmm12, %xmm10
movapd %xmm4, %xmm11
subsd %xmm2, %xmm11
andpd %xmm12, %xmm11
addsd %xmm10, %xmm11
movsd 0x15f8f(%rip), %xmm10   # 0x3f0f8
ucomisd %xmm11, %xmm10
jbe 0x29372
ucomisd %xmm3, %xmm9
ja 0x29221
ucomisd %xmm8, %xmm3
ja 0x29221
movsd 0x48(%rax,%r12), %xmm8
ucomisd %xmm1, %xmm8
ja 0x29221
ucomisd 0x50(%rax,%r12), %xmm1
ja 0x29221
movapd %xmm3, %xmm8
subsd %xmm6, %xmm8
movapd 0x15e78(%rip), %xmm10   # 0x3f030
andpd %xmm10, %xmm8
movapd %xmm1, %xmm9
subsd %xmm7, %xmm9
andpd %xmm10, %xmm9
addsd %xmm8, %xmm9
movsd 0x15f1e(%rip), %xmm8    # 0x3f0f8
ucomisd %xmm9, %xmm8
ja 0x29221
movapd %xmm3, %xmm8
subsd %xmm0, %xmm8
movapd 0x15e3c(%rip), %xmm10   # 0x3f030
andpd %xmm10, %xmm8
movapd %xmm1, %xmm9
subsd %xmm2, %xmm9
andpd %xmm10, %xmm9
addsd %xmm8, %xmm9
movsd 0x15ee2(%rip), %xmm8    # 0x3f0f8
ucomisd %xmm9, %xmm8
jbe 0x29372
movsd 0x38(%r13), %xmm9
movsd 0x40(%r13), %xmm8
ucomisd %xmm6, %xmm9
ja 0x292c5
ucomisd %xmm8, %xmm6
ja 0x292c5
movsd 0x48(%r13), %xmm10
ucomisd %xmm7, %xmm10
ja 0x292c5
ucomisd 0x50(%r13), %xmm7
ja 0x292c5
movapd %xmm6, %xmm10
subsd %xmm5, %xmm10
movapd 0x15dc5(%rip), %xmm12   # 0x3f030
andpd %xmm12, %xmm10
movapd %xmm7, %xmm11
subsd %xmm4, %xmm11
andpd %xmm12, %xmm11
addsd %xmm10, %xmm11
movsd 0x15e6b(%rip), %xmm10   # 0x3f0f8
ucomisd %xmm11, %xmm10
ja 0x292c5
subsd %xmm3, %xmm6
movapd 0x15d8f(%rip), %xmm10   # 0x3f030
andpd %xmm10, %xmm6
subsd %xmm1, %xmm7
andpd %xmm10, %xmm7
addsd %xmm6, %xmm7
movsd 0x15e3d(%rip), %xmm6    # 0x3f0f8
ucomisd %xmm7, %xmm6
jbe 0x29372
ucomisd %xmm0, %xmm9
ja 0x29343
ucomisd %xmm8, %xmm0
ja 0x29343
movsd 0x48(%r13), %xmm6
ucomisd %xmm2, %xmm6
ja 0x29343
ucomisd 0x50(%r13), %xmm2
ja 0x29343
movapd %xmm0, %xmm6
subsd %xmm5, %xmm6
movapd 0x15d39(%rip), %xmm7    # 0x3f030
andpd %xmm7, %xmm6
movapd %xmm2, %xmm5
subsd %xmm4, %xmm5
andpd %xmm7, %xmm5
addsd %xmm6, %xmm5
movsd 0x15de5(%rip), %xmm4    # 0x3f0f8
ucomisd %xmm5, %xmm4
ja 0x29343
subsd %xmm3, %xmm0
movapd 0x15d0b(%rip), %xmm3    # 0x3f030
andpd %xmm3, %xmm0
subsd %xmm1, %xmm2
andpd %xmm3, %xmm2
addsd %xmm0, %xmm2
movsd 0x15dbb(%rip), %xmm0    # 0x3f0f8
ucomisd %xmm2, %xmm0
jbe 0x29372
incq %r14
movslq 0x8(%r15), %rax
decq %rax
addq $0x58, %r12
cmpq %rax, %r14
jl 0x29058
incq %rbp
movslq 0x8(%rbx), %rax
decq %rax
cmpq %rax, %rbp
setl %al
jl 0x28fef
jmp 0x29376
movb 0x6(%rsp), %al
andb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop