// File: micahcc[P]polygon_skeleton/voronoi.cpp
// Function: Voronoi::Implementation::processEvent(CircleEvent const&)
void Voronoi::Implementation::processEvent(const CircleEvent& event)
{
    assert(event.left_int.pt_right == event.right_int.pt_left);
    assert(event.left_int.pt_right == event.right_int.pt_left);
    std::cerr << "--------\nProcessing Event at "
        << (event.circle.center.y - event.circle.radius)
        << " for: [" << event.left_int.pt_left << " -- "
        << event.left_int.pt_right << "], [" << event.right_int.pt_left << " -- "
        << event.right_int.pt_right << "]\n";

    // This essentially locks in the results of a single point (the middle part
    // of the two intersections, that means we must remove all events related to
    // this point


    // Suppose that intersections A and B meet (when the middle peak is beat out
    // by the side peaks):
    // l |   |     | r
    //   \  A/ |   |
    //    \ / v\B  /
    //     v    \ /
    //           v

    // |     |
    // |     |      |
    // \    C/      |
    //  \   / \     /
    //   \ /   \   /
    //    v     \ /
    //           v
    //
    // First we will remove the intersections A and B from the beach line
    //
    // Now if there are other intersections to the left of A, there would be an
    // event associated with A and that (l), same for an event to the right of
    // B (r). Those events can no longer occur because the intersections A (of
    // the left and center peak) and B (of the center and right peaks) will no
    // longer exist when the center peak has been hidden. Therefore we must
    // remove those events.
    //
    // We then have a new intersection on the beach line (C) which can have
    // events with l and r (when they exist)

    // find intersections to the left and right on the beach line, so we can
    // create a new event for when they meet
    {
    for(auto it1 = m_beach.begin(); it1 != m_beach.end(); ++it1) {
        auto it2 = it1;
        it2++;
        if(it2 != m_beach.end() && !m_beach_compare(*it1, *it2)) {
            std::cerr << it1->pt_left << ", " << it1->pt_right
                << " comes before " << it2->pt_left << ", " << it2->pt_right
                << "but it is not less!" << std::endl;
            throw -1;
        }
    }
    }

    bool success;
    BeachLineT::iterator it_new;
    std::cerr << "Looking up event location" << std::endl;
    auto it = m_beach.find(event.left_int);
    assert(it != m_beach.begin());
    assert(it != m_beach.end());

    std::cerr << "Left Int: [" << *(*it).pt_left << " -- " << *(*it).pt_right << std::endl;
    it--;
    auto left_neighbor = *it;
    it++;
    auto left_it = it;
    assert(left_it->pt_right == event.left_int.pt_right);
    assert(left_it->pt_left == event.left_int.pt_left);
    it++;
    auto right_it = it;
    assert(right_it->pt_right == event.right_int.pt_right);
    assert(right_it->pt_left == event.right_int.pt_left);
    std::cerr << "Right Int: [" << *(*it).pt_left << " -- " << *(*it).pt_right << std::endl;
    it++;
    auto right_neighbor = *it;
    assert(left_neighbor.pt_right == event.left_int.pt_left);
    assert(right_neighbor.pt_left == event.right_int.pt_right);

    // Find the 3 unique points so that we can create the necessary boundary
    // lines
    const Point* ptA = event.left_int.pt_left;
    const Point* ptB = event.left_int.pt_right;
    const Point* ptC = event.right_int.pt_right;

    // erase any other meetings with these two events
    m_events.erase(left_neighbor, event.left_int);
    m_events.erase(event.right_int, right_neighbor);

    // delete arc (i.e. erase both intersections related to the current event)
    std::cerr << "Erasing from beach" << std::endl;
    m_beach.erase(left_it);
    m_beach.erase(right_it);

    // Update sweep location so that our beach inserts go in the correct
    // location. Note we do this after the beach erase because technically at
    // this event the left and right intersections meet so there might be a
    // little strangeness with the ordering at sweep_y. Therefore just erase the
    // points first (above)
    *m_beach_compare.sweep_y = event.circle.center.y - event.circle.radius;

    // create new intersection of the outtermost arcs (left point of left
    // intersection and right point of right intersection)
    std::cerr << "Creating new beach point" << std::endl;
    std::tie(it_new, success) = m_beach.emplace(event.left_int.pt_left,
            event.right_int.pt_right);
    assert(success);

    // create new event(s) for the meeting of the new intersection and its
    // neighors, excepting the cases where 1) there is no neighboring
    // intersection because the neighbor is a special endpoint (nullptr for one
    // of its points) or 2) the neighboring intersection and new intersection
    // have the same three points that we just processed
    if(left_neighbor.pt_left != nullptr) {
        // Make sure that we aren't creating a new event for the points we just
        // processed
        auto event_points = std::make_tuple(left_neighbor.pt_left,
                it_new->pt_left, it_new->pt_right);
        if(!points_match(event_points, std::make_tuple(ptA, ptB, ptC)))
            m_events.insert(*m_beach_compare.sweep_y, left_neighbor, *it_new);
    }
    if(right_neighbor.pt_right != nullptr) {
        // Make sure that we aren't creating a new event for the points we just
        // processed
        auto event_points = std::make_tuple(it_new->pt_left, it_new->pt_right,
                right_neighbor.pt_right);
        if(!points_match(event_points, std::make_tuple(ptA, ptB, ptC)))
            m_events.insert(*m_beach_compare.sweep_y, *it_new, right_neighbor);
    }

//    Line line0{*event.left_int.pt_left, *event.left_int.pt_right};
//    Line line1{*event.right_int.pt_left, *event.right_int.pt_right};
//    lines.push_back(line0);
//    lines.push_back(line1);
//
//    // finish off boundaries related to the middle point
//    auto itb = m_bounds.find(left_neighbor.pt_left, left_neighbor.pt_right);
//    assert(itb != m_bounds.end());
//    itb->circle_pt = right_neighbor.pt_right;
//
//    itb = m_bounds.find(right_neighbor.pt_left, right_neighbor.pt_right);
//    assert(itb != m_bounds.end());
//    itb->circle_pt = left_neighbor.pt_left;
        for(const auto& tup_node: m_nodes) {
            assert(tup_node.second != nullptr);
            std::cerr << tup_node.second->x << ", "
                << tup_node.second->y << std::endl;
        }

    // The new center point connects to bisectors of each of the individual
    // pairs of points, these are rays from the center of the event circle to
    // each of the bisectors. Note that the first two points define the line
    // beginning, so all 3 possible pairs of the 3 points must show up
    Node::Ptr nodeCenter = getNode(ptA, ptB, ptC);
    Node::Ptr nodeAB = getNode(ptA, ptB);
    Node::Ptr nodeBC = getNode(ptB, ptC);
    Node::Ptr nodeCA = getNode(ptA, ptC);
    assert(nodeCenter != nullptr);
    assert(nodeAB != nullptr);
    assert(nodeBC != nullptr);
    assert(nodeCA != nullptr);

        for(const auto& tup_node: m_nodes) {
            assert(tup_node.second != nullptr);
            std::cerr << tup_node.second->x << ", "
                << tup_node.second->y << std::endl;
        }
    float distAB = perp(event.circle.center, *ptA, *ptB);
    float distBC = perp(event.circle.center, *ptB, *ptC);
    float distCA = perp(event.circle.center, *ptC, *ptA);
    if((distAB <= 0 && distBC <= 0 && distCA <= 0) ||
            (distAB >= 0 && distBC >= 0 && distCA >= 0)) {
        // point inside triangle
        addTriplet(nodeCenter, nodeAB, nodeBC, nodeCA);
    } else {
        // Whichever ever side of the triangle had the opposite sign as the
        // other two, is the one that we need to connect with
        std::cerr << "center = ["<< event.circle.center << "]"
            << "\n\ttriangle = [" << *ptA << ";"
            << "\n\t" << *ptB << ";"
            << "\n\t" << *ptC << "]"
            << std::endl;
        if((distBC <= 0 && (distCA >= 0 && distAB >=0)) ||
                (distBC >= 0 && (distCA <= 0 && distAB <=0))) {
            // distBC is the odd man out, move ptC into ptA so that A, B are
            // nearest
            addTriplet(nodeBC, nodeCenter, nodeCA, nodeAB);
        } else if((distCA <= 0 && (distAB >= 0 && distBC >=0)) ||
                (distCA >= 0 && (distAB <= 0 && distBC <=0))) {
            // distCA is the odd man out, swap nodeAB and nodeCA
            addTriplet(nodeCA, nodeCenter, nodeAB, nodeBC);
        } else {
            addTriplet(nodeAB, nodeCenter, nodeBC, nodeCA);
        }

    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x510, %rsp            # imm = 0x510
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x350(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0xa942
jmp 0xa961
leaq 0x18b60(%rip), %rdi     # 0x234a9
leaq 0x1897e(%rip), %rsi     # 0x232ce
movl $0x254, %edx            # imm = 0x254
leaq 0x18b80(%rip), %rcx     # 0x234dc
callq 0x3170
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0xa975
jmp 0xa994
leaq 0x18b2d(%rip), %rdi     # 0x234a9
leaq 0x1894b(%rip), %rsi     # 0x232ce
movl $0x255, %edx            # imm = 0x255
leaq 0x18b4d(%rip), %rcx     # 0x234dc
callq 0x3170
movq 0x28655(%rip), %rdi     # 0x32ff0
leaq 0x18b7a(%rip), %rsi     # 0x2351c
callq 0x3250
movq %rax, %rdi
movq -0x10(%rbp), %rax
movss 0x24(%rax), %xmm0
movq -0x10(%rbp), %rax
subss 0x28(%rax), %xmm0
callq 0x31b0
movq %rax, %rdi
leaq 0x18b6f(%rip), %rsi     # 0x2353a
callq 0x3250
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0x18b59(%rip), %rsi     # 0x23542
callq 0x3250
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0x18b3f(%rip), %rsi     # 0x23547
callq 0x3250
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0x18b1b(%rip), %rsi     # 0x23542
callq 0x3250
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0x18b06(%rip), %rsi     # 0x2354c
callq 0x3250
movq -0x350(%rbp), %rdi
addq $0x10, %rdi
callq 0x102a0
movq %rax, -0x18(%rbp)
movq -0x350(%rbp), %rdi
addq $0x10, %rdi
callq 0x10300
movq %rax, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x102d0
testb $0x1, %al
jne 0xaa89
jmp 0xac1f
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
callq 0x10330
movq -0x350(%rbp), %rdi
movq %rax, -0x30(%rbp)
addq $0x10, %rdi
callq 0x10300
movq %rax, -0x38(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x102d0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x351(%rbp)
jne 0xaad2
jmp 0xab1b
movq -0x350(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x368(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x10970
movq %rax, -0x360(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x10970
movq -0x368(%rbp), %rdi
movq -0x360(%rbp), %rsi
movq %rax, %rdx
callq 0x10370
xorb $-0x1, %al
movb %al, -0x351(%rbp)
movb -0x351(%rbp), %al
testb $0x1, %al
jne 0xab2a
jmp 0xac0f
leaq -0x18(%rbp), %rdi
callq 0x109a0
movq (%rax), %rsi
movq 0x284b3(%rip), %rdi     # 0x32ff0
callq 0x31e0
movq %rax, %rdi
leaq 0x1852b(%rip), %rsi     # 0x23077
callq 0x3250
movq %rax, -0x380(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x109a0
movq -0x380(%rbp), %rdi
movq 0x8(%rax), %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0x189d4(%rip), %rsi     # 0x2354f
callq 0x3250
movq %rax, -0x378(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x109a0
movq -0x378(%rbp), %rdi
movq (%rax), %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0x184ce(%rip), %rsi     # 0x23077
callq 0x3250
movq %rax, -0x370(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x109a0
movq -0x370(%rbp), %rdi
movq 0x8(%rax), %rsi
callq 0x31e0
movq %rax, %rdi
leaq 0x18986(%rip), %rsi     # 0x2355e
callq 0x3250
movq %rax, %rdi
movq 0x283d9(%rip), %rsi     # 0x32fc0
callq 0x3290
movl $0x4, %edi
callq 0x30f0
movq %rax, %rdi
movl $0xffffffff, (%rdi)     # imm = 0xFFFFFFFF
movq 0x283aa(%rip), %rsi     # 0x32fb0
xorl %eax, %eax
movl %eax, %edx
callq 0x33d0
jmp 0xac11
leaq -0x18(%rbp), %rdi
callq 0x109c0
jmp 0xaa5f
leaq -0x48(%rbp), %rdi
callq 0x109f0
movq 0x283c1(%rip), %rdi     # 0x32ff0
leaq 0x1893c(%rip), %rsi     # 0x23572
callq 0x3250
movq %rax, %rdi
movq 0x2837b(%rip), %rsi     # 0x32fc0
callq 0x3290
movq -0x350(%rbp), %rdi
addq $0x10, %rdi
movq -0x10(%rbp), %rsi
callq 0x10a10
movq -0x350(%rbp), %rdi
movq %rax, -0x50(%rbp)
addq $0x10, %rdi
callq 0x102a0
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x102d0
testb $0x1, %al
jne 0xac89
jmp 0xac8b
jmp 0xacaa
leaq 0x188fa(%rip), %rdi     # 0x2358c
leaq 0x18635(%rip), %rsi     # 0x232ce
movl $0x290, %edx            # imm = 0x290
leaq 0x18837(%rip), %rcx     # 0x234dc
callq 0x3170
movq -0x350(%rbp), %rdi
addq $0x10, %rdi
callq 0x10300
movq %rax, -0x60(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x102d0
testb $0x1, %al
jne 0xacd1
jmp 0xacd3
jmp 0xacf2
leaq 0x188c8(%rip), %rdi     # 0x235a2
leaq 0x185ed(%rip), %rsi     # 0x232ce
movl $0x291, %edx            # imm = 0x291
leaq 0x187ef(%rip), %rcx     # 0x234dc
callq 0x3170
movq 0x282f7(%rip), %rdi     # 0x32ff0
leaq 0x188b6(%rip), %rsi     # 0x235b6
callq 0x3250
movq %rax, -0x390(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x10970
movq -0x390(%rbp), %rdi
movq (%rax), %rsi
callq 0xa320
movq %rax, %rdi
leaq 0x18814(%rip), %rsi     # 0x23542
callq 0x3250
movq %rax, -0x388(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x10970
movq -0x388(%rbp), %rdi
movq 0x8(%rax), %rsi
callq 0xa320
movq %rax, %rdi
movq 0x28263(%rip), %rsi     # 0x32fc0
callq 0x3290
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x10a50
movq %rax, -0x68(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x10970
movq (%rax), %rcx
movq %rcx, -0x78(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x10330
movq %rax, -0x80(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x109a0
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0xadbf
jmp 0xadde
leaq 0x187fc(%rip), %rdi     # 0x235c2
leaq 0x18501(%rip), %rsi     # 0x232ce
movl $0x298, %edx            # imm = 0x298
leaq 0x18703(%rip), %rcx     # 0x234dc
callq 0x3170
leaq -0x88(%rbp), %rdi
callq 0x109a0
movq (%rax), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jne 0xadf8
jmp 0xae17
leaq 0x187f0(%rip), %rdi     # 0x235ef
leaq 0x184c8(%rip), %rsi     # 0x232ce
movl $0x299, %edx            # imm = 0x299
leaq 0x186ca(%rip), %rcx     # 0x234dc
callq 0x3170
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x10330
movq %rax, -0x90(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x109a0
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0xae50
jmp 0xae6f
leaq 0x187c3(%rip), %rdi     # 0x2361a
leaq 0x18470(%rip), %rsi     # 0x232ce
movl $0x29c, %edx            # imm = 0x29C
leaq 0x18672(%rip), %rcx     # 0x234dc
callq 0x3170
leaq -0x98(%rbp), %rdi
callq 0x109a0
movq (%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0xae8a
jmp 0xaea9
leaq 0x187b8(%rip), %rdi     # 0x23649
leaq 0x18436(%rip), %rsi     # 0x232ce
movl $0x29d, %edx            # imm = 0x29D
leaq 0x18638(%rip), %rcx     # 0x234dc
callq 0x3170
movq 0x28140(%rip), %rdi     # 0x32ff0
leaq 0x187bf(%rip), %rsi     # 0x23676
callq 0x3250
movq %rax, -0x3a0(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x10970
movq -0x3a0(%rbp), %rdi
movq (%rax), %rsi
callq 0xa320
movq %rax, %rdi
leaq 0x1865d(%rip), %rsi     # 0x23542
callq 0x3250
movq %rax, -0x398(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x10970
movq -0x398(%rbp), %rdi
movq 0x8(%rax), %rsi
callq 0xa320
movq %rax, %rdi
movq 0x280ac(%rip), %rsi     # 0x32fc0
callq 0x3290
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x10330
movq %rax, -0xa0(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x10970
movq (%rax), %rcx
movq %rcx, -0xb0(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0xa8(%rbp)
movq -0x70(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jne 0xaf58
jmp 0xaf77
leaq 0x18724(%rip), %rdi     # 0x23683
leaq 0x18368(%rip), %rsi     # 0x232ce
movl $0x2a1, %edx            # imm = 0x2A1
leaq 0x1856a(%rip), %rcx     # 0x234dc
callq 0x3170
movq -0xb0(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0xaf8a
jmp 0xafa9
leaq 0x18723(%rip), %rdi     # 0x236b4
leaq 0x18336(%rip), %rsi     # 0x232ce
movl $0x2a2, %edx            # imm = 0x2A2
leaq 0x18538(%rip), %rcx     # 0x234dc
callq 0x3170
movq -0x350(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xc8(%rbp)
addq $0x40, %rdi
movq %rdi, -0x3c0(%rbp)
movq -0x10(%rbp), %rdx
leaq -0x78(%rbp), %rsi
callq 0x10a90
movq -0x3c0(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x10, %rsi
leaq -0xb0(%rbp), %rdx
callq 0x10a90
movq 0x27fda(%rip), %rdi     # 0x32ff0
movq %rdi, -0x3b8(%rbp)
leaq 0x186c3(%rip), %rsi     # 0x236e7
callq 0x3250
movq %rax, %rdi
movq 0x27f8d(%rip), %rsi     # 0x32fc0
movq %rsi, -0x3b0(%rbp)
callq 0x3290
movq -0x350(%rbp), %rdi
addq $0x10, %rdi
movq %rdi, -0x3a8(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rsi
callq 0x10d10
movq -0x3a8(%rbp), %rdi
movq %rax, -0xd8(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rsi
callq 0x10d10
movq -0x3b8(%rbp), %rdi
movq %rax, %rcx
movq -0x350(%rbp), %rax
movq %rcx, -0xe8(%rbp)
movq -0x10(%rbp), %rcx
movss 0x24(%rcx), %xmm0
movss 0x28(%rcx), %xmm1
subss %xmm1, %xmm0
movq 0x8(%rax), %rax
movss %xmm0, (%rax)
leaq 0x1862e(%rip), %rsi     # 0x236fa
callq 0x3250
movq -0x3b0(%rbp), %rsi
movq %rax, %rdi
callq 0x3290
movq -0x3a8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq %rsi, %rdx
addq $0x18, %rdx
callq 0x10d50
movb %dl, -0x100(%rbp)
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0xf8(%rbp)
movb -0x100(%rbp), %al
movb %al, -0xf0(%rbp)
leaq -0x118(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x39(%rbp), %rdx
callq 0x10db0
leaq -0x118(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x10df0
testb $0x1, -0x39(%rbp)
je 0xb14d
jmp 0xb16c
leaq 0x185bf(%rip), %rdi     # 0x23713
leaq 0x18173(%rip), %rsi     # 0x232ce
movl $0x2bf, %edx            # imm = 0x2BF
leaq 0x18375(%rip), %rcx     # 0x234dc
callq 0x3170
cmpq $0x0, -0x78(%rbp)
je 0xb271
leaq -0x78(%rbp), %rax
movq %rax, -0x3d0(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x109a0
movq %rax, -0x3c8(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x109a0
movq -0x3d0(%rbp), %rsi
movq -0x3c8(%rbp), %rdx
movq %rax, %rcx
addq $0x8, %rcx
leaq -0x130(%rbp), %rdi
callq 0x10e50
movq -0x130(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0x128(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x120(%rbp), %rax
movq %rax, -0x138(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
leaq -0xc8(%rbp), %rcx
callq 0x10e90
leaq -0x148(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x93d0
xorb $-0x1, %al
testb $0x1, %al
jne 0xb222
jmp 0xb26f
movq -0x350(%rbp), %rax
movq %rax, %rcx
addq $0x40, %rcx
movq %rcx, -0x3e0(%rbp)
movq 0x8(%rax), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x3d8(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x10970
movq -0x3e0(%rbp), %rdi
movsd -0x3d8(%rbp), %xmm0
movq %rax, %rdx
leaq -0x78(%rbp), %rsi
callq 0x10ed0
jmp 0xb271
cmpq $0x0, -0xa8(%rbp)
je 0xb375
leaq -0x48(%rbp), %rdi
callq 0x109a0
movq %rax, -0x3e8(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x109a0
movq -0x3e8(%rbp), %rsi
movq %rax, %rdx
addq $0x8, %rdx
leaq -0xb0(%rbp), %rcx
addq $0x8, %rcx
leaq -0x178(%rbp), %rdi
callq 0x11300
movq -0x178(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0x170(%rbp), %rax
movq %rax, -0x188(%rbp)
movq -0x168(%rbp), %rax
movq %rax, -0x180(%rbp)
leaq -0x1a8(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
leaq -0xc8(%rbp), %rcx
callq 0x10e90
leaq -0x190(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x93d0
xorb $-0x1, %al
testb $0x1, %al
jne 0xb323
jmp 0xb373
movq -0x350(%rbp), %rax
movq %rax, %rcx
addq $0x40, %rcx
movq %rcx, -0x3f8(%rbp)
movq 0x8(%rax), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x3f0(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x10970
movq -0x3f8(%rbp), %rdi
movsd -0x3f0(%rbp), %xmm0
movq %rax, %rsi
leaq -0xb0(%rbp), %rdx
callq 0x10ed0
jmp 0xb375
movq -0x350(%rbp), %rax
addq $0x90, %rax
movq %rax, -0x1b0(%rbp)
movq -0x1b0(%rbp), %rdi
callq 0x11340
movq %rax, -0x1b8(%rbp)
movq -0x1b0(%rbp), %rdi
callq 0x11370
movq %rax, -0x1c0(%rbp)
leaq -0x1b8(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x113a0
testb $0x1, %al
jne 0xb3cb
jmp 0xb490
leaq -0x1b8(%rbp), %rdi
callq 0x113d0
movq %rax, -0x1c8(%rbp)
movq -0x1c8(%rbp), %rdi
addq $0x18, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x11400
testb $0x1, %al
jne 0xb3f8
jmp 0xb3fa
jmp 0xb419
leaq 0x1831a(%rip), %rdi     # 0x2371b
leaq 0x17ec6(%rip), %rsi     # 0x232ce
movl $0x2e5, %edx            # imm = 0x2E5
leaq 0x180c8(%rip), %rcx     # 0x234dc
callq 0x3170
movq -0x1c8(%rbp), %rdi
addq $0x18, %rdi
callq 0x11430
movss (%rax), %xmm0
movq 0x27bbc(%rip), %rdi     # 0x32ff0
callq 0x31b0
movq %rax, %rdi
leaq 0x17c34(%rip), %rsi     # 0x23077
callq 0x3250
movq %rax, -0x400(%rbp)
movq -0x1c8(%rbp), %rdi
addq $0x18, %rdi
callq 0x11430
movq -0x400(%rbp), %rdi
movss 0x4(%rax), %xmm0
callq 0x31b0
movq %rax, %rdi
movq 0x27b46(%rip), %rsi     # 0x32fc0
callq 0x3290
leaq -0x1b8(%rbp), %rdi
callq 0x11450
jmp 0xb3af
movq -0x350(%rbp), %rsi
movq -0xb8(%rbp), %rdx
movq -0xc0(%rbp), %rcx
movq -0xc8(%rbp), %r8
leaq -0x1d8(%rbp), %rdi
callq 0xbf70
movq -0x350(%rbp), %rsi
movq -0xb8(%rbp), %rdx
movq -0xc0(%rbp), %rcx
leaq -0x1e8(%rbp), %rdi
callq 0xc360
jmp 0xb4db
movq -0x350(%rbp), %rsi
movq -0xc0(%rbp), %rdx
movq -0xc8(%rbp), %rcx
leaq -0x208(%rbp), %rdi
callq 0xc360
jmp 0xb4fe
movq -0x350(%rbp), %rsi
movq -0xb8(%rbp), %rdx
movq -0xc8(%rbp), %rcx
leaq -0x218(%rbp), %rdi
callq 0xc360
jmp 0xb521
leaq -0x1d8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x11400
testb $0x1, %al
jne 0xb537
jmp 0xb539
jmp 0xb59d
leaq 0x181f6(%rip), %rdi     # 0x23736
leaq 0x17d87(%rip), %rsi     # 0x232ce
movl $0x2f2, %edx            # imm = 0x2F2
leaq 0x17f89(%rip), %rcx     # 0x234dc
callq 0x3170
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
jmp 0xbf4c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
jmp 0xbf40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
jmp 0xbf34
leaq -0x1e8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x11400
testb $0x1, %al
jne 0xb5b3
jmp 0xb5b5
jmp 0xb5d4
leaq 0x18190(%rip), %rdi     # 0x2374c
leaq 0x17d0b(%rip), %rsi     # 0x232ce
movl $0x2f3, %edx            # imm = 0x2F3
leaq 0x17f0d(%rip), %rcx     # 0x234dc
callq 0x3170
leaq -0x208(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x11400
testb $0x1, %al
jne 0xb5ea
jmp 0xb5ec
jmp 0xb60b
leaq 0x1816b(%rip), %rdi     # 0x2375e
leaq 0x17cd4(%rip), %rsi     # 0x232ce
movl $0x2f4, %edx            # imm = 0x2F4
leaq 0x17ed6(%rip), %rcx     # 0x234dc
callq 0x3170
leaq -0x218(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x11400
testb $0x1, %al
jne 0xb621
jmp 0xb623
jmp 0xb642
leaq 0x18146(%rip), %rdi     # 0x23770
leaq 0x17c9d(%rip), %rsi     # 0x232ce
movl $0x2f5, %edx            # imm = 0x2F5
leaq 0x17e9f(%rip), %rcx     # 0x234dc
callq 0x3170
movq -0x350(%rbp), %rax
addq $0x90, %rax
movq %rax, -0x220(%rbp)
movq -0x220(%rbp), %rdi
callq 0x11340
movq %rax, -0x228(%rbp)
movq -0x220(%rbp), %rdi
callq 0x11370
movq %rax, -0x230(%rbp)
leaq -0x228(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x113a0
testb $0x1, %al
jne 0xb698
jmp 0xb794
leaq -0x228(%rbp), %rdi
callq 0x113d0
movq %rax, -0x238(%rbp)
movq -0x238(%rbp), %rdi
addq $0x18, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x11400
testb $0x1, %al
jne 0xb6c5
jmp 0xb6c7
jmp 0xb6e6
leaq 0x1804d(%rip), %rdi     # 0x2371b
leaq 0x17bf9(%rip), %rsi     # 0x232ce
movl $0x2f8, %edx            # imm = 0x2F8
leaq 0x17dfb(%rip), %rcx     # 0x234dc
callq 0x3170
movq -0x238(%rbp), %rdi
addq $0x18, %rdi
callq 0x11430
movss (%rax), %xmm0
movq 0x278ef(%rip), %rdi     # 0x32ff0
callq 0x31b0
movq %rax, -0x408(%rbp)
jmp 0xb70f
movq -0x408(%rbp), %rdi
leaq 0x1795a(%rip), %rsi     # 0x23077
callq 0x3250
movq %rax, -0x410(%rbp)
jmp 0xb72b
movq -0x238(%rbp), %rdi
addq $0x18, %rdi
callq 0x11430
movq -0x410(%rbp), %rdi
movss 0x4(%rax), %xmm0
callq 0x31b0
movq %rax, -0x418(%rbp)
jmp 0xb755
movq -0x418(%rbp), %rdi
movq 0x2785d(%rip), %rsi     # 0x32fc0
callq 0x3290
jmp 0xb76a
jmp 0xb76c
leaq -0x228(%rbp), %rdi
callq 0x11450
jmp 0xb67c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
jmp 0xbf28
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
movq -0xb8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
callq 0x11480
movss %xmm0, -0x41c(%rbp)
jmp 0xb7b9
movss -0x41c(%rbp), %xmm0
movss %xmm0, -0x23c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
movq -0xc0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
callq 0x11480
movss %xmm0, -0x420(%rbp)
jmp 0xb7ee
movss -0x420(%rbp), %xmm0
movss %xmm0, -0x240(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
movq -0xc8(%rbp), %rsi
movq -0xb8(%rbp), %rdx
callq 0x11480
movss %xmm0, -0x424(%rbp)
jmp 0xb823
movss -0x424(%rbp), %xmm0
movss %xmm0, -0x244(%rbp)
xorps %xmm0, %xmm0
ucomiss -0x23c(%rbp), %xmm0
jb 0xb857
xorps %xmm0, %xmm0
ucomiss -0x240(%rbp), %xmm0
jb 0xb857
xorps %xmm0, %xmm0
ucomiss -0x244(%rbp), %xmm0
jae 0xb893
movss -0x23c(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0xb9a1
movss -0x240(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0xb9a1
movss -0x244(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0xb9a1
leaq -0x258(%rbp), %rdi
movq %rdi, -0x448(%rbp)
leaq -0x1d8(%rbp), %rsi
callq 0x114f0
leaq -0x268(%rbp), %rdi
movq %rdi, -0x440(%rbp)
leaq -0x1e8(%rbp), %rsi
callq 0x114f0
leaq -0x278(%rbp), %rdi
movq %rdi, -0x438(%rbp)
leaq -0x208(%rbp), %rsi
callq 0x114f0
leaq -0x288(%rbp), %rdi
movq %rdi, -0x430(%rbp)
leaq -0x218(%rbp), %rsi
callq 0x114f0
movq -0x350(%rbp), %rdi
movq -0x448(%rbp), %rsi
movq -0x440(%rbp), %rdx
movq -0x438(%rbp), %rcx
movq -0x430(%rbp), %r8
callq 0xc6b0
jmp 0xb925
leaq -0x288(%rbp), %rdi
callq 0x8a20
leaq -0x278(%rbp), %rdi
callq 0x8a20
leaq -0x268(%rbp), %rdi
callq 0x8a20
leaq -0x258(%rbp), %rdi
callq 0x8a20
jmp 0xbeef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x8a20
leaq -0x278(%rbp), %rdi
callq 0x8a20
leaq -0x268(%rbp), %rdi
callq 0x8a20
leaq -0x258(%rbp), %rdi
callq 0x8a20
jmp 0xbf28
movq 0x27648(%rip), %rdi     # 0x32ff0
leaq 0x17dd3(%rip), %rsi     # 0x23782
callq 0x3250
movq %rax, -0x450(%rbp)
jmp 0xb9bd
movq -0x450(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x20, %rsi
callq 0xa320
movq %rax, -0x458(%rbp)
jmp 0xb9da
movq -0x458(%rbp), %rdi
leaq 0x17da5(%rip), %rsi     # 0x2378d
callq 0x3250
movq %rax, -0x460(%rbp)
jmp 0xb9f6
movq -0x460(%rbp), %rdi
leaq 0x17d8b(%rip), %rsi     # 0x2378f
callq 0x3250
movq %rax, -0x468(%rbp)
jmp 0xba12
movq -0x468(%rbp), %rdi
movq -0xb8(%rbp), %rsi
callq 0xa320
movq %rax, -0x470(%rbp)
jmp 0xba2e
movq -0x470(%rbp), %rdi
leaq 0x17d62(%rip), %rsi     # 0x2379e
callq 0x3250
movq %rax, -0x478(%rbp)
jmp 0xba4a
movq -0x478(%rbp), %rdi
leaq 0x17d48(%rip), %rsi     # 0x237a0
callq 0x3250
movq %rax, -0x480(%rbp)
jmp 0xba66
movq -0x480(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0xa320
movq %rax, -0x488(%rbp)
jmp 0xba82
movq -0x488(%rbp), %rdi
leaq 0x17d0e(%rip), %rsi     # 0x2379e
callq 0x3250
movq %rax, -0x490(%rbp)
jmp 0xba9e
movq -0x490(%rbp), %rdi
leaq 0x17cf4(%rip), %rsi     # 0x237a0
callq 0x3250
movq %rax, -0x498(%rbp)
jmp 0xbaba
movq -0x498(%rbp), %rdi
movq -0xc8(%rbp), %rsi
callq 0xa320
movq %rax, -0x4a0(%rbp)
jmp 0xbad6
movq -0x4a0(%rbp), %rdi
leaq 0x17ca9(%rip), %rsi     # 0x2378d
callq 0x3250
movq %rax, -0x4a8(%rbp)
jmp 0xbaf2
movq -0x4a8(%rbp), %rdi
movq 0x274c0(%rip), %rsi     # 0x32fc0
callq 0x3290
jmp 0xbb07
xorps %xmm0, %xmm0
ucomiss -0x240(%rbp), %xmm0
jb 0xbb33
movss -0x244(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0xbb33
movss -0x23c(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jae 0xbb67
movss -0x240(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0xbc75
xorps %xmm0, %xmm0
ucomiss -0x244(%rbp), %xmm0
jb 0xbc75
xorps %xmm0, %xmm0
ucomiss -0x23c(%rbp), %xmm0
jb 0xbc75
leaq -0x298(%rbp), %rdi
movq %rdi, -0x4c8(%rbp)
leaq -0x208(%rbp), %rsi
callq 0x114f0
leaq -0x2a8(%rbp), %rdi
movq %rdi, -0x4c0(%rbp)
leaq -0x1d8(%rbp), %rsi
callq 0x114f0
leaq -0x2b8(%rbp), %rdi
movq %rdi, -0x4b8(%rbp)
leaq -0x218(%rbp), %rsi
callq 0x114f0
leaq -0x2c8(%rbp), %rdi
movq %rdi, -0x4b0(%rbp)
leaq -0x1e8(%rbp), %rsi
callq 0x114f0
movq -0x350(%rbp), %rdi
movq -0x4c8(%rbp), %rsi
movq -0x4c0(%rbp), %rdx
movq -0x4b8(%rbp), %rcx
movq -0x4b0(%rbp), %r8
callq 0xc6b0
jmp 0xbbf9
leaq -0x2c8(%rbp), %rdi
callq 0x8a20
leaq -0x2b8(%rbp), %rdi
callq 0x8a20
leaq -0x2a8(%rbp), %rdi
callq 0x8a20
leaq -0x298(%rbp), %rdi
callq 0x8a20
jmp 0xbeed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0x8a20
leaq -0x2b8(%rbp), %rdi
callq 0x8a20
leaq -0x2a8(%rbp), %rdi
callq 0x8a20
leaq -0x298(%rbp), %rdi
callq 0x8a20
jmp 0xbf28
xorps %xmm0, %xmm0
ucomiss -0x244(%rbp), %xmm0
jb 0xbca1
movss -0x23c(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0xbca1
movss -0x240(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jae 0xbcd5
movss -0x244(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0xbde3
xorps %xmm0, %xmm0
ucomiss -0x23c(%rbp), %xmm0
jb 0xbde3
xorps %xmm0, %xmm0
ucomiss -0x240(%rbp), %xmm0
jb 0xbde3
leaq -0x2d8(%rbp), %rdi
movq %rdi, -0x4e8(%rbp)
leaq -0x218(%rbp), %rsi
callq 0x114f0
leaq -0x2e8(%rbp), %rdi
movq %rdi, -0x4e0(%rbp)
leaq -0x1d8(%rbp), %rsi
callq 0x114f0
leaq -0x2f8(%rbp), %rdi
movq %rdi, -0x4d8(%rbp)
leaq -0x1e8(%rbp), %rsi
callq 0x114f0
leaq -0x308(%rbp), %rdi
movq %rdi, -0x4d0(%rbp)
leaq -0x208(%rbp), %rsi
callq 0x114f0
movq -0x350(%rbp), %rdi
movq -0x4e8(%rbp), %rsi
movq -0x4e0(%rbp), %rdx
movq -0x4d8(%rbp), %rcx
movq -0x4d0(%rbp), %r8
callq 0xc6b0
jmp 0xbd67
leaq -0x308(%rbp), %rdi
callq 0x8a20
leaq -0x2f8(%rbp), %rdi
callq 0x8a20
leaq -0x2e8(%rbp), %rdi
callq 0x8a20
leaq -0x2d8(%rbp), %rdi
callq 0x8a20
jmp 0xbeeb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
leaq -0x308(%rbp), %rdi
callq 0x8a20
leaq -0x2f8(%rbp), %rdi
callq 0x8a20
leaq -0x2e8(%rbp), %rdi
callq 0x8a20
leaq -0x2d8(%rbp), %rdi
callq 0x8a20
jmp 0xbf28
leaq -0x318(%rbp), %rdi
movq %rdi, -0x508(%rbp)
leaq -0x1e8(%rbp), %rsi
callq 0x114f0
leaq -0x328(%rbp), %rdi
movq %rdi, -0x500(%rbp)
leaq -0x1d8(%rbp), %rsi
callq 0x114f0
leaq -0x338(%rbp), %rdi
movq %rdi, -0x4f8(%rbp)
leaq -0x208(%rbp), %rsi
callq 0x114f0
leaq -0x348(%rbp), %rdi
movq %rdi, -0x4f0(%rbp)
leaq -0x218(%rbp), %rsi
callq 0x114f0
movq -0x350(%rbp), %rdi
movq -0x508(%rbp), %rsi
movq -0x500(%rbp), %rdx
movq -0x4f8(%rbp), %rcx
movq -0x4f0(%rbp), %r8
callq 0xc6b0
jmp 0xbe75
leaq -0x348(%rbp), %rdi
callq 0x8a20
leaq -0x338(%rbp), %rdi
callq 0x8a20
leaq -0x328(%rbp), %rdi
callq 0x8a20
leaq -0x318(%rbp), %rdi
callq 0x8a20
jmp 0xbeeb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
leaq -0x348(%rbp), %rdi
callq 0x8a20
leaq -0x338(%rbp), %rdi
callq 0x8a20
leaq -0x328(%rbp), %rdi
callq 0x8a20
leaq -0x318(%rbp), %rdi
callq 0x8a20
jmp 0xbf28
jmp 0xbeed
jmp 0xbeef
leaq -0x218(%rbp), %rdi
callq 0x8a20
leaq -0x208(%rbp), %rdi
callq 0x8a20
leaq -0x1e8(%rbp), %rdi
callq 0x8a20
leaq -0x1d8(%rbp), %rdi
callq 0x8a20
addq $0x510, %rsp            # imm = 0x510
popq %rbp
retq
leaq -0x218(%rbp), %rdi
callq 0x8a20
leaq -0x208(%rbp), %rdi
callq 0x8a20
leaq -0x1e8(%rbp), %rdi
callq 0x8a20
leaq -0x1d8(%rbp), %rdi
callq 0x8a20
movq -0x1f0(%rbp), %rdi
callq 0x3400
nopw %cs:(%rax,%rax)