// File: /workspace/github_cpp_makefile_star2_O1/thierry7100[P]CutOptim/src/Geometry.cpp
// Function: Polygon::Transform(double, Point const*)
Polygon *Polygon::Transform(double angle, const Point *pT)
{
Polygon *Transformed = new Polygon;
double cos_a = cos(angle);
double sin_a = sin(angle);
double xmin = 0, xmax = 0, ymin = 0, ymax = 0;

    nbTransformedPoly++;
    nbCreatedTransformedPoly++;
    Transformed->TypePoly = TransformedPoly;
    if ( poly_centroid_ok == 0 ) getCentroid();
    Transformed->angle_rotation = angle;
    Transformed->pt_Translation = *pT;
    Transformed->precision = precision;
    Transformed->_Vertices = _Vertices;          //      Copy vertice vector
    Transformed->nVertices = Transformed->_Vertices.size();
    Transformed->poly_centroid = poly_centroid + Transformed->pt_Translation;
    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 + Transformed->poly_centroid.x;
        newx = round(newx/precision)*precision;
        Transformed->_Vertices[i].x = newx;
        double newy = (_Vertices[i].x - poly_centroid.x) * sin_a + (_Vertices[i].y - poly_centroid.y)* cos_a + Transformed->poly_centroid.y;
        newy = round(newy/precision)*precision;
        Transformed->_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;
        }
    }
    Transformed->BoundingBox.A = Point(xmin, ymin);
    Transformed->BoundingBox.B = Point(xmax, ymax);
    Transformed->poly_area = poly_area;
    Transformed->poly_centroid_ok = 1;
    Transformed->poly_changed = 0;
    Transformed->poly_closed = poly_closed;
    Transformed->poly_clockwise = poly_clockwise;
    return Transformed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r15
movsd %xmm0, (%rsp)
movq %rdi, %rbx
movl $0xc0, %edi
callq 0x7430
movq %rax, %r14
leaq 0x2906b(%rip), %rax     # 0x51ca0
movq %rax, (%r14)
leaq 0x10(%r14), %r12
leaq 0xb0(%r14), %r13
xorl %ebp, %ebp
movl %ebp, 0x8(%r14)
movl $0x8c, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x7270
xorps %xmm0, %xmm0
movups %xmm0, 0xb0(%r14)
movl $0x1, 0x9c(%r14)
movq $0x0, 0xa8(%r14)
movabsq $0x3f1a36e2eb1c432d, %rax # imm = 0x3F1A36E2EB1C432D
movq %rax, 0xa0(%r14)
incq 0x29d6f(%rip)           # 0x52a00
movl %ebp, 0xc(%r14)
incq 0x29d94(%rip)           # 0x52a30
movsd (%rsp), %xmm0
callq 0x7790
movsd %xmm0, 0x18(%rsp)
movsd (%rsp), %xmm0
callq 0x70f0
incq 0x29d63(%rip)           # 0x52a20
incq 0x29d8c(%rip)           # 0x52a50
movsd %xmm0, 0x10(%rsp)
movl $0x4, 0xc(%r14)
cmpl %ebp, 0x90(%rbx)
jne 0x28ce2
movq %rbx, %rdi
callq 0x283b4
movsd (%rsp), %xmm0
movsd %xmm0, 0xa8(%r14)
movups (%r15), %xmm0
movups %xmm0, (%r13)
movsd 0xa0(%rbx), %xmm0
movsd %xmm0, 0xa0(%r14)
leaq 0x10(%rbx), %rsi
movq %r12, %rdi
callq 0x29d7a
movq 0x10(%r14), %r15
movq 0x18(%r14), %rax
subq %r15, %rax
shrq $0x4, %rax
movl %eax, 0x8(%r14)
movsd 0x80(%rbx), %xmm0
movsd 0x88(%rbx), %xmm1
addsd 0xb0(%r14), %xmm0
addsd 0xb8(%r14), %xmm1
movsd %xmm0, 0x80(%r14)
movsd %xmm1, 0x88(%r14)
movslq 0x8(%rbx), %r12
testq %r12, %r12
jle 0x28eb0
movq 0x10(%rbx), %r13
movsd 0xa0(%rbx), %xmm0
movsd %xmm0, (%rsp)
shlq $0x4, %r12
xorpd %xmm4, %xmm4
xorl %ebp, %ebp
xorpd %xmm5, %xmm5
xorpd %xmm7, %xmm7
xorpd %xmm6, %xmm6
movsd %xmm7, 0x20(%rsp)
movsd %xmm6, 0x28(%rsp)
movsd %xmm5, 0x30(%rsp)
movsd %xmm4, 0x38(%rsp)
movsd (%r13,%rbp), %xmm0
movsd 0x8(%r13,%rbp), %xmm2
subsd 0x80(%rbx), %xmm0
subsd 0x88(%rbx), %xmm2
movsd %xmm2, 0x40(%rsp)
movsd 0x10(%rsp), %xmm1
mulsd %xmm2, %xmm1
mulsd 0x18(%rsp), %xmm0
subsd %xmm1, %xmm0
addsd 0x80(%r14), %xmm0
divsd (%rsp), %xmm0
callq 0x71c0
movsd (%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd %xmm0, (%r15,%rbp)
movsd (%r13,%rbp), %xmm0
subsd 0x80(%rbx), %xmm0
movsd 0x40(%rsp), %xmm2
mulsd 0x18(%rsp), %xmm2
mulsd 0x10(%rsp), %xmm0
addsd %xmm2, %xmm0
addsd 0x88(%r14), %xmm0
divsd %xmm1, %xmm0
callq 0x71c0
mulsd (%rsp), %xmm0
movsd %xmm0, 0x8(%r15,%rbp)
testq %rbp, %rbp
je 0x28e83
movsd 0x8(%rsp), %xmm3
movapd %xmm3, %xmm2
minsd 0x38(%rsp), %xmm2
movapd %xmm0, %xmm1
minsd 0x20(%rsp), %xmm1
maxsd 0x30(%rsp), %xmm3
movsd 0x28(%rsp), %xmm4
ucomisd %xmm4, %xmm0
ja 0x28e91
movapd %xmm4, %xmm0
jmp 0x28e91
movapd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm3
movapd %xmm3, %xmm2
addq $0x10, %rbp
movapd %xmm2, %xmm4
movapd %xmm3, %xmm5
movapd %xmm1, %xmm7
movapd %xmm0, %xmm6
cmpq %rbp, %r12
jne 0x28d91
jmp 0x28ec0
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
xorpd %xmm3, %xmm3
xorpd %xmm2, %xmm2
movsd %xmm2, 0x58(%r14)
movsd %xmm1, 0x60(%r14)
movsd %xmm3, 0x68(%r14)
movsd %xmm0, 0x70(%r14)
movsd 0x78(%rbx), %xmm0
movsd %xmm0, 0x78(%r14)
movl $0x1, 0x90(%r14)
movl $0x0, 0x9c(%r14)
movl 0x98(%rbx), %eax
movl %eax, 0x98(%r14)
movl 0x94(%rbx), %eax
movl %eax, 0x94(%r14)
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop