// File: thierry7100[P]CutOptim/src/SvgDoc.cpp
// Function: CheckAngles(Polygon*, int, Polygon*, int)
static bool CheckAngles(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);
    }
    if ( idx_f == 0)
    {
        //  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(fP->nVertices-2) + M_PI;
        if ( sf1 > M_PI ) sf1 -= 2*M_PI;
        sf2 = fP->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
        sf1 = fP->getSlope(idx_f-1) + 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 0x724bb
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
subl $0x2, %esi
callq 0x80590
movsd 0xfba1(%rip), %xmm1     # 0x82018
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movsd 0xfb8b(%rip), %xmm1     # 0x82018
ucomisd %xmm1, %xmm0
jbe 0x724a9
movsd -0x30(%rbp), %xmm0
movsd 0x11d00(%rip), %xmm1    # 0x841a0
subsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x80590
movsd %xmm0, -0x38(%rbp)
jmp 0x72515
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
subl $0x1, %esi
callq 0x80590
movsd 0xfb46(%rip), %xmm1     # 0x82018
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movsd 0xfb30(%rip), %xmm1     # 0x82018
ucomisd %xmm1, %xmm0
jbe 0x72504
movsd -0x30(%rbp), %xmm0
movsd 0x11ca5(%rip), %xmm1    # 0x841a0
subsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x80590
movsd %xmm0, -0x38(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x7257a
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
subl $0x2, %esi
callq 0x80590
movsd 0xfae2(%rip), %xmm1     # 0x82018
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movsd 0xfacc(%rip), %xmm1     # 0x82018
ucomisd %xmm1, %xmm0
jbe 0x72568
movsd -0x40(%rbp), %xmm0
movsd 0x11c41(%rip), %xmm1    # 0x841a0
subsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x80590
movsd %xmm0, -0x48(%rbp)
jmp 0x725d4
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
subl $0x1, %esi
callq 0x80590
movsd 0xfa87(%rip), %xmm1     # 0x82018
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movsd 0xfa71(%rip), %xmm1     # 0x82018
ucomisd %xmm1, %xmm0
jbe 0x725c3
movsd -0x40(%rbp), %xmm0
movsd 0x11be6(%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 0x725fc
movb $0x0, -0x1(%rbp)
jmp 0x72678
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 0x72624
movb $0x0, -0x1(%rbp)
jmp 0x72678
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 0x7264c
movb $0x0, -0x1(%rbp)
jmp 0x72678
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 0x72674
movb $0x0, -0x1(%rbp)
jmp 0x72678
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)