// File: 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:
subq $0xb8, %rsp
movq %rdi, 0xb0(%rsp)
movsd %xmm0, 0xa8(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpl $0x3, 0x8(%rax)
jae 0xe811
movq 0x8(%rsp), %rax
movl 0x8(%rax), %esi
leaq 0x1ecd1(%rip), %rdi     # 0x2d4db
movb $0x0, %al
callq 0xba80
movq 0x8(%rsp), %rdi
callq 0xe200
movsd %xmm0, 0x18(%rsp)
movsd 0x1e94f(%rip), %xmm0    # 0x2d178
ucomisd 0x18(%rsp), %xmm0
jbe 0xe845
movsd 0x18(%rsp), %xmm0
leaq 0x1ecb8(%rip), %rdi     # 0x2d4f6
movb $0x1, %al
callq 0xba80
movq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0xdfe0
movl $0x0, 0xa4(%rsp)
movq 0x8(%rsp), %rcx
movl 0xa4(%rsp), %eax
cmpl 0x8(%rcx), %eax
jae 0xed02
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movl 0xa4(%rsp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x98(%rsp)
movl $0x0, 0xa0(%rsp)
cmpl $0x3, 0xa0(%rsp)
jae 0xe927
movq 0x98(%rsp), %rax
movl 0xa0(%rsp), %ecx
movsd (%rax,%rcx,8), %xmm0
movsd 0x1ebcf(%rip), %xmm1    # 0x2d498
ucomisd %xmm1, %xmm0
ja 0xe8ed
movq 0x98(%rsp), %rax
movl 0xa0(%rsp), %ecx
movsd 0x1ebba(%rip), %xmm0    # 0x2d4a0
ucomisd (%rax,%rcx,8), %xmm0
jbe 0xe90f
movq 0x98(%rsp), %rax
movl 0xa0(%rsp), %ecx
movsd (%rax,%rcx,8), %xmm0
leaq 0x1ec07(%rip), %rdi     # 0x2d50f
movb $0x1, %al
callq 0xba80
jmp 0xe911
movl 0xa0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa0(%rsp)
jmp 0xe8a3
movq 0x8(%rsp), %rcx
movl 0xa4(%rsp), %eax
addl $0x1, %eax
cmpl 0x8(%rcx), %eax
jne 0xe943
xorl %eax, %eax
movl %eax, 0x4(%rsp)
jmp 0xe951
movl 0xa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
movl 0x4(%rsp), %eax
movl %eax, 0xa0(%rsp)
movq 0x98(%rsp), %rax
movsd (%rax), %xmm1
movsd 0x20(%rsp), %xmm2
movq 0x98(%rsp), %rax
movsd 0x8(%rax), %xmm0
mulsd 0x28(%rsp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movq 0x98(%rsp), %rax
movsd 0x10(%rax), %xmm0
movsd 0x30(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
subsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x88(%rsp)
movsd 0x88(%rsp), %xmm1
movsd 0xa8(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
ucomisd %xmm1, %xmm0
ja 0xe9f6
movsd 0x88(%rsp), %xmm0
ucomisd 0xa8(%rsp), %xmm0
jbe 0xea04
leaq 0x1eb33(%rip), %rdi     # 0x2d530
movb $0x0, %al
callq 0xba80
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movl 0xa0(%rsp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rax
movsd (%rax), %xmm0
movq 0x98(%rsp), %rax
subsd (%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x90(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0x98(%rsp), %rax
subsd 0x8(%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
movq 0x90(%rsp), %rax
movsd 0x10(%rax), %xmm0
movq 0x98(%rsp), %rax
subsd 0x10(%rax), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x60(%rsp), %xmm1
movsd 0x60(%rsp), %xmm2
movsd 0x68(%rsp), %xmm0
mulsd 0x68(%rsp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x70(%rsp), %xmm0
movsd 0x70(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x42f0
movaps %xmm0, %xmm1
movsd 0xa8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xeada
leaq 0x1ea7e(%rip), %rdi     # 0x2d551
movb $0x0, %al
callq 0xba80
movsd 0x28(%rsp), %xmm0
movsd 0x70(%rsp), %xmm2
movsd 0x30(%rsp), %xmm1
mulsd 0x68(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x30(%rsp), %xmm0
movsd 0x60(%rsp), %xmm2
movsd 0x20(%rsp), %xmm1
mulsd 0x70(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x20(%rsp), %xmm0
movsd 0x68(%rsp), %xmm2
movsd 0x28(%rsp), %xmm1
mulsd 0x60(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x121b0
movq 0x98(%rsp), %rax
movsd (%rax), %xmm1
movsd 0x40(%rsp), %xmm2
movq 0x98(%rsp), %rax
movsd 0x8(%rax), %xmm0
mulsd 0x48(%rsp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movq 0x98(%rsp), %rax
movsd 0x10(%rax), %xmm0
movsd 0x50(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0xa8(%rsp), %xmm0
addsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movl $0x0, 0xa0(%rsp)
movq 0x8(%rsp), %rcx
movl 0xa0(%rsp), %eax
cmpl 0x8(%rcx), %eax
jae 0xecea
movl 0xa0(%rsp), %eax
cmpl 0xa4(%rsp), %eax
jne 0xec3c
jmp 0xecd4
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rcx
movl 0xa0(%rsp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movsd (%rcx), %xmm1
movsd 0x40(%rsp), %xmm2
movq 0x10(%rax), %rcx
movl 0xa0(%rsp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movsd 0x8(%rcx), %xmm0
mulsd 0x48(%rsp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movq 0x10(%rax), %rax
movl 0xa0(%rsp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movsd 0x50(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x88(%rsp)
movsd 0x88(%rsp), %xmm0
ucomisd 0x80(%rsp), %xmm0
jbe 0xecd2
leaq 0x1e8a7(%rip), %rdi     # 0x2d572
movb $0x0, %al
callq 0xba80
jmp 0xecd4
movl 0xa0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa0(%rsp)
jmp 0xec12
jmp 0xecec
movl 0xa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
jmp 0xe864
addq $0xb8, %rsp
retq
nopw (%rax,%rax)