// File: thierry7100[P]CutOptim/src/SvgDoc.cpp
// Function: CheckAnglesOnEdge(Polygon*, int, Polygon*, int)
static bool CheckAnglesOnEdge(Polygon *mP, int idx_m, Polygon *fP, int idx_f)
{
double sm1, sm2;        //  Slopes for moving (new) polygon at requested vertex (just before and after)
double sf1, sf2;        //  Slopes for fixed polygon at requested vertex (just before and after)

    if ( idx_m == 0)
    {
        //  Arrival segment, angle is pi + slope, and if angle is greater than pi, substract 2*pi to keep value between -pi and +pi
        sm1 = mP->getSlope(mP->nVertices-2) + M_PI;
        if ( sm1 > M_PI ) sm1 -= 2*M_PI;
        sm2 = mP->getSlope(0);
    }
    else
    {
        //  Arrival segment, angle is pi + slope, and if angle is greater than pi, substract 2*pi to keep value between -pi and +pi
        sm1 = mP->getSlope(idx_m-1) + M_PI;
        if ( sm1 > M_PI ) sm1 -= 2*M_PI;
        sm2 = mP->getSlope(idx_m);
    }
    //  In this case on an edge, same angle with +PI as difference
    //  Arrival segment, angle is pi + slope, and if angle is greater than pi, substract 2*pi to keep value between -pi and +pi
    sf1 = fP->getSlope(idx_f) + M_PI;
    if ( sf1 > M_PI ) sf1 -= 2*M_PI;
    sf2 = fP->getSlope(idx_f);
    //  check if sm1 is OK, given angles sf1 and sf2
    int res1 = CheckOKAngles(sf1, sf2, sm1);
    if ( res1 == 0 ) return false;
    //  Idem with sm2
    int res2 = CheckOKAngles(sf1, sf2, sm2);
    if (res2 == 0 ) return false;
    //  Also check sf1 upon sm1 and sm2
    int res3 = CheckOKAngles(sm1, sm2, sf1);
    if ( res3 == 0 ) return false;
    //  and finally sf2 upon sm1 and sm2
    int res4 = CheckOKAngles(sm1, sm2, sf2);
    if (res4 == 0 ) return false;
    //  All is OK, return true
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x72f5b
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
subl $0x2, %esi
callq 0x80590
movsd 0xf101(%rip), %xmm1     # 0x82018
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movsd 0xf0eb(%rip), %xmm1     # 0x82018
ucomisd %xmm1, %xmm0
jbe 0x72f49
movsd -0x30(%rbp), %xmm0
movsd 0x11260(%rip), %xmm1    # 0x841a0
subsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x80590
movsd %xmm0, -0x38(%rbp)
jmp 0x72fb5
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
subl $0x1, %esi
callq 0x80590
movsd 0xf0a6(%rip), %xmm1     # 0x82018
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movsd 0xf090(%rip), %xmm1     # 0x82018
ucomisd %xmm1, %xmm0
jbe 0x72fa4
movsd -0x30(%rbp), %xmm0
movsd 0x11205(%rip), %xmm1    # 0x841a0
subsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x80590
movsd %xmm0, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x80590
movsd 0xf04f(%rip), %xmm1     # 0x82018
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movsd 0xf039(%rip), %xmm1     # 0x82018
ucomisd %xmm1, %xmm0
jbe 0x72ffb
movsd -0x40(%rbp), %xmm0
movsd 0x111ae(%rip), %xmm1    # 0x841a0
subsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x80590
movsd %xmm0, -0x48(%rbp)
movsd -0x40(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
callq 0x6dad0
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jne 0x73034
movb $0x0, -0x1(%rbp)
jmp 0x730b0
movsd -0x40(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
callq 0x6dad0
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
jne 0x7305c
movb $0x0, -0x1(%rbp)
jmp 0x730b0
movsd -0x30(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x40(%rbp), %xmm2
callq 0x6dad0
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0x73084
movb $0x0, -0x1(%rbp)
jmp 0x730b0
movsd -0x30(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x48(%rbp), %xmm2
callq 0x6dad0
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
jne 0x730ac
movb $0x0, -0x1(%rbp)
jmp 0x730b0
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)