// File: /workspace/github_cpp_makefile_star2_O2/realuptime[P]PolyDetector/PolyDetector.cpp
// Function: PolyDetector::DetectAllIntersections()
uint32_t PolyDetector::DetectAllIntersections()
{
    uint32_t ret = 0;
    size_t counter = origLines.size();
    PointType intersection;
    
    intersectionPoints.clear();
    collinearLineMap.clear();
    
    for (auto &l : origLines)
    {
        l.calcCenter();
    }
    
    // sort to always have the same results
    std::sort(origLines.begin(), origLines.end(), PolyLine::bCompareLineOrder);
    
    uint32_t n = 0;
    for (auto &l : origLines)
    {
        l.id = n++;
        l.intersections.clear();
        l.intersectedLines.clear();
    }
    
    // intersected lines: remove lines with only one intersection
    for (uint32_t i = 0; i < counter; i++)
    {
        auto &l1 = origLines[i];
        for (uint32_t j = i + 1; j < counter; j++)
        {
            auto &l2 = origLines[j];
            if (doIntersect(l1.a, l1.b, l2.a, l2.b))
            {
                //if (verbose > 1)
                //    logoutf("line #%u intersects #%u", l1.id, l2.id);
                
                /*
                for (auto &l : {&l1, &l2})
                {
                    auto &otherLid = l->id == l1.id ? l2.id : l1.id;

                    if (l->intersectedLines.find(otherLid) != l->intersectedLines.end())
                    {
                        logoutf("WARN: origLine #%u already contains intersected origLine #%u", l->id, otherLid);
                    }
                    else
                    {
                        l->intersectedLines.insert(otherLid);
                    }
                }
                */
                
                //if (l1.intersectedLines.find(l2.id) != l1.intersectedLines.end())
                l1.intersectedLines.insert(l2.id);
                l2.intersectedLines.insert(l1.id);
            }
        }
    }
    
    for (uint32_t i = 0; i < counter; i++)
    {
        auto &l1 = origLines[i];
        if (l1.intersectedLines.size() == 1)
        {
            if (verbose)
                logoutf("line #%u has only %u intersectedLines", l1.id, uint32_t(l1.intersectedLines.size()));
            
            for (uint32_t j = 0; j < counter; j++)
            {
                if (i != j)
                {
                    auto &l2 = origLines[j];
                    
                    for (auto it = l2.intersectedLines.begin(); it != l2.intersectedLines.end(); )
                    {
                        if (*it == l1.id)
                        {
                            if (verbose)
                                logoutf("removed intersectedLine line #%u from line #%u", l1.id, l2.id);
                            it = l2.intersectedLines.erase(it);
                            i = 0; // recheck all lines
                        }
                        else
                            ++it;
                    }
                }
            }
            
            l1.intersectedLines.clear();
        }
    }
    
    if (verbose > 2)
    {
        for (auto &l : origLines)
        {
            //if (!l.intersectedLines.empty())
            {
                std::string str;
                for (auto &n : l.intersectedLines)
                    str += std::to_string(n) + " ";
                if (!str.empty())
                    str.pop_back();
                logoutf("line #%u has %u intersectedLines: [%s]", l.id, uint32_t(l.intersectedLines.size()), str.c_str());
            }
        }
    }
    
    // intersection points
    std::set<std::pair<uint32_t, uint32_t>> took;
    for (auto &l1 : origLines)
    {
        for (auto &lid2 : l1.intersectedLines)
        {
            auto &l2 = origLines[lid2];
            
            if (took.find(std::make_pair(l1.id, l2.id)) == took.end())
            {
                intersection = vec(0);
                if (l1.IntersectionPoint(l2, intersection)) // checks if not parallel
                {
                    uint32_t intersectionIdx = uint32_t(intersectionPoints.size());
                    
                    // Check if the same intersection point exists
                    bool dupPoint = false;
                    for (uint32_t pi = 0; pi < intersectionPoints.size(); ++pi)
                    {
                        auto &p = intersectionPoints[pi];
                        if (!pointsDiffer(p, intersection))
                        {
                            if (verbose > 3)
                            {
                                logoutf("WARN: origLine #%u intersects origLine #%u exactly in the same point P%u as:", l1.id, l2.id, pi);
                                for (auto &lDup : origLines)
                                {
                                    if (lDup.id != l1.id && lDup.id != l2.id)
                                    {
                                        for (auto &inters : lDup.intersections)
                                        {
                                            if (inters == pi)
                                            {
                                                logoutf("WARN:  origLine #%u", lDup.id);
                                            }
                                        }
                                    }
                                }
                            }
                            dupPoint = true;
                            intersectionIdx = pi;
                            intersection = p;
                            break;
                        }
                    }

                    if (!dupPoint)
                    {
                        intersectionPoints.push_back(intersection);
                    }
                    
                    if (verbose > 2)
                        logoutf("[P%u]: origLine #%u intersects origLine #%u. dup:%d", intersectionIdx, l1.id, l2.id, dupPoint);
                    
                    for (auto &l : {&l1, &l2})
                    {
                        if (std::find(l->intersections.begin(), l->intersections.end(), intersectionIdx) != l->intersections.end())
                        {
                            if (verbose > 1)
                                logoutf("WARN: duplicate intersectionIdx P%u in line #%u", intersectionIdx, l->id);
                        }
                        else
                        {
                            //auto d = obb::LineSegment(l->a, l->b).Distance(intersection);
                            //assert(d < .1f);
                            
                            //auto d1 = obb::LineSegment(l->a, l->b).Distance(intersectionPoints[intersectionIdx]);
                            //assert(d1 < .1f);
                            
                            l->intersections.push_back(intersectionIdx);
                        }
                    }
                    
                    //addPointToLine(intersectionIdx, l1.id);
                    //addPointToLine(intersectionIdx, l2.id);
                    
                    took.insert(std::make_pair(l1.id, l2.id));
                    took.insert(std::make_pair(l2.id, l1.id));
                    
                    ret++;
                }
            }
        }
    }
    if (verbose)
        logoutf("intersectionPoints:%u", uint32_t(intersectionPoints.size()));
    
    //return 0;
    
    if (verbose > 2)
    {
        for (auto &l : origLines)
        {
            //if (!l.intersections.empty())
            {
                std::string str;
                for (auto &n : l.intersections)
                    str += std::to_string(n) + " ";
                if (!str.empty())
                    str.pop_back();
                logoutf("line #%u has %u pts: [%s]", l.id, uint32_t(l.intersections.size()), str.c_str());
            }
        }
    }
    
#if 1
    
    uint32_t nCol = 0;
    std::vector<uint32_t> pids;
    
    uint32_t times = 0;
    bool ok = false;
    do
    {
        took.clear();
        //nCol = 0;
        
        ok = true;
        
        for (auto &l1 : origLines)
        {
            if (l1.ignore) continue;
            if (l1.intersections.size() < 2) continue;
            
            //if (times == 1)
            //    l1.SortIntersectionsList(*this);
            
            float a, b, c;
            vec::line(vec(l1.a.x, l1.a.y), vec(l1.b.x, l1.b.y), a, b, c);
            if (a + b == 0.0f)
            {
                logoutf("l1:#%u l1.a: [%f %f] l1.b: [%f %f]", l1.id, l1.a.x, l1.a.y, l1.b.x, l1.b.y);
                assert(0);
                continue;
            }
            
            //obb::Line line = obb::LineSegment(l1.a, l1.b).ToLine();
        
            for (auto &l2 : origLines)
            {
                if (l2.ignore) continue;
                if (l2.intersections.size() < 2) continue;
                
                //if (took.find(std::make_pair(l1.id, l2.id)) == took.end())
                {
                    //if (k == 1)
                    //    l2.SortIntersectionsList(*this);
                    
                    took.insert(std::make_pair(l1.id, l2.id));
                    took.insert(std::make_pair(l2.id, l1.id));
                    
                    if (l1.id == l2.id) continue;
                    if (l2.intersections.empty()) continue;
                    assert(&l1 != &l2);
                    
                    uint32_t nFound = 0;
                    float maxLineDist = 0;
                    pids.clear();
                    for (auto &pid1 : l1.intersections)
                    {
                        for (auto &pid2 : l2.intersections)
                        {
                            if (pid1 == pid2)
                            {
                                nFound++;
                                pids.push_back(pid1);
                            }
                            
                            //float d = line.Distance(intersectionPoints[pid2]);
                            float d = vec::lineDist(a, b, c, vec(intersectionPoints[pid2].x, intersectionPoints[pid2].y));
                            if (d > maxLineDist)
                                maxLineDist = d;
                        }
                    }
                    
                    if (nFound >= 2)
                    {
                        ok = false;
                        
#if 1
                        if (maxLineDist <= minPointDiff)
                        {
                            logoutf("[%u]: line #%u is collinear with line #%u! nFound:%u lineDist:%f merging ...", times, l1.id, l2.id, nFound, maxLineDist);
                            
                            // TODO: merge point of l2 into l1
                            uint32_t nMerged = 0;
                            for (auto &pid : l2.intersections)
                            {
                                //logoutf("add P%u to l#%u", pid, l1.id);
                                if (std::find(l1.intersections.begin(), l1.intersections.end(), pid) == l1.intersections.end())
                                {
                                    //logoutf("add P%u to l#%u", pid, l1.id);
                                    l1.intersections.push_back(pid);
                                    nMerged++;
                                }
                            }
                            if (nMerged > 0)
                            {
                                logoutf("[%u]: merged %u points from line #%u into line #%u! dist:%f", times, nMerged, l2.id, l1.id, maxLineDist);
                            }
                            
                            //logoutf("line #%u with %u intersections ignored", l2.id, uint32_t(l2.intersections.size()));
                            l2.intersections.clear();
                            l2.a = l2.b = l2.center = vec(0);
                            l2.ignore = true;
                            
                            nCol++;
                        }
                        else
                        {
                            // merge points?
                            
                            // remove them
                            uint32_t nRm1 = 0, nRm2 = 0;
                            for (auto &pid : pids)
                            {
                                logoutf("[%u]]: P%u", times, pid);
                                for (auto it = l1.intersections.begin(); it != l1.intersections.end();)
                                {
                                    if (*it == pid)
                                    {
                                        it = l1.intersections.erase(it);
                                        nRm1++;
                                    }
                                    else
                                        ++it;
                                }
                                for (auto it = l2.intersections.begin(); it != l2.intersections.end();)
                                {
                                    if (*it == pid)
                                    {
                                        it = l2.intersections.erase(it);
                                        nRm2++;
                                    }
                                    else
                                        ++it;
                                }
                            }
                            auto keepPid = pids[0];
                            l1.intersections.push_back(keepPid);
                            l2.intersections.push_back(keepPid);
                            
                            logoutf("[%u]]: line #%u has common points(%u) with line #%u keeping just P%u nRm1:%u nRm2:%u rem1:%u rem2:%u lineDist:%f",
                                    times, l1.id, uint32_t(pids.size()), l2.id, keepPid, nRm1, nRm2,
                                    uint32_t(l1.intersections.size()),
                                    uint32_t(l2.intersections.size()),
                                    maxLineDist);
                        }
#endif
                    
                    }
                }
            }
        }
        if (ok && verbose)
            logoutf("[%u] ok!", times);
        times++;
    }
    while (!ok);
    
    logoutf("Number of col lines using intersection points: %u", uint32_t(nCol));
#endif

    for (auto &l : origLines)
    {
        if (l.intersections.size() == 1)
        {
            logoutf("WARN: line #%u has only %u intersections!", l.id, uint32_t(l.intersections.size()));
            //assert(false);
        }
    }
    
    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %r12
movq 0x20(%rdi), %rax
subq 0x18(%rdi), %rax
movl $0x90, %ecx
cqto
idivq %rcx
movq %rax, (%rsp)
movq 0xc8(%rdi), %rax
cmpq %rax, 0xd0(%rdi)
je 0x335e
movq %rax, 0xd0(%r12)
leaq 0xc8(%r12), %r14
leaq 0x98(%r12), %rdi
callq 0x9eae
movq 0x18(%r12), %rbx
movq 0x20(%r12), %r15
cmpq %r15, %rbx
je 0x3393
movq %rbx, %rdi
callq 0x2868
addq $0x90, %rbx
jmp 0x337d
movq 0x18(%r12), %rdi
movq 0x20(%r12), %rsi
leaq -0xda8(%rip), %rdx      # 0x25fc
callq 0x9f12
movq 0x18(%r12), %rbx
movq %r12, 0x8(%rsp)
movq 0x20(%r12), %r15
xorl %ebp, %ebp
cmpq %r15, %rbx
je 0x33e4
movl %ebp, 0x60(%rbx)
movq 0x10(%rbx), %rax
cmpq %rax, 0x18(%rbx)
je 0x33d0
movq %rax, 0x18(%rbx)
leaq 0x28(%rbx), %rdi
callq 0x934a
addq $0x90, %rbx
incl %ebp
jmp 0x33ba
xorl %eax, %eax
movl %eax, %eax
cmpq %rax, (%rsp)
movq 0x8(%rsp), %rbp
jbe 0x3487
movq 0x18(%rbp), %rcx
imulq $0x90, %rax, %rdx
leaq (%rcx,%rdx), %rbx
incl %eax
leaq 0x8(%rcx,%rdx), %r12
leaq 0x28(%rcx,%rdx), %rsi
movq %rsi, 0x10(%rsp)
leaq (%rcx,%rdx), %rbp
addq $0x60, %rbp
movl %eax, 0x28(%rsp)
movl %eax, %r13d
movl %r13d, %r13d
cmpq %r13, (%rsp)
jbe 0x347e
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
imulq $0x90, %r13, %rcx
leaq (%rax,%rcx), %r15
addq %rax, %rcx
addq $0x8, %rcx
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x2419
testb %al, %al
je 0x3479
leaq 0x60(%r15), %rsi
movq 0x10(%rsp), %rdi
callq 0xa77a
addq $0x28, %r15
movq %r15, %rdi
movq %rbp, %rsi
callq 0xa77a
incl %r13d
jmp 0x3426
movl 0x28(%rsp), %eax
jmp 0x33e6
xorl %r15d, %r15d
movl %r15d, %eax
cmpq %rax, (%rsp)
jbe 0x359d
movq 0x18(%rbp), %rbx
imulq $0x90, %rax, %r12
cmpq $0x1, 0x50(%rbx,%r12)
jne 0x3595
leaq (%rbx,%r12), %r13
cmpl $0x0, 0x60(%rbp)
je 0x34cd
movl 0x60(%r13), %esi
leaq 0x9f19(%rip), %rdi      # 0xd3dc
pushq $0x1
popq %rdx
xorl %eax, %eax
callq 0x2040
leaq (%rbx,%r12), %rax
addq $0x28, %rax
movq %rax, 0x80(%rsp)
xorl %ebx, %ebx
movl %ebx, %eax
cmpq %rax, (%rsp)
jbe 0x3588
movl %ebx, %ecx
cmpl %ebx, %r15d
je 0x357e
movq 0x18(%rbp), %rcx
imulq $0x90, %rax, %rax
leaq (%rcx,%rax), %rdx
movq %rdx, 0x28(%rsp)
leaq (%rcx,%rax), %rdx
addq $0x28, %rdx
movq %rdx, 0x10(%rsp)
movq 0x18(%rdx), %r12
leaq (%rcx,%rax), %rbp
addq $0x30, %rbp
cmpq %rbp, %r12
je 0x3576
movl 0x20(%r12), %esi
cmpl 0x60(%r13), %esi
je 0x3540
movq %r12, %rdi
callq 0x2160
movq %rax, %r12
jmp 0x3523
movq 0x8(%rsp), %rax
cmpl $0x0, 0x60(%rax)
je 0x3561
movq 0x28(%rsp), %rax
movl 0x60(%rax), %edx
leaq 0x9ea9(%rip), %rdi      # 0xd403
xorl %eax, %eax
callq 0x2040
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0xa870
movq %rax, %r12
xorl %r15d, %r15d
jmp 0x3523
movl %r15d, %ecx
movq 0x8(%rsp), %rbp
incl %ebx
movl %ecx, %r15d
jmp 0x34df
movq 0x80(%rsp), %rdi
callq 0x934a
incl %r15d
jmp 0x348a
cmpl $0x2, 0x60(%rbp)
movq 0x18(%rbp), %r13
movq 0x20(%rbp), %rax
movq %rax, 0x20(%rsp)
jbe 0x36a8
leaq 0xc0(%rsp), %r15
leaq 0x98(%rsp), %r12
leaq 0x40(%rsp), %rbp
cmpq 0x20(%rsp), %r13
je 0x3696
leaq 0xd0(%rsp), %rax
movq %rax, 0xc0(%rsp)
andq $0x0, 0xc8(%rsp)
movb $0x0, 0xd0(%rsp)
movq 0x40(%r13), %rbx
movq %r13, 0x28(%rsp)
addq $0x30, %r13
cmpq %r13, %rbx
je 0x364c
movl 0x20(%rbx), %esi
movq %r12, %rdi
callq 0x87e9
movq %rbp, %rdi
movq %r12, %rsi
leaq 0xa439(%rip), %rdx      # 0xda58
callq 0x87ca
movq %r15, %rdi
movq %rbp, %rsi
callq 0x2220
movq %rbp, %rdi
callq 0x20b0
movq %r12, %rdi
callq 0x20b0
movq %rbx, %rdi
callq 0x2160
movq %rax, %rbx
jmp 0x3602
cmpq $0x0, 0xc8(%rsp)
je 0x365f
movq %r15, %rdi
callq 0x2180
movq 0x28(%rsp), %r13
movl 0x50(%r13), %edx
movl 0x60(%r13), %esi
movq 0xc0(%rsp), %rcx
leaq 0x9db8(%rip), %rdi      # 0xd433
xorl %eax, %eax
callq 0x2040
movq %r15, %rdi
callq 0x20b0
addq $0x90, %r13
jmp 0x35c9
movq 0x8(%rsp), %rbp
movq 0x18(%rbp), %r13
movq 0x20(%rbp), %rax
movq %rax, 0x20(%rsp)
leaq 0xc8(%rsp), %r12
andl $0x0, (%r12)
andq $0x0, 0x8(%r12)
movq %r12, 0x10(%r12)
movq %r12, 0x18(%r12)
andq $0x0, 0x20(%r12)
movl $0x0, 0x8c(%rsp)
cmpq 0x20(%rsp), %r13
je 0x39d4
movq 0x40(%r13), %rcx
leaq 0x30(%r13), %rax
movq %rax, 0x30(%rsp)
movq %r13, 0x28(%rsp)
cmpq 0x30(%rsp), %rcx
je 0x39c8
movq %rcx, (%rsp)
movl 0x20(%rcx), %eax
movq 0x18(%rbp), %rcx
imulq $0x90, %rax, %rbx
movl 0x60(%r13), %eax
movq %rcx, %r15
movl 0x60(%rcx,%rbx), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x40(%rsp)
leaq 0xc0(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xa8bc
cmpq %r12, %rax
jne 0x39b7
addq %rbx, %r15
andq $0x0, 0x70(%rsp)
movq %r13, %rdi
movq %r15, %rsi
leaq 0x70(%rsp), %rdx
callq 0x2524
testb %al, %al
je 0x39b7
movq %r15, 0x10(%rsp)
movq 0xc8(%rbp), %rdx
movq 0xd0(%rbp), %rax
subq %rdx, %rax
movq %rax, %rcx
shrq $0x3, %rcx
movl %ecx, 0x98(%rsp)
sarq $0x3, %rax
movss 0x70(%rsp), %xmm0
movss 0x74(%rsp), %xmm1
xorl %r12d, %r12d
movss 0x98be(%rip), %xmm4     # 0xd060
leaq 0x98(%rsp), %rbx
movl %r12d, %ebp
cmpq %rbp, %rax
jbe 0x37db
movss (%rdx,%rbp,8), %xmm2
subss %xmm0, %xmm2
movss 0x4(%rdx,%rbp,8), %xmm3
subss %xmm1, %xmm3
mulss %xmm3, %xmm3
mulss %xmm2, %xmm2
addss %xmm3, %xmm2
ucomiss %xmm4, %xmm2
jb 0x37f0
incl %r12d
jmp 0x37aa
xorl %r12d, %r12d
movq %r14, %rdi
leaq 0x70(%rsp), %rsi
callq 0x8828
jmp 0x38b7
movq 0x8(%rsp), %rbx
cmpl $0x3, 0x60(%rbx)
jbe 0x3887
movq %rdx, 0x78(%rsp)
movl 0x60(%r13), %esi
movq 0x10(%rsp), %rax
movl 0x60(%rax), %edx
leaq 0x9c44(%rip), %rdi      # 0xd45b
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2040
movq 0x18(%rbx), %r15
movq 0x20(%rbx), %rax
movq %rax, 0x80(%rsp)
cmpq 0x80(%rsp), %r15
je 0x3895
movl 0x60(%r15), %eax
cmpl 0x60(%r13), %eax
je 0x3879
movq 0x10(%rsp), %rcx
cmpl 0x60(%rcx), %eax
je 0x3879
movq 0x10(%r15), %rbx
movq 0x18(%r15), %r13
cmpq %r13, %rbx
je 0x3879
cmpl %r12d, (%rbx)
jne 0x3873
movl 0x60(%r15), %esi
leaq 0x9c3d(%rip), %rdi      # 0xd4a9
xorl %eax, %eax
callq 0x2040
addq $0x4, %rbx
jmp 0x3857
addq $0x90, %r15
movq 0x28(%rsp), %r13
jmp 0x3831
movl %r12d, 0x98(%rsp)
movq (%rdx,%rbp,8), %rax
jmp 0x38a6
movl %r12d, 0x98(%rsp)
movq 0x78(%rsp), %rax
movq (%rax,%rbp,8), %rax
movq %rax, 0x70(%rsp)
pushq $0x1
popq %r12
leaq 0x98(%rsp), %rbx
movq 0x8(%rsp), %rbp
cmpl $0x3, 0x60(%rbp)
jb 0x38e6
movl 0x98(%rsp), %esi
movl 0x60(%r13), %edx
movq 0x10(%rsp), %rax
movl 0x60(%rax), %ecx
leaq 0x9be2(%rip), %rdi      # 0xd4be
movl %r12d, %r8d
xorl %eax, %eax
callq 0x2040
movq %r13, 0x40(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x48(%rsp)
xorl %r13d, %r13d
cmpq $0x10, %r13
je 0x3953
movq 0x40(%rsp,%r13), %r12
movq 0x10(%r12), %rdi
movq 0x18(%r12), %rsi
movq %rbx, %rdx
callq 0x9d20
cmpq 0x18(%r12), %rax
je 0x393e
cmpl $0x2, 0x60(%rbp)
jb 0x394d
movl 0x98(%rsp), %esi
movl 0x60(%r12), %edx
leaq 0x9bbe(%rip), %rdi      # 0xd4f3
xorl %eax, %eax
callq 0x2040
jmp 0x394d
addq $0x10, %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x87ac
addq $0x8, %r13
jmp 0x38f8
movq 0x28(%rsp), %r13
movl 0x60(%r13), %eax
movq 0x10(%rsp), %r15
movl 0x60(%r15), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x40(%rsp)
leaq 0xc0(%rsp), %rbx
movq %rbx, %rdi
leaq 0x40(%rsp), %r12
movq %r12, %rsi
callq 0xaa8a
movl 0x60(%r15), %eax
movl 0x60(%r13), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x40(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xaa8a
incl 0x8c(%rsp)
leaq 0xc8(%rsp), %r12
movq (%rsp), %rdi
callq 0x2160
movq %rax, %rcx
jmp 0x36f3
addq $0x90, %r13
jmp 0x36d6
cmpl $0x0, 0x60(%rbp)
je 0x3aed
movq 0x8(%rsp), %rbx
movq 0xd0(%rbx), %rsi
subq 0xc8(%rbx), %rsi
shrq $0x3, %rsi
leaq 0x9b28(%rip), %rdi      # 0xd524
xorl %eax, %eax
callq 0x2040
cmpl $0x3, 0x60(%rbx)
jb 0x3aed
movq 0x8(%rsp), %rax
movq 0x18(%rax), %r13
movq 0x20(%rax), %rax
movq %rax, 0x10(%rsp)
leaq 0x40(%rsp), %r15
leaq 0xf8(%rsp), %r12
leaq 0x98(%rsp), %rbp
cmpq 0x10(%rsp), %r13
je 0x3aed
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
andq $0x0, 0x48(%rsp)
movb $0x0, 0x50(%rsp)
movq 0x10(%r13), %rbx
movq %r13, (%rsp)
movq 0x18(%r13), %r13
cmpq %r13, %rbx
je 0x3aa2
movl (%rbx), %esi
movq %r12, %rdi
callq 0x87e9
movq %rbp, %rdi
movq %r12, %rsi
leaq 0x9fdc(%rip), %rdx      # 0xda58
callq 0x87ca
movq %r15, %rdi
movq %rbp, %rsi
callq 0x2220
movq %rbp, %rdi
callq 0x20b0
movq %r12, %rdi
callq 0x20b0
addq $0x4, %rbx
jmp 0x3a60
cmpq $0x0, 0x48(%rsp)
je 0x3ab2
movq %r15, %rdi
callq 0x2180
movq (%rsp), %r13
movl 0x60(%r13), %esi
movq 0x18(%r13), %rdx
subq 0x10(%r13), %rdx
shrq $0x2, %rdx
movq 0x40(%rsp), %rcx
leaq 0x9a69(%rip), %rdi      # 0xd53b
xorl %eax, %eax
callq 0x2040
movq %r15, %rdi
callq 0x20b0
addq $0x90, %r13
jmp 0x3a34
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %rax
andq $0x0, 0x10(%rax)
movaps %xmm0, (%rax)
leaq 0xc0(%rsp), %r15
leaq 0x98(%rsp), %r13
movl $0x0, 0x1c(%rsp)
movl $0x0, 0x88(%rsp)
movq 0x8(%rsp), %rbx
movq %r15, %rdi
callq 0xac1a
movq 0x18(%rbx), %r12
movq 0x20(%rbx), %rax
movq %rax, 0xf0(%rsp)
movb $0x1, %al
movl %eax, 0x3c(%rsp)
cmpq 0xf0(%rsp), %r12
je 0x3fcb
cmpb $0x0, 0x74(%r12)
jne 0x3b69
movq 0x18(%r12), %rax
subq 0x10(%r12), %rax
cmpq $0x5, %rax
jae 0x3b72
addq $0x90, %r12
jmp 0x3b43
movss (%r12), %xmm0
movss 0x4(%r12), %xmm1
movss 0x8(%r12), %xmm2
movss 0xc(%r12), %xmm3
movaps %xmm1, %xmm5
subss %xmm3, %xmm5
movaps %xmm2, %xmm4
subss %xmm0, %xmm4
movss %xmm4, 0x28(%rsp)
movss %xmm5, 0x10(%rsp)
addss %xmm5, %xmm4
ucomiss 0x94b6(%rip), %xmm4     # 0xd068
jne 0x3bba
jnp 0x409d
leaq 0x10(%r12), %rax
movq %rax, 0x90(%rsp)
movaps %xmm0, %xmm4
subss %xmm2, %xmm4
subss %xmm1, %xmm3
mulss %xmm0, %xmm3
mulss %xmm1, %xmm4
addss %xmm3, %xmm4
movss %xmm4, 0x80(%rsp)
movq 0x18(%rbx), %rbp
movq 0x20(%rbx), %rax
movq %r12, 0x20(%rsp)
movq %rax, 0x68(%rsp)
cmpq %rax, %rbp
je 0x3b69
cmpb $0x0, 0x74(%rbp)
jne 0x3fbf
movq 0x18(%rbp), %rax
subq 0x10(%rbp), %rax
cmpq $0x5, %rax
jb 0x3fba
movl 0x60(%r12), %eax
movl 0x60(%rbp), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x98(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0xaa8a
movl 0x60(%rbp), %eax
movl 0x60(%r12), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x98(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0xaa8a
movl 0x60(%r12), %eax
cmpl 0x60(%rbp), %eax
je 0x3fba
movq 0x10(%rbp), %rax
cmpq 0x18(%rbp), %rax
je 0x3fba
cmpq %rbp, %r12
je 0x407e
movq 0x40(%rsp), %rax
cmpq %rax, 0x48(%rsp)
je 0x3c98
movq %rax, 0x48(%rsp)
movq %rbp, 0x30(%rsp)
leaq 0x10(%rbp), %rax
movq %rax, 0xb8(%rsp)
movq 0x10(%r12), %rbp
movq 0x18(%r12), %rax
movq %rax, 0x78(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, (%rsp)
xorl %r12d, %r12d
cmpq 0x78(%rsp), %rbp
je 0x3d3b
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rbx
movq 0x18(%rax), %r15
cmpq %r15, %rbx
je 0x3d35
movl (%rbx), %eax
cmpl %eax, (%rbp)
jne 0x3cf5
leaq 0x40(%rsp), %rdi
movq %rbp, %rsi
callq 0x87ac
incl %r12d
movl (%rbx), %eax
movl %eax, %eax
movq (%r14), %rcx
movsd (%rcx,%rax,8), %xmm0
movsd %xmm0, 0x98(%rsp)
movss 0x10(%rsp), %xmm0
movss 0x28(%rsp), %xmm1
movss 0x80(%rsp), %xmm2
movq %r13, %rdi
callq 0x8846
maxss (%rsp), %xmm0
addq $0x4, %rbx
movss %xmm0, (%rsp)
jmp 0x3cd7
addq $0x4, %rbp
jmp 0x3cc3
cmpl $0x1, %r12d
jbe 0x3e12
movss 0x9317(%rip), %xmm0     # 0xd064
movss (%rsp), %xmm1
ucomiss %xmm1, %xmm0
movl 0x1c(%rsp), %ebx
jae 0x3e2e
movq 0x40(%rsp), %r12
movq 0x48(%rsp), %rax
movq %rax, 0x78(%rsp)
xorl %r15d, %r15d
xorl %ebp, %ebp
cmpq 0x78(%rsp), %r12
je 0x3f11
movl (%r12), %edx
leaq 0x98b9(%rip), %rdi      # 0xd642
movl %ebx, %esi
xorl %eax, %eax
callq 0x2040
movq 0x90(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rcx
movq 0x18(%rcx), %rcx
cmpq %rcx, %rax
je 0x3dce
movl (%rax), %edx
cmpl (%r12), %edx
je 0x3db9
addq $0x4, %rax
jmp 0x3da6
movq 0x90(%rsp), %rdi
movq %rax, %rsi
callq 0x889a
incl %r15d
jmp 0x3d9d
movq 0xb8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rsp), %rcx
movq 0x18(%rcx), %rcx
cmpq %rcx, %rax
je 0x3e09
movl (%rax), %edx
cmpl (%r12), %edx
je 0x3df5
addq $0x4, %rax
jmp 0x3de2
movq 0xb8(%rsp), %rdi
movq %rax, %rsi
callq 0x889a
incl %ebp
jmp 0x3dd9
addq $0x4, %r12
jmp 0x3d73
movq 0x8(%rsp), %rbx
leaq 0xc0(%rsp), %r15
movq 0x20(%rsp), %r12
movq 0x30(%rsp), %rbp
jmp 0x3fba
movq 0x20(%rsp), %rax
movl 0x60(%rax), %edx
movl %ebx, %esi
movq 0x30(%rsp), %rbx
movl 0x60(%rbx), %ecx
cvtss2sd %xmm1, %xmm0
leaq 0x976c(%rip), %rdi      # 0xd5b7
movl %esi, 0x1c(%rsp)
movl %r12d, %r8d
movsd %xmm0, (%rsp)
movb $0x1, %al
callq 0x2040
movq 0x10(%rbx), %r12
movq 0x18(%rbx), %rbx
xorl %ebp, %ebp
cmpq %rbx, %r12
je 0x3ea0
movq 0x20(%rsp), %r15
movq 0x10(%r15), %rdi
movq 0x18(%r15), %rsi
movq %r12, %rdx
callq 0x9d20
cmpq 0x18(%r15), %rax
jne 0x3e9a
movq 0x90(%rsp), %rdi
movq %r12, %rsi
callq 0x87ac
incl %ebp
addq $0x4, %r12
jmp 0x3e68
testl %ebp, %ebp
movq 0x20(%rsp), %r12
movq 0x30(%rsp), %rbx
je 0x3ecf
movl 0x60(%rbx), %ecx
movl 0x60(%r12), %r8d
leaq 0x9748(%rip), %rdi      # 0xd605
movl 0x1c(%rsp), %esi
movl %ebp, %edx
movsd (%rsp), %xmm0
movb $0x1, %al
callq 0x2040
movq 0x10(%rbx), %rax
cmpq %rax, 0x18(%rbx)
leaq 0xc0(%rsp), %r15
movq %rbx, %rbp
je 0x3ee8
movq %rax, 0x18(%rbp)
andq $0x0, 0x58(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, (%rbp)
movb $0x1, 0x74(%rbp)
incl 0x88(%rsp)
movl $0x0, 0x3c(%rsp)
movq 0x8(%rsp), %rbx
jmp 0x3fba
movq 0x40(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x98(%rsp)
movq 0x90(%rsp), %rdi
movq %r13, %rsi
callq 0x87ac
movq 0xb8(%rsp), %rdi
movq %r13, %rsi
callq 0x87ac
movq 0x20(%rsp), %r12
movl 0x60(%r12), %edx
movq 0x48(%rsp), %rcx
subq 0x40(%rsp), %rcx
shrq $0x2, %rcx
movl %ebx, %esi
movq 0x30(%rsp), %rbx
movl 0x60(%rbx), %r8d
movl 0x98(%rsp), %r9d
movq 0x18(%r12), %r10
subq 0x10(%r12), %r10
shrq $0x2, %r10
movq 0x18(%rbx), %r11
subq 0x10(%rbx), %r11
shrq $0x2, %r11
cvtss2sd (%rsp), %xmm0
leaq 0x96be(%rip), %rdi      # 0xd64e
movb $0x1, %al
pushq %r11
pushq %r10
pushq %rbp
movq %rbx, %rbp
pushq %r15
callq 0x2040
addq $0x20, %rsp
movl $0x0, 0x3c(%rsp)
movq 0x8(%rsp), %rbx
leaq 0xc0(%rsp), %r15
movq 0x68(%rsp), %rax
addq $0x90, %rbp
jmp 0x3bf9
cmpl $0x0, 0x60(%rbx)
setne %al
movl 0x3c(%rsp), %ebp
testb %al, %bpl
je 0x3fed
leaq 0x96de(%rip), %rdi      # 0xd6c0
movl 0x1c(%rsp), %esi
xorl %eax, %eax
callq 0x2040
incl 0x1c(%rsp)
testb $0x1, %bpl
je 0x3b25
leaq 0x96c8(%rip), %rdi      # 0xd6ca
movl 0x88(%rsp), %esi
xorl %eax, %eax
callq 0x2040
movq 0x18(%rbx), %r14
movq 0x20(%rbx), %r15
leaq 0x96de(%rip), %rbx      # 0xd6fd
pushq $0x1
popq %rbp
cmpq %r15, %r14
je 0x404e
movq 0x18(%r14), %rax
subq 0x10(%r14), %rax
cmpq $0x4, %rax
jne 0x4045
movl 0x60(%r14), %esi
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2040
addq $0x90, %r14
jmp 0x4022
leaq 0x40(%rsp), %rdi
callq 0x973e
leaq 0xc0(%rsp), %rdi
callq 0x9444
movl 0x8c(%rsp), %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9527(%rip), %rdi      # 0xd5ac
leaq 0x9088(%rip), %rsi      # 0xd114
leaq 0x94e9(%rip), %rcx      # 0xd57c
movl $0x393, %edx            # imm = 0x393
callq 0x20f0
movl 0x60(%r12), %esi
cvtss2sd %xmm0, %xmm0
cvtss2sd %xmm1, %xmm1
cvtss2sd %xmm2, %xmm2
cvtss2sd %xmm3, %xmm3
leaq 0x949d(%rip), %rdi      # 0xd556
movb $0x4, %al
callq 0x2040
leaq 0x94b3(%rip), %rdi      # 0xd57a
leaq 0x9046(%rip), %rsi      # 0xd114
leaq 0x94a7(%rip), %rcx      # 0xd57c
movl $0x37e, %edx            # imm = 0x37E
callq 0x20f0
jmp 0x415d
jmp 0x415d
jmp 0x415d
jmp 0x4162
movq %rax, %rbx
jmp 0x410e
movq %rax, %rbx
jmp 0x4101
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x20b0
leaq 0xf8(%rsp), %rdi
callq 0x20b0
leaq 0x40(%rsp), %rdi
callq 0x20b0
jmp 0x416f
movq %rax, %rbx
jmp 0x413e
movq %rax, %rbx
jmp 0x4131
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x20b0
leaq 0x98(%rsp), %rdi
callq 0x20b0
leaq 0xc0(%rsp), %rdi
callq 0x20b0
jmp 0x417c
jmp 0x415d
jmp 0x4162
jmp 0x4162
jmp 0x4162
jmp 0x415d
jmp 0x4162
jmp 0x4162
jmp 0x4162
movq %rax, %rbx
jmp 0x416f
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x973e
leaq 0xc0(%rsp), %rdi
callq 0x9444
movq %rbx, %rdi
callq 0x2200