// File: thierry7100[P]CutOptim/src/Geometry.cpp
// Function: Polygon::getCentroid()
Point Polygon::getCentroid()
{
double p_area;
double cx = 0, cy = 0;

    if ( poly_changed ) poly_centroid_ok = 0;
    if ( poly_centroid_ok == 0 )    //  Not yet computed, do it
    {
        p_area = area();
        for ( int i = 0; i < nVertices - 1; i++)
        {
            double d = _Vertices[i].x*_Vertices[i+1].y - _Vertices[i+1].x*_Vertices[i].y;
            cx += (_Vertices[i].x + _Vertices[i+1].x)*d;
            cy += (_Vertices[i].y + _Vertices[i+1].y)*d;
        }
        cx /= 6*p_area;
        cy /= 6*p_area;
        poly_centroid = Point(cx, cy);
        poly_centroid_ok = 1;
    }
    return poly_centroid;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
cmpl $0x0, 0x9c(%rax)
je 0x615de
movq -0x58(%rbp), %rax
movl $0x0, 0x90(%rax)
movq -0x58(%rbp), %rax
cmpl $0x0, 0x90(%rax)
jne 0x617d8
movq -0x58(%rbp), %rdi
callq 0x5ed10
movsd %xmm0, -0x20(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x58(%rbp), %rcx
movl -0x34(%rbp), %eax
movl 0x8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x6176b
movq -0x58(%rbp), %rdi
addq $0x10, %rdi
movslq -0x34(%rbp), %rsi
callq 0x63990
movq -0x58(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
addq $0x10, %rdi
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x63990
movq -0x58(%rbp), %rdi
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
addq $0x10, %rdi
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x63990
movq -0x58(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
addq $0x10, %rdi
movslq -0x34(%rbp), %rsi
callq 0x63990
movsd -0x80(%rbp), %xmm1
movsd -0x78(%rbp), %xmm0
movsd -0x70(%rbp), %xmm2
movq -0x58(%rbp), %rdi
mulsd 0x8(%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
addq $0x10, %rdi
movslq -0x34(%rbp), %rsi
callq 0x63990
movq -0x58(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
addq $0x10, %rdi
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x63990
movsd -0x68(%rbp), %xmm0
movq -0x58(%rbp), %rdi
addsd (%rax), %xmm0
movsd -0x40(%rbp), %xmm2
movsd -0x28(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
addq $0x10, %rdi
movslq -0x34(%rbp), %rsi
callq 0x63990
movq -0x58(%rbp), %rdi
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
addq $0x10, %rdi
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x63990
movsd -0x60(%rbp), %xmm0
addsd 0x8(%rax), %xmm0
movsd -0x40(%rbp), %xmm2
movsd -0x30(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x61604
movsd 0x229a5(%rip), %xmm1    # 0x84118
mulsd -0x20(%rbp), %xmm1
movsd -0x28(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd 0x2298a(%rip), %xmm1    # 0x84118
mulsd -0x20(%rbp), %xmm1
movsd -0x30(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x28(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
leaq -0x50(%rbp), %rdi
callq 0x5b520
movq -0x58(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, 0x80(%rax)
movq -0x48(%rbp), %rcx
movq %rcx, 0x88(%rax)
movl $0x1, 0x90(%rax)
movq -0x58(%rbp), %rax
movups 0x80(%rax), %xmm0
movaps %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
movsd -0x8(%rbp), %xmm1
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)