// File: /workspace/github_cpp_makefile_star2_O2/gchen98[P]macs/datastructures.cpp
// Function: GraphBuilder::insertNodeInRunningEdge(boost::intrusive_ptr<Node>&, boost::shared_ptr<Edge>&)
void GraphBuilder::insertNodeInRunningEdge(NodePtr & newNode,EdgePtr & tempEdge){

    NodePtr & bottomNode = tempEdge->getBottomNodeRef();
    NodePtr & topNode = tempEdge->getTopNodeRef();
    #ifdef DIAG
    if (newNode->getHeight()<=bottomNode->getHeight() ||
    newNode->getHeight() >= topNode->getHeight()){
           cerr<<"Edge has heights "<<bottomNode->getHeight()<<
        " and "<<topNode->getHeight()<<endl;
        cerr<<"New node has height "<<newNode->getHeight()<<endl;
        throw "Node to insert does not fit within coal edge ";
    }
    #endif

    EdgePtr tempEdgeCopy = tempEdge;

    tempEdge = EdgePtr(new Edge(topNode,newNode));
    tempEdge->iGraphIteration = iGraphIteration;
    newNode->addNewEdge(Node::TOP_EDGE,tempEdge);
    tempEdge->getTopNodeRef()->replaceOldWithNewEdge(
    Node::BOTTOM_EDGE,tempEdgeCopy,tempEdge);

    EdgePtr newBottomEdge = EdgePtr(new Edge(newNode,bottomNode));
    newBottomEdge->iGraphIteration = iGraphIteration;
    newNode->addNewEdge(Node::BOTTOM_EDGE,newBottomEdge);
    addEdge(newBottomEdge);
    bottomNode->replaceOldWithNewEdge(Node::TOP_EDGE,tempEdgeCopy,
    newBottomEdge);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, %r15
movq %rdx, %rdi
callq 0xda24
movq %rax, %r14
movq %r13, %rdi
callq 0xda24
movq %rax, %rbp
movq (%r13), %rax
movq %rax, 0x18(%rsp)
movq 0x8(%r13), %rax
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x10bd2
lock
incl 0x8(%rax)
pushq $0x30
popq %rdi
callq 0x3260
movq %rax, %rbx
addq $0x18, %rbp
movq %rax, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0xf72e
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0xdb9a
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0xdbce
leaq 0x10(%rsp), %rdi
callq 0xdff8
movl 0xd0(%r15), %ebx
movq %r13, %rdi
callq 0xda24
movl %ebx, 0x14(%rax)
movq %r12, %rdi
callq 0xda4e
movq %rax, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0xf880
movq %r13, %rdi
callq 0xda24
leaq 0x18(%rax), %rdi
callq 0xda4e
pushq $0x1
popq %rsi
leaq 0x18(%rsp), %rdx
movq %rax, %rdi
movq %r13, %rcx
callq 0xf8d4
pushq $0x30
popq %rdi
callq 0x3260
movq %rax, %rbx
addq $0x20, %r14
movq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0xf72e
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0xdb9a
movl 0xd0(%r15), %ebp
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xda24
movl %ebp, 0x14(%rax)
movq %r12, %rdi
callq 0xda4e
pushq $0x1
popq %rsi
movq %rax, %rdi
movq %rbx, %rdx
callq 0xf880
movq %r15, %rdi
movq %rbx, %rsi
callq 0x10d3a
movq %r14, %rdi
callq 0xda4e
leaq 0x18(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %rax, %rdi
xorl %esi, %esi
callq 0xf8d4
leaq 0x10(%rsp), %rdi
callq 0xdff8
leaq 0x20(%rsp), %rdi
callq 0xdff8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x10d03
jmp 0x10d24
movq %rax, %r14
pushq $0x30
popq %rsi
movq %rbx, %rdi
callq 0x3270
jmp 0x10d27
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0xdff8
jmp 0x10d27
jmp 0x10d24
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0xdff8
movq %r14, %rdi
callq 0x3400
nop