// File: micahcc[P]polygon_skeleton/voronoi.cpp
// Function: Voronoi::Implementation::getNode(Vector const*, Vector const*, Vector const*)
Voronoi::Node::Ptr Voronoi::Implementation::getNode(
        const Point* ptA, const Point* ptB, const Point* ptC)
{
    orderPoints(ptA, ptB, ptC);
    auto result = m_nodes.emplace(std::make_tuple(ptA, ptB, ptC), nullptr);

    // if node exists, just return it
    if(!result.second) {
        assert(result.first->second != nullptr);
        return result.first->second;
    }

    // create and fill out the new node
    auto circle = solveCircle(*ptA, *ptB, *ptC);

    // need to construct a new node and add its parents and location
    auto new_node = std::make_shared<Node>();
    result.first->second = new_node;

    // Add parents
    new_node->parents.insert((ptA - m_points->data()) / sizeof(Point));
    new_node->parents.insert((ptB - m_points->data()) / sizeof(Point));
    new_node->parents.insert((ptC - m_points->data()) / sizeof(Point));

    // Add position
    new_node->x = circle.center.x;
    new_node->y = circle.center.y;

    return new_node;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x128(%rbp)
movq %rdi, %rax
movq %rax, -0x120(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq -0x18(%rbp), %rdi
movq %rdi, -0x110(%rbp)
leaq -0x20(%rbp), %rsi
movq %rsi, -0x108(%rbp)
leaq -0x28(%rbp), %rdx
movq %rdx, -0x100(%rbp)
callq 0x11d10
movq -0x118(%rbp), %rax
movq -0x110(%rbp), %rsi
movq -0x108(%rbp), %rdx
movq -0x100(%rbp), %rcx
addq $0x90, %rax
movq %rax, -0xf8(%rbp)
leaq -0x50(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x10e90
movq -0xf8(%rbp), %rdi
movq -0xf0(%rbp), %rsi
movq $0x0, -0x58(%rbp)
leaq -0x58(%rbp), %rdx
callq 0x11d90
movb %dl, -0x60(%rbp)
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x38(%rbp)
movb -0x60(%rbp), %al
movb %al, -0x30(%rbp)
testb $0x1, -0x30(%rbp)
jne 0xc0a5
leaq -0x38(%rbp), %rdi
callq 0x11de0
movq %rax, %rdi
addq $0x18, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x11400
testb $0x1, %al
jne 0xc063
jmp 0xc065
jmp 0xc084
leaq 0x1794f(%rip), %rdi     # 0x239bb
leaq 0x1725b(%rip), %rsi     # 0x232ce
movl $0x3d6, %edx            # imm = 0x3D6
leaq 0x1795c(%rip), %rcx     # 0x239db
callq 0x3170
leaq -0x38(%rbp), %rdi
callq 0x11de0
movq -0x128(%rbp), %rdi
movq %rax, %rsi
addq $0x18, %rsi
callq 0x114f0
jmp 0xc33e
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xa370
movq -0x128(%rbp), %rdi
movss %xmm1, -0x80(%rbp)
movlpd %xmm0, -0x88(%rbp)
movl -0x80(%rbp), %eax
movl %eax, -0x70(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x78(%rbp)
movb $0x0, -0x89(%rbp)
callq 0x11e10
leaq -0x38(%rbp), %rdi
callq 0x11de0
movq -0x128(%rbp), %rsi
movq %rax, %rdi
addq $0x18, %rdi
callq 0x11e80
movq -0x128(%rbp), %rdi
callq 0x11430
movq %rax, %rcx
movq -0x118(%rbp), %rax
addq $0x8, %rcx
movq %rcx, -0x148(%rbp)
movq -0x18(%rbp), %rcx
movq %rcx, -0x140(%rbp)
movq 0xe0(%rax), %rdi
callq 0x11f00
movq -0x148(%rbp), %rdi
movq %rax, %rcx
movq -0x140(%rbp), %rax
subq %rcx, %rax
sarq $0x3, %rax
shrq $0x3, %rax
movq %rax, -0x98(%rbp)
leaq -0x98(%rbp), %rsi
callq 0x11eb0
movb %dl, -0x131(%rbp)
movq %rax, -0x130(%rbp)
jmp 0xc179
movq -0x128(%rbp), %rdi
movb -0x131(%rbp), %al
movq -0x130(%rbp), %rcx
movq %rcx, -0xb8(%rbp)
movb %al, -0xb0(%rbp)
callq 0x11430
movq %rax, %rcx
movq -0x118(%rbp), %rax
addq $0x8, %rcx
movq %rcx, -0x168(%rbp)
movq -0x20(%rbp), %rcx
movq %rcx, -0x160(%rbp)
movq 0xe0(%rax), %rdi
callq 0x11f00
movq -0x168(%rbp), %rdi
movq %rax, %rcx
movq -0x160(%rbp), %rax
subq %rcx, %rax
sarq $0x3, %rax
shrq $0x3, %rax
movq %rax, -0xc0(%rbp)
leaq -0xc0(%rbp), %rsi
callq 0x11eb0
movb %dl, -0x151(%rbp)
movq %rax, -0x150(%rbp)
jmp 0xc209
movq -0x128(%rbp), %rdi
movb -0x151(%rbp), %al
movq -0x150(%rbp), %rcx
movq %rcx, -0xd0(%rbp)
movb %al, -0xc8(%rbp)
callq 0x11430
movq %rax, %rcx
movq -0x118(%rbp), %rax
addq $0x8, %rcx
movq %rcx, -0x188(%rbp)
movq -0x28(%rbp), %rcx
movq %rcx, -0x180(%rbp)
movq 0xe0(%rax), %rdi
callq 0x11f00
movq -0x188(%rbp), %rdi
movq %rax, %rcx
movq -0x180(%rbp), %rax
subq %rcx, %rax
sarq $0x3, %rax
shrq $0x3, %rax
movq %rax, -0xd8(%rbp)
leaq -0xd8(%rbp), %rsi
callq 0x11eb0
movb %dl, -0x171(%rbp)
movq %rax, -0x170(%rbp)
jmp 0xc299
movq -0x128(%rbp), %rdi
movb -0x171(%rbp), %al
movq -0x170(%rbp), %rcx
movq %rcx, -0xe8(%rbp)
movb %al, -0xe0(%rbp)
movss -0x78(%rbp), %xmm0
movss %xmm0, -0x190(%rbp)
callq 0x11430
movss -0x190(%rbp), %xmm0
movq -0x128(%rbp), %rdi
movss %xmm0, (%rax)
movss -0x74(%rbp), %xmm0
movss %xmm0, -0x18c(%rbp)
callq 0x11430
movss -0x18c(%rbp), %xmm0
movss %xmm0, 0x4(%rax)
movb $0x1, -0x89(%rbp)
testb $0x1, -0x89(%rbp)
jne 0xc33c
jmp 0xc330
movq -0x128(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
callq 0x8a20
jmp 0xc34e
movq -0x128(%rbp), %rdi
callq 0x8a20
jmp 0xc33e
movq -0x120(%rbp), %rax
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
movq -0xa0(%rbp), %rdi
callq 0x3400
nopw (%rax,%rax)