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

    NodePtr bottomNodeCopy = selectedEdge->getBottomNodeRef();
    #ifdef DIAG
    NodePtr & topNode = selectedEdge->getTopNodeRef();
    if (newNode->getHeight()<bottomNodeCopy->getHeight() ||
    newNode->getHeight() > topNode->getHeight()){
        cerr<<"Edge has heights "<<bottomNodeCopy->getHeight()<<
        " and "<<topNode->getHeight()<<endl;
        cerr<<"New node has height "<<newNode->getHeight()<<endl;
        throw "Node to insert does not fit within edge";
    }
    #endif
    int iGraphIteration = selectedEdge->iGraphIteration;
    selectedEdge->setBottomNode(newNode);
    newNode->addNewEdge(Node::TOP_EDGE,selectedEdge);
    EdgePtr newBottomEdge = EdgePtr(new Edge(newNode,bottomNodeCopy));
    newBottomEdge->iGraphIteration = iGraphIteration;
    addEdge(newBottomEdge);
    bottomNodeCopy->replaceOldWithNewEdge(Node::TOP_EDGE,selectedEdge,
    newBottomEdge);
    newNode->addNewEdge(Node::BOTTOM_EDGE,newBottomEdge);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdi, %r15
movq (%rdx), %rdi
testq %rdi, %rdi
je 0x1401b
movq %rdx, %r14
movq %rsi, %rbx
movq 0x20(%rdi), %r12
movq %r12, 0x8(%rsp)
testq %r12, %r12
je 0x13ef4
incq 0x8(%r12)
movl 0x14(%rdi), %ebp
movq %rbx, %rsi
callq 0x11fc6
movq (%rbx), %r12
testq %r12, %r12
je 0x13ffc
xorl %eax, %eax
cmpw $0x0, 0x68(%r12)
setne %al
movq (%r14), %rcx
leaq 0x8(%r14), %rsi
shll $0x4, %eax
leaq (%r12,%rax), %rdi
addq $0x28, %rdi
movq %rcx, -0x8(%rdi)
callq 0x153ac
incw 0x68(%r12)
movl $0x30, %edi
callq 0x3260
movq %rax, %r12
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x11eb4
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x1079c
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x1401b
movl %ebp, 0x14(%rax)
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x13a78
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x13ffc
leaq 0x10(%rsp), %rcx
xorl %esi, %esi
movq %r14, %rdx
callq 0x12098
movq (%rbx), %r14
testq %r14, %r14
je 0x13ffc
xorl %eax, %eax
cmpw $0x0, 0x6a(%r14)
setne %al
leaq 0x18(%rsp), %rbx
movq -0x8(%rbx), %rcx
shll $0x4, %eax
leaq (%r14,%rax), %rdi
addq $0x48, %rdi
movq %rcx, -0x8(%rdi)
movq %rbx, %rsi
callq 0x153ac
incw 0x6a(%r14)
movq %rbx, %rdi
callq 0x10d5e
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x13fef
decq 0x8(%rdi)
jne 0x13fef
movq (%rdi), %rax
callq *0x8(%rax)
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4af5(%rip), %rdi      # 0x18af8
leaq 0x4af6(%rip), %rsi      # 0x18b00
leaq 0x54ea(%rip), %rcx      # 0x194fb
movl $0xc7, %edx
callq 0x3170
leaq 0x4ad6(%rip), %rdi      # 0x18af8
leaq 0x543d(%rip), %rsi      # 0x19466
leaq 0x5462(%rip), %rcx      # 0x19492
movl $0x2d8, %edx            # imm = 0x2D8
callq 0x3170
movq %rax, %rbx
movl $0x30, %esi
movq %r12, %rdi
callq 0x3270
jmp 0x14063
movq %rax, %rbx
jmp 0x14068
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x10d5e
jmp 0x14063
movq %rax, %rbx
movq 0x8(%rsp), %r12
testq %r12, %r12
je 0x1407e
decq 0x8(%r12)
jne 0x1407e
movq (%r12), %rax
movq %r12, %rdi
callq *0x8(%rax)
movq %rbx, %rdi
callq 0x33f0