// File: /workspace/github_cpp_makefile_star2_O2/micahcc[P]polygon_skeleton/voronoi.cpp
// Function: Voronoi::Implementation::processPoint(Vector const&)
void Voronoi::Implementation::processPoint(const Point& pt)
{
    std::cerr << "<----------------------" << std::endl;
    std::cerr << "<Processing point: " << pt << std::endl;

    // Update sweep location in beach line so that insertion takes place at the
    // right location

    *m_beach_compare.sweep_y = pt.y;

    // insert two new intersections in between existing intersections
    Intersection dummy{&pt, &pt};
    bool success;
    BeachLineT::iterator it1, it2, it_new;
    const Point* ptA = nullptr;
    const Point* ptB = nullptr;
    const Point* ptC = nullptr;
    const Point* ptD = nullptr;
    if(m_beach.empty()) {
        std::cerr << "<<<Beach empty, inserting special" << std::endl;
        // add null intersection
        // no intersections to erase
        m_beach.emplace(nullptr, &pt);
        m_beach.emplace(&pt, nullptr);
    } else {
        // In between two previous intersections, on the parabolar for the
        // shared point
        //
        //  iterator:      it1       it2
        //  struct:        pt_left pt_right   pt_left pt_right
        //  points:         A   B     B   C
        //  new inter:          B  D  B
        // intersection >= so take the first point
        std::cerr << "<<Finding beach location" << std::endl;
        it1 = m_beach.lower_bound(dummy);
        std::cerr << "<<Lower bound: (" << it1->pt_left << " -- "
            << it1->pt_right << ")" << std::endl;
        if(it1->pt_left) {
            std::cerr << "<<pt_left: " << *it1->pt_left << std::endl;
        }
        if(it1->pt_right) {
            std::cerr << "<<pt_right: " << *it1->pt_right << std::endl;
        }
        std::cerr << "<<Done" << std::endl;
        it2 = it1; it1--;
        ptB = it1->pt_right;
        ptD = &pt;

        std::cerr << "B: " << ptB << std::endl
            << "D: " << ptD << std::endl;
        // Insert new intersection into beach, then create an event for the old
        // left and the new intersection point
        std::cerr << "Inserting " << ptB << ", " << ptD << " into beach" << std::endl;
        std::tie(it_new, success) = m_beach.emplace(ptB, ptD);
        assert(success);
        if(it1->pt_left != nullptr)
            m_events.insert(*m_beach_compare.sweep_y, *it1, *it_new);

        // Insert new intersection int beach, then create a new event for the
        // old upper intersection and the new one
        std::cerr << "Inserting " << ptD << ", " << ptB << " into beach" << std::endl;
        std::tie(it_new, success) = m_beach.emplace(ptD, ptB);
        assert(success);
        if(it2->pt_right != nullptr)
            m_events.insert(*m_beach_compare.sweep_y, *it_new, *it2);

        // Erase the event that involved the meeting of our previous left and
        // right intersections (since we got in the middle)
        if(it1->pt_left != nullptr && it2->pt_right != nullptr) {
            m_events.erase(*it1, *it2);
        }
    }


    std::cerr << "<......................" << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r13
movq %rdi, %rbx
movq 0xc850(%rip), %r14      # 0x13ff0
leaq 0x6038(%rip), %rsi      # 0xd7df
movq %r14, %rdi
callq 0x31f0
movq %rax, %rdi
callq 0x30d0
leaq 0x6039(%rip), %rsi      # 0xd7f7
movq %r14, %rdi
callq 0x31f0
movq %rax, %r14
movq %rax, %rdi
movq %r13, %rsi
callq 0x62cf
movq %r14, %rdi
callq 0x30d0
movss 0x4(%r13), %xmm0
movq 0x8(%rbx), %rax
movss %xmm0, (%rax)
movq %r13, -0x70(%rbp)
andq $0x0, -0x38(%rbp)
movq %r13, -0x68(%rbp)
andq $0x0, -0x30(%rbp)
leaq 0x10(%rbx), %r15
xorl %eax, %eax
cmpq %rax, 0x38(%rbx)
je 0x7abc
movq 0xc7dd(%rip), %r14      # 0x13ff0
leaq 0x6013(%rip), %rsi      # 0xd82d
movq %r14, %rdi
callq 0x31f0
movq %rax, %rdi
callq 0x30d0
leaq -0x70(%rbp), %rsi
movq %r15, -0x48(%rbp)
movq %r15, %rdi
callq 0xa294
movq %rax, %r15
leaq 0x6002(%rip), %rsi      # 0xd846
movq %r14, %rdi
callq 0x31f0
leaq 0x20(%r15), %r12
movq 0x20(%r15), %rsi
movq %rax, %rdi
callq 0x3190
leaq 0x5d1b(%rip), %rsi      # 0xd57e
movq %rax, %rdi
callq 0x31f0
movq 0x28(%r15), %rsi
movq %rax, %rdi
callq 0x3190
leaq 0x6177(%rip), %rsi      # 0xd9f5
movq %rax, %rdi
callq 0x31f0
movq %rax, %rdi
callq 0x30d0
cmpq $0x0, 0x20(%r15)
je 0x78bf
movq 0xc754(%rip), %rdi      # 0x13ff0
leaq 0x5fb4(%rip), %rsi      # 0xd857
callq 0x31f0
movq %rax, %r14
movq (%r12), %rsi
movq %rax, %rdi
callq 0x62cf
movq %r14, %rdi
callq 0x30d0
movq %rbx, -0x50(%rbp)
movq %r12, -0x40(%rbp)
cmpq $0x0, 0x28(%r15)
je 0x78f8
movq 0xc71b(%rip), %rdi      # 0x13ff0
leaq 0x5f87(%rip), %rsi      # 0xd863
callq 0x31f0
movq %rax, %r14
movq 0x28(%r15), %rsi
movq %rax, %rdi
callq 0x62cf
movq %r14, %rdi
callq 0x30d0
movq 0xc6f1(%rip), %rbx      # 0x13ff0
leaq 0x5f6a(%rip), %rsi      # 0xd870
movq %rbx, %rdi
callq 0x31f0
movq %rax, %rdi
callq 0x30d0
movq %r15, %rdi
callq 0x3120
movq %rax, %r12
movq 0x28(%rax), %r14
leaq -0x38(%rbp), %rax
movq %r14, (%rax)
leaq -0x30(%rbp), %rax
movq %r13, (%rax)
leaq 0x5f3d(%rip), %rsi      # 0xd877
movq %rbx, %rdi
callq 0x31f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x3190
movq %rax, %rdi
callq 0x30d0
leaq 0x5f1f(%rip), %rsi      # 0xd87b
movq %rax, %rdi
callq 0x31f0
movq %rax, %rdi
movq %r13, %rsi
callq 0x3190
movq %rax, %rdi
callq 0x30d0
leaq 0x5f01(%rip), %rsi      # 0xd87f
movq %rbx, %rdi
callq 0x31f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x3190
leaq 0x56ef(%rip), %rsi      # 0xd087
movq %rax, %rdi
callq 0x31f0
movq %rax, %rdi
movq %r13, %rsi
callq 0x3190
leaq 0x5ed8(%rip), %rsi      # 0xd88a
movq %rax, %rdi
callq 0x31f0
movq %rax, %rdi
callq 0x30d0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0xa2aa
testb $0x1, %dl
je 0x7b35
addq $0x20, %r12
cmpq $0x0, (%r12)
movq -0x50(%rbp), %rbx
je 0x7a06
leaq 0x40(%rbx), %rdi
movq 0x8(%rbx), %rcx
cvtss2sd (%rcx), %xmm0
addq $0x20, %rax
movq %r12, %rsi
movq %rax, %rdx
callq 0x9032
movq 0xc5e3(%rip), %rdi      # 0x13ff0
leaq 0x5e6b(%rip), %rsi      # 0xd87f
callq 0x31f0
leaq -0x30(%rbp), %r14
movq (%r14), %rsi
movq %rax, %rdi
callq 0x3190
leaq 0x5658(%rip), %rsi      # 0xd087
movq %rax, %rdi
callq 0x31f0
leaq -0x38(%rbp), %r13
movq (%r13), %rsi
movq %rax, %rdi
callq 0x3190
leaq 0x5e3c(%rip), %rsi      # 0xd88a
movq %rax, %rdi
callq 0x31f0
movq %rax, %rdi
callq 0x30d0
movq -0x48(%rbp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0xa2aa
testb $0x1, %dl
je 0x7b54
cmpq $0x0, 0x28(%r15)
je 0x7a99
leaq 0x40(%rbx), %rdi
movq 0x8(%rbx), %rcx
cvtss2sd (%rcx), %xmm0
addq $0x20, %rax
movq %rax, %rsi
movq -0x40(%rbp), %rdx
callq 0x9032
cmpq $0x0, (%r12)
je 0x7b0b
cmpq $0x0, 0x28(%r15)
je 0x7b0b
addq $0x40, %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq -0x40(%rbp), %rdx
callq 0x8f32
jmp 0x7b0b
movq 0xc52d(%rip), %rdi      # 0x13ff0
leaq 0x5d41(%rip), %rsi      # 0xd80b
callq 0x31f0
movq %rax, %rdi
callq 0x30d0
leaq -0x60(%rbp), %rbx
andq $0x0, (%rbx)
leaq -0x58(%rbp), %r14
movq %r13, (%r14)
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0xa144
movq %r13, (%rbx)
andq $0x0, (%r14)
leaq -0x60(%rbp), %rsi
leaq -0x58(%rbp), %rdx
movq %r15, %rdi
callq 0xa1ec
movq 0xc4de(%rip), %rdi      # 0x13ff0
leaq 0x5db7(%rip), %rsi      # 0xd8d0
callq 0x31f0
movq %rax, %rdi
callq 0x30d0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5c13(%rip), %rdi      # 0xd74f
leaq 0x57c7(%rip), %rsi      # 0xd30a
leaq 0x5d4c(%rip), %rcx      # 0xd896
movl $0x352, %edx            # imm = 0x352
callq 0x3130
leaq 0x5bf4(%rip), %rdi      # 0xd74f
leaq 0x57a8(%rip), %rsi      # 0xd30a
leaq 0x5d2d(%rip), %rcx      # 0xd896
movl $0x35a, %edx            # imm = 0x35A
callq 0x3130
nop