// File: micahcc[P]polygon_skeleton/voronoi.cpp
// Function: Voronoi::Implementation::addEdge(std::shared_ptr<Voronoi::Node>, std::shared_ptr<Voronoi::Node>)
Voronoi::Edge::Ptr Voronoi::Implementation::addEdge(
        Node::Ptr nodeA,
        Node::Ptr nodeB)
{
    // the edges parents are the parents in common between the two input nodes
    std::set<size_t> common;
    std::set_intersection(
            nodeA->parents.begin(), nodeA->parents.end(),
            nodeB->parents.begin(), nodeB->parents.end(),
            std::inserter(common, common.begin()));

    auto out = std::make_shared<Edge>();
    out->parents = common;
    out->nodes[0] = nodeA;
    out->nodes[1] = nodeB;
    std::cerr << "adding edge!" << std::endl;
    std::cerr << "edge = [" << nodeA->x << ", " << nodeA->y << ";"
        << nodeB->x << ", " << nodeB->y << "]" << std::endl;
    m_edges.push_back(out);
    return out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rcx, -0xd0(%rbp)
movq %rdx, -0xd8(%rbp)
movq %rdi, -0xf0(%rbp)
movq %rdi, %rax
movq %rax, -0xe8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq -0x50(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x11ff0
movq -0xd8(%rbp), %rdi
callq 0x11430
movq %rax, %rdi
addq $0x8, %rdi
callq 0x120a0
movq -0xd8(%rbp), %rdi
movq %rax, -0x58(%rbp)
callq 0x11430
movq %rax, %rdi
addq $0x8, %rdi
callq 0x120d0
movq -0xd0(%rbp), %rdi
movq %rax, -0x60(%rbp)
callq 0x11430
movq %rax, %rdi
addq $0x8, %rdi
callq 0x120a0
movq -0xd0(%rbp), %rdi
movq %rax, -0x68(%rbp)
callq 0x11430
movq %rax, %rdi
addq $0x8, %rdi
callq 0x120d0
movq -0xc8(%rbp), %rdi
movq %rax, -0x70(%rbp)
callq 0x120a0
movq -0xc8(%rbp), %rdi
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rsi
callq 0x12100
movq %rdx, -0xc0(%rbp)
movq %rax, -0xb8(%rbp)
jmp 0xe47b
movq -0xc0(%rbp), %rax
movq -0xb8(%rbp), %rcx
movq %rcx, -0x80(%rbp)
movq %rax, -0x78(%rbp)
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq -0x70(%rbp), %rcx
movq -0x80(%rbp), %r8
movq -0x78(%rbp), %r9
callq 0x12010
movq %rdx, -0x100(%rbp)
movq %rax, -0xf8(%rbp)
jmp 0xe4be
movq -0xf0(%rbp), %rdi
movq -0x100(%rbp), %rax
movq -0xf8(%rbp), %rcx
movq %rcx, -0xa8(%rbp)
movq %rax, -0xa0(%rbp)
movb $0x0, -0xa9(%rbp)
callq 0x12140
jmp 0xe4ef
movq -0xf0(%rbp), %rdi
callq 0x49c0
movq %rax, %rdi
leaq -0x50(%rbp), %rsi
callq 0x121b0
jmp 0xe509
movq -0xf0(%rbp), %rdi
callq 0x49c0
movq -0xd8(%rbp), %rsi
movq %rax, %rdi
addq $0x30, %rdi
callq 0x11e80
movq -0xf0(%rbp), %rdi
callq 0x49c0
movq -0xd0(%rbp), %rsi
movq %rax, %rdi
addq $0x40, %rdi
callq 0x11e80
movq 0x24aa2(%rip), %rdi     # 0x32ff0
leaq 0x15539(%rip), %rsi     # 0x23a8e
callq 0x3250
movq %rax, -0x108(%rbp)
jmp 0xe563
movq -0x108(%rbp), %rdi
movq 0x24a4f(%rip), %rsi     # 0x32fc0
callq 0x3290
jmp 0xe578
movq 0x24a71(%rip), %rdi     # 0x32ff0
leaq 0x15515(%rip), %rsi     # 0x23a9b
callq 0x3250
movq %rax, -0x110(%rbp)
jmp 0xe594
movq -0xd8(%rbp), %rdi
callq 0x11430
movq -0x110(%rbp), %rdi
movss (%rax), %xmm0
callq 0x31b0
movq %rax, -0x118(%rbp)
jmp 0xe5b9
movq -0x118(%rbp), %rdi
leaq 0x14ab0(%rip), %rsi     # 0x23077
callq 0x3250
movq %rax, -0x120(%rbp)
jmp 0xe5d5
movq -0xd8(%rbp), %rdi
callq 0x11430
movq -0x120(%rbp), %rdi
movss 0x4(%rax), %xmm0
callq 0x31b0
movq %rax, -0x128(%rbp)
jmp 0xe5fb
movq -0x128(%rbp), %rdi
leaq 0x15195(%rip), %rsi     # 0x2379e
callq 0x3250
movq %rax, -0x130(%rbp)
jmp 0xe617
movq -0xd0(%rbp), %rdi
callq 0x11430
movq -0x130(%rbp), %rdi
movss (%rax), %xmm0
callq 0x31b0
movq %rax, -0x138(%rbp)
jmp 0xe63c
movq -0x138(%rbp), %rdi
leaq 0x14a2d(%rip), %rsi     # 0x23077
callq 0x3250
movq %rax, -0x140(%rbp)
jmp 0xe658
movq -0xd0(%rbp), %rdi
callq 0x11430
movq -0x140(%rbp), %rdi
movss 0x4(%rax), %xmm0
callq 0x31b0
movq %rax, -0x148(%rbp)
jmp 0xe67e
movq -0x148(%rbp), %rdi
leaq 0x15101(%rip), %rsi     # 0x2378d
callq 0x3250
movq %rax, -0x150(%rbp)
jmp 0xe69a
movq -0x150(%rbp), %rdi
movq 0x24918(%rip), %rsi     # 0x32fc0
callq 0x3290
jmp 0xe6af
movq -0xf0(%rbp), %rsi
movq -0xe0(%rbp), %rdi
addq $0xc8, %rdi
callq 0x121e0
jmp 0xe6cb
movb $0x1, -0xa9(%rbp)
testb $0x1, -0xa9(%rbp)
jne 0xe71d
jmp 0xe711
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0xe736
movq -0xf0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
callq 0x6ef0
jmp 0xe736
movq -0xf0(%rbp), %rdi
callq 0x6ef0
leaq -0x50(%rbp), %rdi
callq 0x12250
movq -0xe8(%rbp), %rax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x12250
movq -0x90(%rbp), %rdi
callq 0x3400
nopl (%rax,%rax)