// File: /workspace/github_cpp_makefile_star2_O3/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)
movl 0x8(%rsi), %eax
cmpl $0x2, %eax
jl 0x28b41
movq %rsi, %rbx
movq %rdi, %r14
xorl %r13d, %r13d
movq 0x28(%rbx), %r12
imulq $0x58, %r13, %rcx
movsd 0x58(%r14), %xmm0
ucomisd 0x40(%r12,%rcx), %xmm0
jae 0x28b2f
addq %rcx, %r12
movsd 0x38(%r12), %xmm0
ucomisd 0x68(%r14), %xmm0
jae 0x28b2f
movsd 0x60(%r14), %xmm0
ucomisd 0x50(%r12), %xmm0
jae 0x28b2f
movsd 0x48(%r12), %xmm0
ucomisd 0x70(%r14), %xmm0
jae 0x28b2f
cmpl $0x2, 0x8(%r14)
jl 0x28b2f
xorl %ebp, %ebp
xorl %r15d, %r15d
movq 0x28(%r14), %rdi
addq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
leaq 0x7(%rsp), %rcx
callq 0x295b6
movl %eax, %ecx
movb $0x1, %al
testl %ecx, %ecx
jne 0x28b43
cmpb $0x1, 0x7(%rsp)
jne 0x28b15
movsd 0x18(%r12), %xmm3
movsd 0x20(%r12), %xmm0
movsd 0x28(%r12), %xmm4
movsd 0x30(%r12), %xmm2
movq 0x28(%r14), %rcx
movsd 0x18(%rcx,%rbp), %xmm6
movsd 0x20(%rcx,%rbp), %xmm1
movsd 0x28(%rcx,%rbp), %xmm7
movsd 0x30(%rcx,%rbp), %xmm5
movsd 0x38(%rcx,%rbp), %xmm9
ucomisd %xmm3, %xmm9
movsd 0x40(%rcx,%rbp), %xmm8
ja 0x2894e
ucomisd %xmm8, %xmm3
ja 0x2894e
movsd 0x48(%rcx,%rbp), %xmm10
ucomisd %xmm4, %xmm10
ja 0x2894e
ucomisd 0x50(%rcx,%rbp), %xmm4
ja 0x2894e
movapd %xmm3, %xmm10
unpcklpd %xmm4, %xmm10           # xmm10 = xmm10[0],xmm4[0]
movapd %xmm6, %xmm11
unpcklpd %xmm7, %xmm11           # xmm11 = xmm11[0],xmm7[0]
movapd %xmm10, %xmm12
subpd %xmm11, %xmm12
andpd 0x15734(%rip), %xmm12   # 0x3e030
pshufd $0xee, %xmm12, %xmm11   # xmm11 = xmm12[2,3,2,3]
addsd %xmm12, %xmm11
movsd 0x15788(%rip), %xmm12   # 0x3e098
ucomisd %xmm11, %xmm12
ja 0x2894e
movapd %xmm1, %xmm11
unpcklpd %xmm5, %xmm11           # xmm11 = xmm11[0],xmm5[0]
subpd %xmm11, %xmm10
andpd 0x15701(%rip), %xmm10   # 0x3e030
pshufd $0xee, %xmm10, %xmm11   # xmm11 = xmm10[2,3,2,3]
addsd %xmm10, %xmm11
movsd 0x15755(%rip), %xmm10   # 0x3e098
ucomisd %xmm11, %xmm10
jbe 0x28b43
ucomisd %xmm0, %xmm9
ja 0x289f7
ucomisd %xmm8, %xmm0
ja 0x289f7
movsd 0x48(%rcx,%rbp), %xmm8
ucomisd %xmm2, %xmm8
ja 0x289f7
ucomisd 0x50(%rcx,%rbp), %xmm2
ja 0x289f7
movapd %xmm0, %xmm8
unpcklpd %xmm2, %xmm8            # xmm8 = xmm8[0],xmm2[0]
movapd %xmm6, %xmm9
unpcklpd %xmm7, %xmm9            # xmm9 = xmm9[0],xmm7[0]
movapd %xmm8, %xmm10
subpd %xmm9, %xmm10
andpd 0x1568b(%rip), %xmm10   # 0x3e030
pshufd $0xee, %xmm10, %xmm9    # xmm9 = xmm10[2,3,2,3]
addsd %xmm10, %xmm9
movsd 0x156df(%rip), %xmm10   # 0x3e098
ucomisd %xmm9, %xmm10
ja 0x289f7
movapd %xmm1, %xmm9
unpcklpd %xmm5, %xmm9            # xmm9 = xmm9[0],xmm5[0]
subpd %xmm9, %xmm8
andpd 0x15658(%rip), %xmm8    # 0x3e030
pshufd $0xee, %xmm8, %xmm9     # xmm9 = xmm8[2,3,2,3]
addsd %xmm8, %xmm9
movsd 0x156ac(%rip), %xmm8    # 0x3e098
ucomisd %xmm9, %xmm8
jbe 0x28b43
movsd 0x38(%r12), %xmm9
movsd 0x40(%r12), %xmm8
ucomisd %xmm6, %xmm9
ja 0x28a9b
ucomisd %xmm8, %xmm6
ja 0x28a9b
movsd 0x48(%r12), %xmm10
ucomisd %xmm7, %xmm10
ja 0x28a9b
ucomisd 0x50(%r12), %xmm7
ja 0x28a9b
unpcklpd %xmm7, %xmm6            # xmm6 = xmm6[0],xmm7[0]
movapd %xmm3, %xmm7
unpcklpd %xmm4, %xmm7            # xmm7 = xmm7[0],xmm4[0]
movapd %xmm6, %xmm10
subpd %xmm7, %xmm10
andpd 0x155df(%rip), %xmm10   # 0x3e030
pshufd $0xee, %xmm10, %xmm7    # xmm7 = xmm10[2,3,2,3]
addsd %xmm10, %xmm7
movsd 0x15633(%rip), %xmm10   # 0x3e098
ucomisd %xmm7, %xmm10
ja 0x28a9b
movapd %xmm0, %xmm7
unpcklpd %xmm2, %xmm7            # xmm7 = xmm7[0],xmm2[0]
subpd %xmm7, %xmm6
andpd 0x155b0(%rip), %xmm6    # 0x3e030
pshufd $0xee, %xmm6, %xmm7     # xmm7 = xmm6[2,3,2,3]
addsd %xmm6, %xmm7
movsd 0x15607(%rip), %xmm6    # 0x3e098
ucomisd %xmm7, %xmm6
jbe 0x28b43
ucomisd %xmm1, %xmm9
ja 0x28b15
ucomisd %xmm8, %xmm1
ja 0x28b15
movsd 0x48(%r12), %xmm6
ucomisd %xmm5, %xmm6
ja 0x28b15
ucomisd 0x50(%r12), %xmm5
ja 0x28b15
unpcklpd %xmm5, %xmm1            # xmm1 = xmm1[0],xmm5[0]
unpcklpd %xmm4, %xmm3            # xmm3 = xmm3[0],xmm4[0]
movapd %xmm1, %xmm4
subpd %xmm3, %xmm4
andpd 0x15559(%rip), %xmm4    # 0x3e030
pshufd $0xee, %xmm4, %xmm3     # xmm3 = xmm4[2,3,2,3]
addsd %xmm4, %xmm3
movsd 0x155b0(%rip), %xmm4    # 0x3e098
ucomisd %xmm3, %xmm4
ja 0x28b15
unpcklpd %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0]
subpd %xmm0, %xmm1
andpd 0x15532(%rip), %xmm1    # 0x3e030
pshufd $0xee, %xmm1, %xmm0     # xmm0 = xmm1[2,3,2,3]
addsd %xmm1, %xmm0
movsd 0x15589(%rip), %xmm1    # 0x3e098
ucomisd %xmm0, %xmm1
jbe 0x28b43
incq %r15
movslq 0x8(%r14), %rax
decq %rax
addq $0x58, %rbp
cmpq %rax, %r15
jl 0x28832
movl 0x8(%rbx), %eax
incq %r13
leal -0x1(%rax), %ecx
movslq %ecx, %rcx
cmpq %rcx, %r13
jl 0x287cb
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq