// File: 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
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl $0xc0, %edi
callq 0x9550
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xc0(%rbp)
callq 0x5e600
jmp 0x62401
movq -0xc0(%rbp), %rax
movq %rax, -0x20(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x99f0
movsd %xmm0, -0x38(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x9120
movq -0xc8(%rbp), %rax
movsd %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
movq 0x56718(%rip), %rcx     # 0xb8b70
addq $0x1, %rcx
movq %rcx, 0x5670d(%rip)     # 0xb8b70
movq 0x56736(%rip), %rcx     # 0xb8ba0
addq $0x1, %rcx
movq %rcx, 0x5672b(%rip)     # 0xb8ba0
movq -0x20(%rbp), %rcx
movl $0x4, 0xc(%rcx)
cmpl $0x0, 0x90(%rax)
jne 0x624c3
movq -0xc8(%rbp), %rdi
callq 0x615a0
movsd %xmm0, -0x70(%rbp)
movsd %xmm1, -0x68(%rbp)
jmp 0x624c3
movq -0xc0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0xc0, %esi
callq 0x9560
jmp 0x62920
movq -0xc8(%rbp), %rsi
movsd -0x10(%rbp), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, 0xa8(%rax)
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, 0xb0(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0xb8(%rax)
movsd 0xa0(%rsi), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, 0xa0(%rax)
addq $0x10, %rsi
movq -0x20(%rbp), %rdi
addq $0x10, %rdi
callq 0x642a0
movq -0x20(%rbp), %rdi
addq $0x10, %rdi
callq 0x5add0
movq -0xc8(%rbp), %rdi
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
addq $0x80, %rdi
movq -0x20(%rbp), %rsi
addq $0xb0, %rsi
callq 0x63d60
movsd %xmm0, -0x80(%rbp)
movsd %xmm1, -0x78(%rbp)
movq -0x20(%rbp), %rax
movq -0x80(%rbp), %rcx
movq %rcx, 0x80(%rax)
movq -0x78(%rbp), %rcx
movq %rcx, 0x88(%rax)
movl $0x0, -0x84(%rbp)
movq -0xc8(%rbp), %rcx
movl -0x84(%rbp), %eax
cmpl 0x8(%rcx), %eax
jge 0x62862
movq -0xc8(%rbp), %rdi
addq $0x10, %rdi
movslq -0x84(%rbp), %rsi
callq 0x63990
movq -0xc8(%rbp), %rdi
movsd (%rax), %xmm0
subsd 0x80(%rdi), %xmm0
movsd %xmm0, -0xf8(%rbp)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
addq $0x10, %rdi
movslq -0x84(%rbp), %rsi
callq 0x63990
movsd -0xf8(%rbp), %xmm0
movsd -0xf0(%rbp), %xmm2
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movsd 0x8(%rcx), %xmm1
subsd 0x88(%rax), %xmm1
mulsd -0x40(%rbp), %xmm1
movq %xmm1, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x20(%rbp), %rcx
addsd 0x80(%rcx), %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x90(%rbp), %xmm0
divsd 0xa0(%rax), %xmm0
callq 0x9220
movq -0xc8(%rbp), %rax
mulsd 0xa0(%rax), %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0xe8(%rbp)
movq -0x20(%rbp), %rdi
addq $0x10, %rdi
movslq -0x84(%rbp), %rsi
callq 0x63990
movsd -0xe8(%rbp), %xmm0
movq -0xc8(%rbp), %rdi
movsd %xmm0, (%rax)
addq $0x10, %rdi
movslq -0x84(%rbp), %rsi
callq 0x63990
movq -0xc8(%rbp), %rdi
movsd (%rax), %xmm0
subsd 0x80(%rdi), %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
addq $0x10, %rdi
movslq -0x84(%rbp), %rsi
callq 0x63990
movsd -0xe0(%rbp), %xmm0
movsd -0xd8(%rbp), %xmm2
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movsd 0x8(%rcx), %xmm1
subsd 0x88(%rax), %xmm1
mulsd -0x38(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x20(%rbp), %rcx
addsd 0x88(%rcx), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x98(%rbp), %xmm0
divsd 0xa0(%rax), %xmm0
callq 0x9220
movq -0xc8(%rbp), %rax
mulsd 0xa0(%rax), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
movq -0x20(%rbp), %rdi
addq $0x10, %rdi
movslq -0x84(%rbp), %rsi
callq 0x63990
movsd -0xd0(%rbp), %xmm0
movsd %xmm0, 0x8(%rax)
cmpl $0x0, -0x84(%rbp)
jne 0x627d2
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x6284c
movsd -0x90(%rbp), %xmm1
movsd -0x48(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x627f2
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x98(%rbp), %xmm1
movsd -0x58(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x62812
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x90(%rbp), %xmm0
ucomisd -0x50(%rbp), %xmm0
jbe 0x6282e
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x98(%rbp), %xmm0
ucomisd -0x60(%rbp), %xmm0
jbe 0x6284a
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x6284c
jmp 0x6284e
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x6257f
movsd -0x48(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
leaq -0xa8(%rbp), %rdi
callq 0x5b520
movq -0x20(%rbp), %rax
movq -0xa8(%rbp), %rcx
movq %rcx, 0x58(%rax)
movq -0xa0(%rbp), %rcx
movq %rcx, 0x60(%rax)
movsd -0x50(%rbp), %xmm0
movsd -0x60(%rbp), %xmm1
leaq -0xb8(%rbp), %rdi
callq 0x5b520
movq -0xc8(%rbp), %rax
movq -0x20(%rbp), %rcx
movq -0xb8(%rbp), %rdx
movq %rdx, 0x68(%rcx)
movq -0xb0(%rbp), %rdx
movq %rdx, 0x70(%rcx)
movsd 0x78(%rax), %xmm0
movq -0x20(%rbp), %rcx
movsd %xmm0, 0x78(%rcx)
movq -0x20(%rbp), %rcx
movl $0x1, 0x90(%rcx)
movq -0x20(%rbp), %rcx
movl $0x0, 0x9c(%rcx)
movl 0x98(%rax), %edx
movq -0x20(%rbp), %rcx
movl %edx, 0x98(%rcx)
movl 0x94(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x94(%rax)
movq -0x20(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x9960
nopl (%rax)