// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/common/winding.cpp
// Function: Winding::Check(double) const
vec_t epsilon
#endif
							   ) const
{
    unsigned int    i, j;
    vec_t*          p1;
    vec_t*          p2;
    vec_t           d, edgedist;
    vec3_t          dir, edgenormal, facenormal;
    vec_t           area;
    vec_t           facedist;

    if (m_NumPoints < 3)
    {
        Error("Winding::Check : %i points", m_NumPoints);
    }

    area = getArea();
    if (area < 1)
    {
        Error("Winding::Check : %f area", area);
    }

    getPlane(facenormal, facedist);

    for (i = 0; i < m_NumPoints; i++)
    {
        p1 = m_Points[i];

        for (j = 0; j < 3; j++)
        {
            if (p1[j] > BOGUS_RANGE || p1[j] < -BOGUS_RANGE)
            {
                Error("Winding::Check : BOGUS_RANGE: %f", p1[j]);
            }
        }

        j = i + 1 == m_NumPoints ? 0 : i + 1;

        // check the point is on the face plane
        d = DotProduct(p1, facenormal) - facedist;
        if (d < -ON_EPSILON || d > ON_EPSILON)
        {
            Error("Winding::Check : point off plane");
        }

        // check the edge isn't degenerate
        p2 = m_Points[j];
        VectorSubtract(p2, p1, dir);

        if (VectorLength(dir) < ON_EPSILON)
        {
            Error("Winding::Check : degenerate edge");
        }

        CrossProduct(facenormal, dir, edgenormal);
        VectorNormalize(edgenormal);
        edgedist = DotProduct(p1, edgenormal);
        edgedist += ON_EPSILON;

        // all other points must be on front side
        for (j = 0; j < m_NumPoints; j++)
        {
            if (j == i)
            {
                continue;
            }
            d = DotProduct(m_Points[j], edgenormal);
            if (d > edgedist)
            {
                Error("Winding::Check : non-convex");
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movapd %xmm0, 0x30(%rsp)
movq %rdi, %rbx
movl 0x8(%rdi), %esi
cmpl $0x2, %esi
ja 0xa8b4
leaq 0x119ee(%rip), %rdi     # 0x1c29b
xorl %eax, %eax
callq 0x8d7b
movq %rbx, %rdi
callq 0xa5d6
movsd 0x11794(%rip), %xmm1    # 0x1c058
ucomisd %xmm0, %xmm1
jbe 0xa8d8
leaq 0x119e5(%rip), %rdi     # 0x1c2b6
movb $0x1, %al
callq 0x8d7b
leaq 0x50(%rsp), %rsi
leaq 0xa0(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rdx
callq 0xa4fa
movsd (%r14), %xmm0
movsd %xmm0, 0x68(%rsp)
movapd 0x1193d(%rip), %xmm0    # 0x1c240
xorpd 0x30(%rsp), %xmm0
movapd %xmm0, 0x90(%rsp)
movl 0x8(%rbx), %eax
leaq 0x119b3(%rip), %rbp     # 0x1c2cf
xorl %r14d, %r14d
xorl %ecx, %ecx
movl %eax, %eax
cmpq %rax, %rcx
jae 0xab9d
movq 0x10(%rbx), %r13
movq %rcx, 0x8(%rsp)
imulq $0x18, %rcx, %r12
addq %r13, %r12
addq %r14, %r13
xorl %r15d, %r15d
cmpq $0x3, %r15
je 0xa974
movsd (%r13,%r15,8), %xmm0
movapd %xmm0, %xmm1
andpd 0x118f5(%rip), %xmm1    # 0x1c250
ucomisd 0x11895(%rip), %xmm1    # 0x1c1f8
jbe 0xa96f
movq %rbp, %rdi
movb $0x1, %al
callq 0x8d7b
incq %r15
jmp 0xa942
movl 0x8(%rbx), %r13d
movsd (%r12), %xmm2
movsd 0x8(%r12), %xmm0
movsd 0x58(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd 0x50(%rsp), %xmm4
mulsd %xmm2, %xmm4
addsd %xmm1, %xmm4
movsd 0x10(%r12), %xmm1
movsd 0x60(%rsp), %xmm3
mulsd %xmm1, %xmm3
addsd %xmm4, %xmm3
subsd 0x68(%rsp), %xmm3
movapd 0x90(%rsp), %xmm4
ucomisd %xmm3, %xmm4
ja 0xa9d5
ucomisd 0x30(%rsp), %xmm3
ja 0xa9d5
unpcklpd %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0]
jmp 0xa9f7
leaq 0x11914(%rip), %rdi     # 0x1c2f0
xorl %eax, %eax
callq 0x8d7b
movsd 0x8(%r12), %xmm0
movsd 0x10(%r12), %xmm1
movhpd (%r12), %xmm1           # xmm1 = xmm1[0],mem[0]
leaq 0x11934(%rip), %r15     # 0x1c332
movq 0x8(%rsp), %rcx
incq %rcx
movl %ecx, %eax
movq %rcx, 0x8(%rsp)
cmpq %r13, %rcx
movq 0x10(%rbx), %rcx
movl $0x0, %edx
cmovneq %rax, %rdx
imulq $0x18, %rdx, %rax
movsd 0x8(%rcx,%rax), %xmm3
subsd %xmm0, %xmm3
movsd 0x10(%rcx,%rax), %xmm4
movhpd (%rcx,%rax), %xmm4      # xmm4 = xmm4[0],mem[0]
subpd %xmm1, %xmm4
movapd %xmm3, %xmm0
mulsd %xmm3, %xmm0
movapd %xmm4, %xmm5
unpckhpd %xmm4, %xmm5            # xmm5 = xmm5[1],xmm4[1]
movapd %xmm5, %xmm1
mulsd %xmm5, %xmm1
addsd %xmm0, %xmm1
movapd %xmm4, %xmm0
mulsd %xmm4, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movapd 0x30(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xaaaa
leaq 0x11898(%rip), %rdi     # 0x1c311
xorl %eax, %eax
movapd %xmm3, 0x40(%rsp)
movapd %xmm4, 0x80(%rsp)
movapd %xmm5, 0x70(%rsp)
callq 0x8d7b
movapd 0x70(%rsp), %xmm5
movapd 0x80(%rsp), %xmm4
movapd 0x40(%rsp), %xmm3
movsd 0x50(%rsp), %xmm0
movupd 0x58(%rsp), %xmm1
movapd %xmm1, %xmm2
shufpd $0x1, %xmm0, %xmm2      # xmm2 = xmm2[1],xmm0[0]
mulsd %xmm3, %xmm0
unpcklpd %xmm4, %xmm3            # xmm3 = xmm3[0],xmm4[0]
mulpd %xmm2, %xmm3
mulpd %xmm1, %xmm4
subpd %xmm3, %xmm4
movapd %xmm4, 0x10(%rsp)
mulsd %xmm1, %xmm5
subsd %xmm5, %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x10(%rsp), %rdi
callq 0xc2e9
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
mulsd 0x18(%rsp), %xmm1
mulsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd 0x10(%r12), %xmm3
mulsd 0x20(%rsp), %xmm3
addsd %xmm0, %xmm3
addsd 0x30(%rsp), %xmm3
xorl %r12d, %r12d
xorl %r13d, %r13d
movsd %xmm3, 0x40(%rsp)
movl 0x8(%rbx), %eax
cmpq %rax, %r13
jae 0xab8f
cmpq %r12, %r14
je 0xab86
movq 0x10(%rbx), %rax
movsd (%rax,%r12), %xmm0
movsd 0x8(%rax,%r12), %xmm1
mulsd 0x18(%rsp), %xmm1
mulsd 0x10(%rsp), %xmm0
movsd 0x10(%rax,%r12), %xmm2
mulsd 0x20(%rsp), %xmm2
addsd %xmm1, %xmm0
addsd %xmm0, %xmm2
ucomisd %xmm3, %xmm2
jbe 0xab86
movq %r15, %rdi
xorl %eax, %eax
callq 0x8d7b
movsd 0x40(%rsp), %xmm3
incq %r13
addq $0x18, %r12
jmp 0xab31
addq $0x18, %r14
movq 0x8(%rsp), %rcx
jmp 0xa921
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop