// File: thierry7100[P]CutOptim/src/Geometry.cpp
// Function: Polygon::enlarge(double)
Polygon *Polygon::enlarge(double Diff)
{
int First = 1;
Point OldA2 = Point(0, 0);
Point OldB2 = Point(0, 0);
Segment A2B2 = Segment(OldA2, OldB2);
Line OldLine(1, 1, 0);
Line FirstLine(1, 1, 0);
int newVertices = 0;
double a, b, c;

    //  Then create larger polygon.
    Polygon *LargePoly = new Polygon();

    for ( int i = 0; i < nVertices - 1; i++)
    {
        //  For each segment create a segment which is parallel to the original segment, but translated at distance Diff
        a = _Vertices[i].y - _Vertices[i+1].y;
        b = _Vertices[i+1].x - _Vertices[i].x;
        c = _Vertices[i].x * _Vertices[i+1].y - _Vertices[i+1].x * _Vertices[i].y;
        //  If equation of first segment is ax + by + c = 0, the translated segment has an equation like ax + by + C = 0 where C = c + Diff*sqrt(a*a + b*b)
        //  Here we will first build a segment which begins in A' and end in B' where A' is the point on the line perpendicular to the segment and which starts in A
        double C = c + Diff*sqrt(a*a+b*b);
        Line A1B1 = Line(a, b, C);
        //  Now the lines which are perpendicular in A or B to the segment
        Line AB_perpendicular_A = Line(-b, a, b*_Vertices[i].x - a*_Vertices[i].y);
        Line AB_perpendicular_B = Line(-b, a, b*_Vertices[i+1].x - a*_Vertices[i+1].y);
        // Compute intersection of AB_perpendicular_A and A1B1 (point A1)
        Point A1 = A1B1.Intersect(AB_perpendicular_A);
        Point B1 = A1B1.Intersect(AB_perpendicular_B);
        //  Now enlarge segment to reach A2 which is Diff further from A1 and B2 which is also Diff further from B1
        double distA1B1 = A1.Distance(B1);
        double Coeff = Diff/distA1B1;
        //  Now compute A2 and B2
        //  A2B1 = Coeff*A1B1
        Point A2 = A1 + Coeff*(A1-B1);
        Point B2 = B1 + Coeff*(B1-A1);
        A2B2 = Segment(A2, B2);
        //  Compute intersection between segment A2B2 and Old Segment A2B2 if not processing the first vertice
        if ( !First )
        {
            Point A3 = A1B1.Intersect(OldLine);
            //  If A3 is between A2 and B2, keep segment A3 - B2
            if (A2B2.InSegment(A3) )
            {
                //Change end of previous segment to A3, so change vertice of largePoly
                LargePoly->_Vertices[newVertices-1] = A3;
                //  And add new point B2
                LargePoly->addVertice(B2);
                newVertices = LargePoly->_Vertices.size();
#if DEBUG_CONSOLE > 1
                printf("Changing last point to A3 (%.3f,%.3f) and add one point (%d) B2 : (%.3f,%.3f)\n", A3.x, A3.y, newVertices, B2.x, B2.y);
#endif // DEBUG_CONSOLE
            }
            else
            {
                // Add vertice A2 and B2
                LargePoly->addVertice(A2);
                LargePoly->addVertice(B2);
                newVertices = LargePoly->_Vertices.size();
#if DEBUG_CONSOLE > 1
                printf("Add 2 points (%d and %d) A2 point (%.3f,%.3f) and B2 (%.3f,%.3f)\n", newVertices-1, newVertices, A2.x, A2.y, B2.x, B2.y);
#endif // DEBUG_CONSOLE
            }
        }
        else
        {
            LargePoly->addVertice(A2);
            LargePoly->addVertice(B2);
            newVertices = LargePoly->_Vertices.size();
            FirstLine = A1B1;
            First = 0;
#if DEBUG_CONSOLE > 1
            printf("Add First %d points : (%.3f, %.3f)   (%.3f,%.3f)\n", newVertices, A2.x, A2.y, B2.x, B2.y);
#endif // DEBUG_CONSOLE
        }
        OldA2 = A2;
        OldB2 = B2;
        OldLine = A1B1;
    }
    //  Now change first segment, compute intersection with OldLine
    Point A3;
    if ( OldLine.hasIntersect(&FirstLine, A3 ) )
    {
        //  If A3 is between A2 and B2, keep segment A3 - B2
        if (A2B2.InSegment(A3) )
        {
            //Change end of previous segment to A3, so change vertice of largePoly
            LargePoly->_Vertices[newVertices-1] = A3;
            //  And set First point of Poly to be the same
            LargePoly->_Vertices[0] = A3;
#if DEBUG_CONSOLE > 1
            printf("Changing first/last point (%d) A3 : (%.3f,%.3f)\n", newVertices, A3.x, A3.y);
    #endif // DEBUG_CONSOLE
        }
        else
        {
            // Add vertice between B2 and first point
            LargePoly->addVertice(LargePoly->_Vertices[0]);
            newVertices = LargePoly->_Vertices.size();
    #if DEBUG_CONSOLE > 1
            printf("Add 1 point (%d) (%3.f,%.3f) , closing polygon\n", newVertices, LargePoly->_Vertices[0].x, LargePoly->_Vertices[0].y);
    #endif // DEBUG_CONSOLE
        }
    }
    else
    {       //  No intersection, add point
            // Add vertice between B2 and first point
        LargePoly->addVertice(LargePoly->_Vertices[0]);
        newVertices = LargePoly->_Vertices.size();
#if DEBUG_CONSOLE > 1
        printf("NoIntersect, Add 1 point (%d) (%3.f,%.3f) , closing polygon\n", newVertices, LargePoly->_Vertices[0].x, LargePoly->_Vertices[0].y);
#endif // DEBUG_CONSOLE
    }
    LargePoly->CheckClosed();
    LargePoly->ReCalcBoundingBox();

    //  Now check that all edges of the enlarged polygon dont intersect
    //  If edge I (_Vertice[i] --> _Vertice[i+1]) intersect edge j (_Vertice[j] --> _Vertice[j+1] ) in point Ai with j > i
    //  1) Change _Vertice[i+1] to Ai
    //  2) Delete All vertices from i+2 to j
    //  The resulting polygon will have an edge from _Vertice[i] --> Ai and Ai --> Vertice[j] (with old indexes i and j).
#if DEBUG_CONSOLE > 0
    printf("Large Poly before post processing with %d (%zu) vertices\n", newVertices, LargePoly->_Vertices.size());
    for (int v = 0; v < newVertices; v++)
    {
        printf("Vertex %d : (%.3f,%.3f)\n", v, LargePoly->_Vertices[v].x, LargePoly->_Vertices[v].y);
    }
#endif
    //  After this step, remove vertices which are inside the polygon.
    //  The edges should never intersect
    int modified = true;
    Point Intersection;
    while ( modified )
    {
        modified = false;
        for (int i = 0; i < newVertices - 2; i++)
        {
            Segment AiBi = Segment(LargePoly->_Vertices[i], LargePoly->_Vertices[i+1]);
            for ( int j = i+2; j < newVertices - 1; j++)
            {
                if ( j == newVertices-2 && i == 0 ) break;      //  Do not check this case, last segment will always intersect first one !
                Segment AjBj = Segment(LargePoly->_Vertices[j],LargePoly->_Vertices[j+1]);
                if ( AiBi.isCrossing(&AjBj, &Intersection))
                {
                //  The two segments are crossing
                //  First change Bi to Intersection
#if DEBUG_CONSOLE > 0
                    printf("Intersection detected between segment %d (%.3f,%.3f -- %.3f,%.3f) and segment %d (%.3f,%.3f -- %.3f,%.3f)\n",
                                i, LargePoly->_Vertices[i].x, LargePoly->_Vertices[i].y, LargePoly->_Vertices[i+1].x, LargePoly->_Vertices[i+1].y,
                                j, LargePoly->_Vertices[j].x, LargePoly->_Vertices[j].y, LargePoly->_Vertices[j+1].x, LargePoly->_Vertices[j+1].y);
                    printf("Changing end of segment to intersection point (%.3f,%.3f)\n", Intersection.x, Intersection.y);
#endif
                //  Build 2 polygons, first one contains segments between i+1 (modified to intersection) and j also modified as intersection
                //  The second one contains all other points
                    Polygon *Poly1 = new Polygon;
                    Polygon *Poly2 = new Polygon;
                    for ( int k = 0; k < newVertices; k++)
                    {
                        if ( k < i || k > j )
                        {
                            Poly1->addVertice(LargePoly->_Vertices[k]);
                        }
                        else if ( k == i )
                        {
                            Poly1->addVertice(LargePoly->_Vertices[k]);
                            Poly1->addVertice(Intersection);
                        }
                        else if ( k == i+1 )
                        {
                            Poly2->addVertice(Intersection);
                            Poly2->addVertice(LargePoly->_Vertices[k]);
                        }
                        else if ( k < j )
                        {
                            Poly2->addVertice(LargePoly->_Vertices[k]);
                        }
                        else
                        {
                            Poly2->addVertice(LargePoly->_Vertices[k]);
                            Poly2->addVertice(Intersection);
                        }
                    }
                    //  Keep the largest one
                    double area1 = fabs(Poly1->area());
                    double area2 = fabs(Poly2->area());
                    if ( area1 > area2 )
                    {
#if DEBUG_CONSOLE > 0
                        printf("Area1 = %.3f, Area2 = %.3f, keep polygon1", area1, area2);
#endif
                        delete Poly2;
                        delete LargePoly;
                        LargePoly = Poly1;
                    }
                    else
                    {
#if DEBUG_CONSOLE > 0
                        printf("Area1 = %.3f, Area2 = %.3f, keep polygon2", area1, area2);
#endif
                        delete Poly1;
                        delete LargePoly;
                        LargePoly = Poly2;
                    }
                    newVertices = LargePoly->_Vertices.size();
                    modified = true;
                    break;
                }
            }
            if ( modified ) break;
        }

    }
    for (int i = 0; i < newVertices; i++)
    {
        if ( isInPoly(&LargePoly->_Vertices[i]) > 0 || distance(LargePoly->_Vertices[i]) < Diff - precision )
        {
            // Inside poly or too close, delete vertex
            LargePoly->delVertex(i);
            newVertices = LargePoly->nVertices;
        }
    }

    LargePoly->CheckClosed();
    LargePoly->ReCalcArea();
#if DEBUG_CONSOLE > 0
    Rectangle BBox = LargePoly->GetBoundingBox();
    printf("After postprocessing, %d vertices, area = %.3f, Bounding box (%.3f,%.3f) - (%.3f,%.3f), closed = %d\n",
        LargePoly->nVertices, LargePoly->area(), BBox.A.x, BBox.A.y, BBox.B.x, BBox.B.y, LargePoly->isClosed());
#endif
    return(LargePoly);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4a0, %rsp            # imm = 0x4A0
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x388(%rbp)
movl $0x1, -0x14(%rbp)
leaq -0x28(%rbp), %rdi
movq %rdi, -0x380(%rbp)
xorps %xmm1, %xmm1
movsd %xmm1, -0x368(%rbp)
movaps %xmm1, %xmm0
callq 0x5b520
movsd -0x368(%rbp), %xmm1
leaq -0x38(%rbp), %rdi
movq %rdi, -0x378(%rbp)
movaps %xmm1, %xmm0
callq 0x5b520
movq -0x380(%rbp), %rsi
movq -0x378(%rbp), %rdx
leaq -0x90(%rbp), %rdi
callq 0x639b0
movsd -0x368(%rbp), %xmm2
leaq -0xa8(%rbp), %rdi
movsd 0x24808(%rip), %xmm1    # 0x840f8
movsd %xmm1, -0x370(%rbp)
movaps %xmm1, %xmm0
callq 0x63b70
movsd -0x370(%rbp), %xmm1
movsd -0x368(%rbp), %xmm2
leaq -0xc0(%rbp), %rdi
movaps %xmm1, %xmm0
callq 0x63b70
movl $0x0, -0xc4(%rbp)
movl $0xc0, %edi
callq 0x9550
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x360(%rbp)
callq 0x5e600
jmp 0x5f947
movq -0x360(%rbp), %rax
movq %rax, -0xe8(%rbp)
movl $0x0, -0xf8(%rbp)
movq -0x388(%rbp), %rcx
movl -0xf8(%rbp), %eax
movl 0x8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x600e2
movq -0x388(%rbp), %rdi
addq $0x10, %rdi
movslq -0xf8(%rbp), %rsi
callq 0x63990
movq -0x388(%rbp), %rdi
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x420(%rbp)
addq $0x10, %rdi
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x63990
movsd -0x420(%rbp), %xmm0
movq -0x388(%rbp), %rdi
subsd 0x8(%rax), %xmm0
movsd %xmm0, -0xd0(%rbp)
addq $0x10, %rdi
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x63990
movq -0x388(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x418(%rbp)
addq $0x10, %rdi
movslq -0xf8(%rbp), %rsi
callq 0x63990
movsd -0x418(%rbp), %xmm0
movq -0x388(%rbp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, -0xd8(%rbp)
addq $0x10, %rdi
movslq -0xf8(%rbp), %rsi
callq 0x63990
movq -0x388(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x408(%rbp)
addq $0x10, %rdi
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x63990
movq -0x388(%rbp), %rdi
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x400(%rbp)
addq $0x10, %rdi
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x63990
movq -0x388(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x410(%rbp)
addq $0x10, %rdi
movslq -0xf8(%rbp), %rsi
callq 0x63990
movsd -0x410(%rbp), %xmm1
movsd -0x408(%rbp), %xmm0
movsd -0x400(%rbp), %xmm2
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, -0xe0(%rbp)
movsd -0xe0(%rbp), %xmm0
movsd %xmm0, -0x3f8(%rbp)
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x3f0(%rbp)
movsd -0xd0(%rbp), %xmm0
movsd -0xd0(%rbp), %xmm2
movsd -0xd8(%rbp), %xmm1
mulsd -0xd8(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x9460
movsd -0x3f8(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x3f0(%rbp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x100(%rbp)
movsd -0xd0(%rbp), %xmm0
movsd -0xd8(%rbp), %xmm1
movsd -0x100(%rbp), %xmm2
leaq -0x118(%rbp), %rdi
callq 0x63b70
movq -0x388(%rbp), %rdi
movsd -0xd8(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x3d0(%rbp)
movsd -0xd0(%rbp), %xmm0
movsd %xmm0, -0x3c8(%rbp)
movsd -0xd8(%rbp), %xmm0
movsd %xmm0, -0x3e0(%rbp)
addq $0x10, %rdi
movslq -0xf8(%rbp), %rsi
callq 0x63990
movq -0x388(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x3d8(%rbp)
movsd -0xd0(%rbp), %xmm0
movsd %xmm0, -0x3e8(%rbp)
addq $0x10, %rdi
movslq -0xf8(%rbp), %rsi
callq 0x63990
movsd -0x3e8(%rbp), %xmm3
movsd -0x3e0(%rbp), %xmm2
movsd -0x3d8(%rbp), %xmm4
movsd -0x3d0(%rbp), %xmm0
movsd -0x3c8(%rbp), %xmm1
mulsd 0x8(%rax), %xmm3
movq %xmm3, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm3
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
leaq -0x130(%rbp), %rdi
callq 0x63b70
movq -0x388(%rbp), %rdi
movsd -0xd8(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x3a8(%rbp)
movsd -0xd0(%rbp), %xmm0
movsd %xmm0, -0x3a0(%rbp)
movsd -0xd8(%rbp), %xmm0
movsd %xmm0, -0x3b8(%rbp)
addq $0x10, %rdi
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x63990
movq -0x388(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x3b0(%rbp)
movsd -0xd0(%rbp), %xmm0
movsd %xmm0, -0x3c0(%rbp)
addq $0x10, %rdi
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x63990
movsd -0x3c0(%rbp), %xmm3
movsd -0x3b8(%rbp), %xmm2
movsd -0x3b0(%rbp), %xmm4
movsd -0x3a8(%rbp), %xmm0
movsd -0x3a0(%rbp), %xmm1
mulsd 0x8(%rax), %xmm3
movq %xmm3, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm3
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
leaq -0x148(%rbp), %rdi
callq 0x63b70
leaq -0x118(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x63bb0
movsd %xmm0, -0x158(%rbp)
movsd %xmm1, -0x150(%rbp)
leaq -0x118(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x63bb0
movsd %xmm0, -0x168(%rbp)
movsd %xmm1, -0x160(%rbp)
leaq -0x158(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x63d00
movsd %xmm0, -0x170(%rbp)
movsd -0x10(%rbp), %xmm0
divsd -0x170(%rbp), %xmm0
movsd %xmm0, -0x178(%rbp)
movsd -0x178(%rbp), %xmm0
movsd %xmm0, -0x398(%rbp)
leaq -0x158(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x63e00
movaps %xmm0, %xmm2
movsd -0x398(%rbp), %xmm0
movsd %xmm2, -0x1a8(%rbp)
movsd %xmm1, -0x1a0(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x63db0
movsd %xmm0, -0x198(%rbp)
movsd %xmm1, -0x190(%rbp)
leaq -0x158(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x63d60
movsd %xmm0, -0x188(%rbp)
movsd %xmm1, -0x180(%rbp)
movsd -0x178(%rbp), %xmm0
movsd %xmm0, -0x390(%rbp)
leaq -0x168(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x63e00
movaps %xmm0, %xmm2
movsd -0x390(%rbp), %xmm0
movsd %xmm2, -0x1d8(%rbp)
movsd %xmm1, -0x1d0(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x63db0
movsd %xmm0, -0x1c8(%rbp)
movsd %xmm1, -0x1c0(%rbp)
leaq -0x168(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x63d60
movsd %xmm0, -0x1b8(%rbp)
movsd %xmm1, -0x1b0(%rbp)
leaq -0x230(%rbp), %rdi
leaq -0x188(%rbp), %rsi
leaq -0x1b8(%rbp), %rdx
callq 0x639b0
leaq -0x90(%rbp), %rdi
leaq -0x230(%rbp), %rsi
movl $0x58, %edx
callq 0x9490
cmpl $0x0, -0x14(%rbp)
jne 0x6000b
leaq -0x118(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x63bb0
movsd %xmm0, -0x240(%rbp)
movsd %xmm1, -0x238(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x63e50
cmpl $0x0, %eax
je 0x5ffcd
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
movl -0xc4(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x63990
movq -0x240(%rbp), %rcx
movq %rcx, (%rax)
movq -0x238(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0xe8(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x5e960
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
callq 0x5add0
movl %eax, -0xc4(%rbp)
jmp 0x60009
movq -0x360(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
movl $0xc0, %esi
callq 0x9560
jmp 0x60850
movq -0xe8(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x5e960
movq -0xe8(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x5e960
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
callq 0x5add0
movl %eax, -0xc4(%rbp)
jmp 0x60078
movq -0xe8(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x5e960
movq -0xe8(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x5e960
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
callq 0x5add0
movl %eax, -0xc4(%rbp)
movq -0x118(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x110(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x188(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x180(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x1b8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x1b0(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x118(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x110(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x98(%rbp)
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
jmp 0x5f95f
leaq -0x250(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x5b520
leaq -0xa8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
leaq -0x250(%rbp), %rdx
callq 0x63ef0
testb $0x1, %al
jne 0x60117
jmp 0x601d4
leaq -0x90(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x63e50
cmpl $0x0, %eax
je 0x6018b
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
movl -0xc4(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x63990
movq -0x250(%rbp), %rcx
movq %rcx, (%rax)
movq -0x248(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x63990
movq -0x250(%rbp), %rcx
movq %rcx, (%rax)
movq -0x248(%rbp), %rcx
movq %rcx, 0x8(%rax)
jmp 0x601d2
movq -0xe8(%rbp), %rax
movq %rax, -0x428(%rbp)
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x63990
movq -0x428(%rbp), %rdi
movq %rax, %rsi
callq 0x5e960
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
callq 0x5add0
movl %eax, -0xc4(%rbp)
jmp 0x6021b
movq -0xe8(%rbp), %rax
movq %rax, -0x430(%rbp)
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x63990
movq -0x430(%rbp), %rdi
movq %rax, %rsi
callq 0x5e960
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
callq 0x5add0
movl %eax, -0xc4(%rbp)
movq -0xe8(%rbp), %rdi
callq 0x64020
movq -0xe8(%rbp), %rdi
callq 0x60860
movl $0x1, -0x254(%rbp)
leaq -0x268(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x5b520
cmpl $0x0, -0x254(%rbp)
je 0x60762
movl $0x0, -0x254(%rbp)
movl $0x0, -0x26c(%rbp)
movl -0x26c(%rbp), %eax
movl -0xc4(%rbp), %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jge 0x6075d
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
movslq -0x26c(%rbp), %rsi
callq 0x63990
movq %rax, -0x438(%rbp)
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
movl -0x26c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x63990
movq -0x438(%rbp), %rsi
movq %rax, %rdx
leaq -0x2c8(%rbp), %rdi
callq 0x639b0
movl -0x26c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x2cc(%rbp)
movl -0x2cc(%rbp), %eax
movl -0xc4(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x6073c
movl -0x2cc(%rbp), %eax
movl -0xc4(%rbp), %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jne 0x6031e
cmpl $0x0, -0x26c(%rbp)
jne 0x6031e
jmp 0x6073c
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
movslq -0x2cc(%rbp), %rsi
callq 0x63990
movq %rax, -0x440(%rbp)
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
movl -0x2cc(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x63990
movq -0x440(%rbp), %rsi
movq %rax, %rdx
leaq -0x328(%rbp), %rdi
callq 0x639b0
leaq -0x2c8(%rbp), %rdi
leaq -0x328(%rbp), %rsi
leaq -0x268(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x640b0
cmpl $0x0, %eax
je 0x60726
movl $0xc0, %edi
callq 0x9550
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x448(%rbp)
callq 0x5e600
jmp 0x603b3
movq -0x448(%rbp), %rax
movq %rax, -0x330(%rbp)
movl $0xc0, %edi
callq 0x9550
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x450(%rbp)
callq 0x5e600
jmp 0x603df
movq -0x450(%rbp), %rax
movq %rax, -0x338(%rbp)
movl $0x0, -0x33c(%rbp)
movl -0x33c(%rbp), %eax
cmpl -0xc4(%rbp), %eax
jge 0x60612
movl -0x33c(%rbp), %eax
cmpl -0x26c(%rbp), %eax
jl 0x60429
movl -0x33c(%rbp), %eax
cmpl -0x2cc(%rbp), %eax
jle 0x604b2
movq -0x330(%rbp), %rax
movq %rax, -0x458(%rbp)
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
movslq -0x33c(%rbp), %rsi
callq 0x63990
movq -0x458(%rbp), %rdi
movq %rax, %rsi
callq 0x5e960
jmp 0x605fc
movq -0x448(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
movl $0xc0, %esi
callq 0x9560
jmp 0x60850
movq -0x450(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
movl $0xc0, %esi
callq 0x9560
jmp 0x60850
movl -0x33c(%rbp), %eax
cmpl -0x26c(%rbp), %eax
jne 0x6050c
movq -0x330(%rbp), %rax
movq %rax, -0x460(%rbp)
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
movslq -0x33c(%rbp), %rsi
callq 0x63990
movq -0x460(%rbp), %rdi
movq %rax, %rsi
callq 0x5e960
movq -0x330(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x5e960
jmp 0x605fa
movl -0x33c(%rbp), %eax
movl -0x26c(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x6056b
movq -0x338(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x5e960
movq -0x338(%rbp), %rax
movq %rax, -0x468(%rbp)
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
movslq -0x33c(%rbp), %rsi
callq 0x63990
movq -0x468(%rbp), %rdi
movq %rax, %rsi
callq 0x5e960
jmp 0x605f8
movl -0x33c(%rbp), %eax
cmpl -0x2cc(%rbp), %eax
jge 0x605af
movq -0x338(%rbp), %rax
movq %rax, -0x470(%rbp)
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
movslq -0x33c(%rbp), %rsi
callq 0x63990
movq -0x470(%rbp), %rdi
movq %rax, %rsi
callq 0x5e960
jmp 0x605f6
movq -0x338(%rbp), %rax
movq %rax, -0x478(%rbp)
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
movslq -0x33c(%rbp), %rsi
callq 0x63990
movq -0x478(%rbp), %rdi
movq %rax, %rsi
callq 0x5e960
movq -0x338(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x5e960
jmp 0x605f8
jmp 0x605fa
jmp 0x605fc
jmp 0x605fe
movl -0x33c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x33c(%rbp)
jmp 0x603f7
movq -0x330(%rbp), %rdi
callq 0x5ed10
movaps 0x23a8b(%rip), %xmm1    # 0x840b0
pand %xmm1, %xmm0
movsd %xmm0, -0x348(%rbp)
movq -0x338(%rbp), %rdi
callq 0x5ed10
movaps 0x23a6c(%rip), %xmm1    # 0x840b0
pand %xmm1, %xmm0
movsd %xmm0, -0x350(%rbp)
movsd -0x348(%rbp), %xmm0
ucomisd -0x350(%rbp), %xmm0
jbe 0x606b4
movq -0x338(%rbp), %rax
movq %rax, -0x480(%rbp)
cmpq $0x0, %rax
je 0x60683
movq -0x480(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0xe8(%rbp), %rax
movq %rax, -0x488(%rbp)
cmpq $0x0, %rax
je 0x606a4
movq -0x488(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x330(%rbp), %rax
movq %rax, -0xe8(%rbp)
jmp 0x60704
movq -0x330(%rbp), %rax
movq %rax, -0x490(%rbp)
cmpq $0x0, %rax
je 0x606d5
movq -0x490(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0xe8(%rbp), %rax
movq %rax, -0x498(%rbp)
cmpq $0x0, %rax
je 0x606f6
movq -0x498(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x338(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
callq 0x5add0
movl %eax, -0xc4(%rbp)
movl $0x1, -0x254(%rbp)
jmp 0x6073c
jmp 0x60728
movl -0x2cc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2cc(%rbp)
jmp 0x602e6
cmpl $0x0, -0x254(%rbp)
je 0x60747
jmp 0x6075d
jmp 0x60749
movl -0x26c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x26c(%rbp)
jmp 0x60270
jmp 0x6024f
movl $0x0, -0x354(%rbp)
movl -0x354(%rbp), %eax
cmpl -0xc4(%rbp), %eax
jge 0x60828
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
movslq -0x354(%rbp), %rsi
callq 0x63990
movq -0x388(%rbp), %rdi
movq %rax, %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x60a10
cmpl $0x0, %eax
jg 0x607f0
movq -0xe8(%rbp), %rdi
addq $0x10, %rdi
movslq -0x354(%rbp), %rsi
callq 0x63990
movq -0x388(%rbp), %rdi
movq %rax, %rsi
callq 0x5eee0
movq -0x388(%rbp), %rax
movaps %xmm0, %xmm1
movsd -0x10(%rbp), %xmm0
subsd 0xa0(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x60812
movq -0xe8(%rbp), %rdi
movl -0x354(%rbp), %esi
callq 0x61250
movq -0xe8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xc4(%rbp)
jmp 0x60814
movl -0x354(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x354(%rbp)
jmp 0x6076c
movq -0xe8(%rbp), %rdi
callq 0x64020
movq -0xe8(%rbp), %rdi
callq 0x612f0
movq -0xe8(%rbp), %rax
addq $0x4a0, %rsp            # imm = 0x4A0
popq %rbp
retq
movq -0xf0(%rbp), %rdi
callq 0x9960
nopl (%rax)