// File: /workspace/github_cpp_makefile_star2_O2/gchen98[P]macs/datastructures.cpp
// Function: GraphBuilder::getNewickTree[abi:cxx11](double, boost::intrusive_ptr<Node>&)
string GraphBuilder::getNewickTree(double lastCoalHeight,NodePtr & curNode){
    ostringstream oss;
    if (curNode->getType()==Node::SAMPLE){
        // print the Newick format with the Sample ID followed by length
        SampleNode * pSampleNode = static_cast<SampleNode *>(curNode.get());
        oss<<pSampleNode->iId<<":"<<lastCoalHeight-curNode->getHeight();
    }else if (curNode->getType()==Node::COAL){
        // if the two lower branches are in the current tree, then print the
        // Newick format, and recursively repeat
        if (iGraphIteration==curNode->getBottomEdgeByIndex(0)->iGraphIteration &&
        iGraphIteration==curNode->getBottomEdgeByIndex(1)->iGraphIteration){
            oss<<"("<<getNewickTree(curNode->getHeight(),
            curNode->getBottomEdgeByIndex(0)->getBottomNodeRef())
            <<","<<getNewickTree(curNode->getHeight(),
            curNode->getBottomEdgeByIndex(1)->getBottomNodeRef())
            <<")";
            // if we are at the MRCA we don't need to output the branch length since
            // it is obviously 0 length
            if (curNode!=localMRCA) oss<<":"<<lastCoalHeight-curNode->getHeight();
//            cout<<"got here\n";
        }else{
            for(int i=0;i<2;++i){
                if (curNode->getBottomEdgeByIndex(i)->iGraphIteration==iGraphIteration){
                    oss<<getNewickTree(lastCoalHeight,
                    curNode->getBottomEdgeByIndex(i)->getBottomNodeRef());
                }
            }
        }
    }else {
        // this is for everything else(e.g. migration, xover nodes),
        // don't print anything, but recursively
        // descend down the graph
        oss<<getNewickTree(lastCoalHeight,
        curNode->getBottomEdgeByIndex(0)->getBottomNodeRef());
    }
    return oss.str();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdx, %r14
movsd %xmm0, 0x8(%rsp)
movq %rsi, %r15
movq %rdi, 0x38(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x3300
movq %r14, %rdi
callq 0xda4e
cmpl $0x3, 0x64(%rax)
jne 0x11833
movq (%r14), %rax
movl 0x78(%rax), %esi
leaq 0x80(%rsp), %rdi
callq 0x33f0
leaq 0x4bbc(%rip), %rsi      # 0x163c7
movq %rax, %rdi
callq 0x3250
movq %rax, %rbx
movq %r14, %rdi
callq 0xda4e
movsd 0x8(%rsp), %xmm0
subsd 0x70(%rax), %xmm0
movq %rbx, %rdi
callq 0x3370
jmp 0x118a3
movq %r14, %rdi
callq 0xda4e
cmpl $0x0, 0x64(%rax)
je 0x118d9
movq %r14, %rdi
callq 0xda4e
leaq 0x40(%rax), %rsi
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0xe1ca
movq %rbx, %rdi
callq 0xda24
leaq 0x20(%rax), %rdx
leaq 0x18(%rsp), %rdi
movq %r15, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x117b4
leaq 0x80(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x3210
leaq 0x18(%rsp), %rdi
callq 0x3468
leaq 0x48(%rsp), %rdi
callq 0xdff8
leaq 0x88(%rsp), %rsi
movq 0x38(%rsp), %rdi
callq 0x3360
leaq 0x80(%rsp), %rdi
callq 0x3090
movq 0x38(%rsp), %rax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0xd0(%r15), %ebp
movq %r14, %rdi
callq 0xda4e
leaq 0x40(%rax), %rsi
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0xe1ca
movq %rbx, %rdi
callq 0xda24
cmpl 0x14(%rax), %ebp
jne 0x11aa5
movl 0xd0(%r15), %ebp
movq %r14, %rdi
callq 0xda4e
leaq 0x50(%rax), %rsi
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0xe1ca
movq %rbx, %rdi
callq 0xda24
movl 0x14(%rax), %ebx
leaq 0x48(%rsp), %rdi
callq 0xdff8
leaq 0x20(%rsp), %rdi
callq 0xdff8
cmpl %ebx, %ebp
jne 0x11aaf
leaq 0x4fd4(%rip), %rsi      # 0x1692c
leaq 0x80(%rsp), %rdi
callq 0x3250
movq %rax, %rbx
movq %r14, %rdi
callq 0xda4e
movsd 0x70(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
callq 0xda4e
leaq 0x40(%rax), %rsi
leaq 0x70(%rsp), %r12
movq %r12, %rdi
callq 0xe1ca
movq %r12, %rdi
callq 0xda24
leaq 0x20(%rax), %rdx
leaq 0x18(%rsp), %rdi
movq %r15, %rsi
movsd 0x10(%rsp), %xmm0
callq 0x117b4
leaq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x3210
leaq 0x44b9(%rip), %rsi      # 0x15e80
movq %rax, %rdi
callq 0x3250
movq %rax, %rbx
movq %r14, %rdi
callq 0xda4e
movsd 0x70(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %r14, %rdi
callq 0xda4e
leaq 0x50(%rax), %rsi
leaq 0x60(%rsp), %r12
movq %r12, %rdi
callq 0xe1ca
movq %r12, %rdi
callq 0xda24
leaq 0x20(%rax), %rdx
leaq 0x40(%rsp), %rdi
movq %r15, %rsi
movsd 0x10(%rsp), %xmm0
callq 0x117b4
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x3210
leaq 0x2e38(%rip), %rsi      # 0x14869
movq %rax, %rdi
callq 0x3250
leaq 0x40(%rsp), %rdi
callq 0x3468
leaq 0x68(%rsp), %rdi
callq 0xdff8
leaq 0x18(%rsp), %rdi
callq 0x3468
leaq 0x78(%rsp), %rdi
callq 0xdff8
movq (%r14), %rax
cmpq 0x40(%r15), %rax
je 0x118a3
leaq 0x4952(%rip), %rsi      # 0x163c7
leaq 0x80(%rsp), %rdi
callq 0x3250
movq %rax, %rbx
movq %r14, %rdi
callq 0xda4e
movsd 0x8(%rsp), %xmm0
subsd 0x70(%rax), %xmm0
movq %rbx, %rdi
callq 0x3370
jmp 0x118a3
leaq 0x20(%rsp), %rdi
callq 0xdff8
xorl %r12d, %r12d
leaq 0x18(%rsp), %rbp
cmpl $0x2, %r12d
je 0x118a3
movq %r14, %rdi
callq 0xda4e
movzwl %r12w, %edx
movq %rbp, %rdi
movq %rax, %rsi
callq 0xdaf6
movq %rbp, %rdi
callq 0xda24
movl 0x14(%rax), %r13d
movl 0xd0(%r15), %ebx
leaq 0x20(%rsp), %rdi
callq 0xdff8
cmpl %ebx, %r13d
jne 0x11b55
movq %r14, %rdi
callq 0xda4e
movzwl %r12w, %edx
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0xdaf6
movq %rbx, %rdi
callq 0xda24
leaq 0x20(%rax), %rdx
movq %rbp, %rdi
movq %r15, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x117b4
leaq 0x80(%rsp), %rdi
movq %rbp, %rsi
callq 0x3210
movq %rbp, %rdi
callq 0x3468
leaq 0x48(%rsp), %rdi
callq 0xdff8
incl %r12d
jmp 0x11ab7
movq %rax, %rbx
jmp 0x11b74
movq %rax, %rbx
jmp 0x11b8d
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x3468
leaq 0x68(%rsp), %rdi
callq 0xdff8
jmp 0x11b83
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3468
leaq 0x78(%rsp), %rdi
jmp 0x11bb6
jmp 0x11ba4
jmp 0x11b9f
jmp 0x11b9a
movq %rax, %rbx
jmp 0x11bbb
movq %rax, %rbx
jmp 0x11bb1
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3468
leaq 0x48(%rsp), %rdi
callq 0xdff8
leaq 0x80(%rsp), %rdi
callq 0x3090
movq %rbx, %rdi
callq 0x3400