// File: /workspace/github_cpp_makefile_star2_O2/thierry7100[P]CutOptim/src/Geometry.cpp
// Function: Polygon::Rotate(double)
Polygon *Polygon::Rotate(double angle)
{
Polygon *Rotated = new Polygon;
double cos_a = cos(angle);
double sin_a = sin(angle);
double xmin = 0, xmax = 0, ymin = 0, ymax = 0;

    nbRotatedPoly++;
    nbCreatedRotatedPoly++;
    Rotated->TypePoly = RotatedPoly;
    if ( poly_centroid_ok == 0 ) getCentroid();
    Rotated->precision = precision;
    Rotated->pt_Translation = pt_Translation;
    Rotated->_Vertices = _Vertices;          //      Copy vertice vector
    Rotated->nVertices = Rotated->_Vertices.size();

    for ( int i = 0; i < nVertices; i++)
    {
        double newx = (_Vertices[i].x - poly_centroid.x) * cos_a - (_Vertices[i].y - poly_centroid.y)* sin_a + poly_centroid.x;
        newx = round(newx/precision)*precision;
        Rotated->_Vertices[i].x = newx;
        double newy = (_Vertices[i].x - poly_centroid.x) * sin_a + (_Vertices[i].y - poly_centroid.y)* cos_a + poly_centroid.y;
        newy = round(newy/precision)*precision;
        Rotated->_Vertices[i].y = newy;
        if ( i == 0 )
        {
            xmin = newx;
            xmax = newx;
            ymin = newy;
            ymax = newy;
        }
        else
        {
            if ( newx < xmin ) xmin = newx;
            if ( newy < ymin ) ymin = newy;
            if ( newx > xmax ) xmax = newx;
            if ( newy > ymax ) ymax = newy;
        }
    }
    Rotated->BoundingBox.A = Point(xmin, ymin);
    Rotated->BoundingBox.B = Point(xmax, ymax);
    Rotated->poly_area = poly_area;
    Rotated->poly_centroid = poly_centroid;
    Rotated->angle_rotation = angle;
    Rotated->poly_centroid_ok = 1;
    Rotated->poly_changed = 0;
    Rotated->poly_closed = poly_closed;
    Rotated->poly_clockwise = poly_clockwise;
    return Rotated;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movsd %xmm0, (%rsp)
movq %rdi, %rbx
movl $0xc0, %edi
callq 0x8440
movq %rax, %r14
movq %rax, %rdi
callq 0x21f2c
movsd (%rsp), %xmm0
callq 0x87d0
movsd %xmm0, 0x18(%rsp)
movsd (%rsp), %xmm0
callq 0x80e0
incq 0x2a2bc(%rip)           # 0x4da40
incq 0x2a2e5(%rip)           # 0x4da70
movsd %xmm0, 0x10(%rsp)
movl $0x2, 0xc(%r14)
cmpl $0x0, 0x90(%rbx)
jne 0x237aa
movq %rbx, %rdi
callq 0x233aa
movsd 0xa0(%rbx), %xmm0
movsd %xmm0, 0xa0(%r14)
movups 0xb0(%rbx), %xmm0
movups %xmm0, 0xb0(%r14)
leaq 0x10(%rbx), %rsi
movq %r14, %rdi
addq $0x10, %rdi
callq 0x246f4
movq 0x10(%r14), %r15
movq 0x18(%r14), %rax
subq %r15, %rax
shrq $0x4, %rax
movl %eax, 0x8(%r14)
movl 0x8(%rbx), %r13d
movq 0x10(%rbx), %rbp
leaq 0x80(%rbx), %rax
movq %rax, 0x30(%rsp)
movsd 0xa0(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %r12d, %r12d
testl %r13d, %r13d
cmovlel %r12d, %r13d
shlq $0x4, %r13
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
xorpd %xmm2, %xmm2
cmpq %r12, %r13
je 0x2392c
movsd %xmm2, 0x38(%rsp)
movapd %xmm1, 0x50(%rsp)
movsd %xmm0, 0x40(%rsp)
movsd (%rbp,%r12), %xmm0
movsd 0x8(%rbp,%r12), %xmm3
movsd 0x80(%rbx), %xmm1
movsd 0x88(%rbx), %xmm2
movsd %xmm2, 0x48(%rsp)
subsd %xmm1, %xmm0
subsd %xmm2, %xmm3
movsd %xmm3, 0x20(%rsp)
movsd 0x10(%rsp), %xmm2
mulsd %xmm3, %xmm2
mulsd 0x18(%rsp), %xmm0
subsd %xmm2, %xmm0
addsd %xmm1, %xmm0
divsd 0x8(%rsp), %xmm0
callq 0x81a0
movsd 0x20(%rsp), %xmm2
mulsd 0x18(%rsp), %xmm2
movsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm0
movapd %xmm0, 0x20(%rsp)
movsd %xmm0, (%r15,%r12)
movsd (%rbp,%r12), %xmm0
subsd 0x80(%rbx), %xmm0
mulsd 0x10(%rsp), %xmm0
addsd %xmm2, %xmm0
addsd 0x48(%rsp), %xmm0
divsd %xmm1, %xmm0
callq 0x81a0
movapd 0x20(%rsp), %xmm3
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%r15,%r12)
movapd %xmm3, %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
testq %r12, %r12
je 0x2391f
minpd 0x50(%rsp), %xmm1
maxsd 0x38(%rsp), %xmm3
movsd 0x40(%rsp), %xmm2
ucomisd %xmm2, %xmm0
ja 0x2391f
movapd %xmm2, %xmm0
addq $0x10, %r12
movapd %xmm3, %xmm2
jmp 0x23829
movupd %xmm1, 0x58(%r14)
movsd %xmm2, 0x68(%r14)
movsd %xmm0, 0x70(%r14)
movsd 0x78(%rbx), %xmm0
movsd %xmm0, 0x78(%r14)
movq 0x30(%rsp), %rax
movups (%rax), %xmm0
movups %xmm0, 0x80(%r14)
movsd (%rsp), %xmm0
movsd %xmm0, 0xa8(%r14)
movl $0x1, 0x90(%r14)
andl $0x0, 0x9c(%r14)
movq 0x94(%rbx), %rax
movq %rax, 0x94(%r14)
movq %r14, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq