// File: 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
movq %rsp, %rbp
subq $0x390, %rsp            # imm = 0x390
movq %rdi, -0x2d0(%rbp)
movq %rdi, %rax
movq %rax, -0x2c8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x43f0
movq -0x20(%rbp), %rdi
callq 0x1ded0
movq %rax, %rdi
callq 0x1e200
movl %eax, -0x2b4(%rbp)
jmp 0x2b05d
movl -0x2b4(%rbp), %eax
cmpl $0x3, %eax
jne 0x2b11d
movq -0x20(%rbp), %rdi
callq 0x1e220
movq %rax, -0x1b0(%rbp)
movq -0x1b0(%rbp), %rax
movl 0x78(%rax), %esi
leaq -0x198(%rbp), %rdi
callq 0x44d0
movq %rax, -0x2d8(%rbp)
jmp 0x2b09b
movq -0x2d8(%rbp), %rdi
leaq 0x93cc(%rip), %rsi      # 0x34475
callq 0x42b0
movq %rax, -0x2e0(%rbp)
jmp 0x2b0b7
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x2f0(%rbp)
movq -0x20(%rbp), %rdi
callq 0x1ded0
movq %rax, %rdi
callq 0x1df20
movsd %xmm0, -0x2e8(%rbp)
jmp 0x2b0df
movq -0x2e0(%rbp), %rdi
movsd -0x2e8(%rbp), %xmm1
movsd -0x2f0(%rbp), %xmm0
subsd %xmm1, %xmm0
callq 0x4550
jmp 0x2b101
jmp 0x2b76c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0x2b79d
movq -0x20(%rbp), %rdi
callq 0x1ded0
movq %rax, %rdi
callq 0x1e200
movl %eax, -0x2f4(%rbp)
jmp 0x2b136
movl -0x2f4(%rbp), %eax
cmpl $0x0, %eax
jne 0x2b691
movq -0x2c0(%rbp), %rax
movl 0xd0(%rax), %eax
movl %eax, -0x2f8(%rbp)
movq -0x20(%rbp), %rdi
callq 0x1ded0
movq %rax, %rsi
movb $0x0, -0x1d1(%rbp)
leaq -0x1c0(%rbp), %rdi
xorl %edx, %edx
callq 0x1e260
jmp 0x2b17b
leaq -0x1c0(%rbp), %rdi
callq 0x1de60
movl -0x2f8(%rbp), %ecx
movq %rax, %rdx
xorl %eax, %eax
cmpl 0x14(%rdx), %ecx
movb %al, -0x2f9(%rbp)
jne 0x2b1f7
movq -0x2c0(%rbp), %rax
movl 0xd0(%rax), %eax
movl %eax, -0x300(%rbp)
movq -0x20(%rbp), %rdi
callq 0x1ded0
movq %rax, %rsi
leaq -0x1d0(%rbp), %rdi
movl $0x1, %edx
callq 0x1e260
jmp 0x2b1cf
movb $0x1, -0x1d1(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x1de60
movq %rax, %rcx
movl -0x300(%rbp), %eax
cmpl 0x14(%rcx), %eax
sete %al
movb %al, -0x2f9(%rbp)
movb -0x2f9(%rbp), %al
movb %al, -0x301(%rbp)
testb $0x1, -0x1d1(%rbp)
jne 0x2b20e
jmp 0x2b21a
leaq -0x1d0(%rbp), %rdi
callq 0x1e090
leaq -0x1c0(%rbp), %rdi
callq 0x1e090
movb -0x301(%rbp), %al
testb $0x1, %al
jne 0x2b235
jmp 0x2b510
leaq 0x9853(%rip), %rsi      # 0x34a8f
leaq -0x198(%rbp), %rdi
callq 0x42b0
movq %rax, -0x310(%rbp)
jmp 0x2b251
movq -0x20(%rbp), %rdi
callq 0x1ded0
movq %rax, %rdi
callq 0x1df20
movsd %xmm0, -0x318(%rbp)
jmp 0x2b26c
movq -0x20(%rbp), %rdi
callq 0x1ded0
movq %rax, %rsi
leaq -0x208(%rbp), %rdi
xorl %edx, %edx
callq 0x1e260
jmp 0x2b288
leaq -0x208(%rbp), %rdi
callq 0x1de60
movq %rax, %rdi
callq 0x1deb0
movq %rax, -0x320(%rbp)
jmp 0x2b2a5
movq -0x320(%rbp), %rdx
movsd -0x318(%rbp), %xmm0
movq -0x2c0(%rbp), %rsi
leaq -0x1f8(%rbp), %rdi
callq 0x2b000
jmp 0x2b2c9
movq -0x310(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x4280
movq %rax, -0x328(%rbp)
jmp 0x2b2e5
movq -0x328(%rbp), %rdi
leaq 0x8c15(%rip), %rsi      # 0x33f08
callq 0x42b0
movq %rax, -0x330(%rbp)
jmp 0x2b301
movq -0x20(%rbp), %rdi
callq 0x1ded0
movq %rax, %rdi
callq 0x1df20
movsd %xmm0, -0x338(%rbp)
jmp 0x2b31c
movq -0x20(%rbp), %rdi
callq 0x1ded0
movq %rax, %rsi
leaq -0x238(%rbp), %rdi
movl $0x1, %edx
callq 0x1e260
jmp 0x2b33b
leaq -0x238(%rbp), %rdi
callq 0x1de60
movq %rax, %rdi
callq 0x1deb0
movq %rax, -0x340(%rbp)
jmp 0x2b358
movq -0x340(%rbp), %rdx
movsd -0x338(%rbp), %xmm0
movq -0x2c0(%rbp), %rsi
leaq -0x228(%rbp), %rdi
callq 0x2b000
jmp 0x2b37c
movq -0x330(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0x4280
movq %rax, -0x348(%rbp)
jmp 0x2b398
movq -0x348(%rbp), %rdi
leaq 0x7593(%rip), %rsi      # 0x32939
callq 0x42b0
jmp 0x2b3ad
leaq -0x228(%rbp), %rdi
callq 0x4598
leaq -0x238(%rbp), %rdi
callq 0x1e090
leaq -0x1f8(%rbp), %rdi
callq 0x4598
leaq -0x208(%rbp), %rdi
callq 0x1e090
movq -0x2c0(%rbp), %rsi
movq -0x20(%rbp), %rdi
addq $0x40, %rsi
callq 0x1e350
testb $0x1, %al
jne 0x2b3fa
jmp 0x2b50b
leaq 0x9074(%rip), %rsi      # 0x34475
leaq -0x198(%rbp), %rdi
callq 0x42b0
movq %rax, -0x350(%rbp)
jmp 0x2b416
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x360(%rbp)
movq -0x20(%rbp), %rdi
callq 0x1ded0
movq %rax, %rdi
callq 0x1df20
movsd %xmm0, -0x358(%rbp)
jmp 0x2b43e
movq -0x350(%rbp), %rdi
movsd -0x358(%rbp), %xmm1
movsd -0x360(%rbp), %xmm0
subsd %xmm1, %xmm0
callq 0x4550
jmp 0x2b460
jmp 0x2b50b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x1e090
jmp 0x2b79d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0x2b4fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0x2b4ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0x2b4e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x4598
leaq -0x238(%rbp), %rdi
callq 0x1e090
leaq -0x1f8(%rbp), %rdi
callq 0x4598
leaq -0x208(%rbp), %rdi
callq 0x1e090
jmp 0x2b79d
jmp 0x2b68c
movl $0x0, -0x23c(%rbp)
cmpl $0x2, -0x23c(%rbp)
jge 0x2b68a
movq -0x20(%rbp), %rdi
callq 0x1ded0
movq %rax, %rsi
movzwl -0x23c(%rbp), %edx
leaq -0x250(%rbp), %rdi
callq 0x1e260
jmp 0x2b548
leaq -0x250(%rbp), %rdi
callq 0x1de60
movq %rax, %rcx
movq -0x2c0(%rbp), %rax
movl 0x14(%rcx), %ecx
movl %ecx, -0x364(%rbp)
movl 0xd0(%rax), %eax
movl %eax, -0x368(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x1e090
movl -0x368(%rbp), %ecx
movl -0x364(%rbp), %eax
cmpl %ecx, %eax
jne 0x2b674
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x370(%rbp)
movq -0x20(%rbp), %rdi
callq 0x1ded0
movq %rax, %rsi
movzwl -0x23c(%rbp), %edx
leaq -0x280(%rbp), %rdi
callq 0x1e260
jmp 0x2b5c1
leaq -0x280(%rbp), %rdi
callq 0x1de60
movq %rax, %rdi
callq 0x1deb0
movq %rax, -0x378(%rbp)
jmp 0x2b5de
movq -0x378(%rbp), %rdx
movsd -0x370(%rbp), %xmm0
movq -0x2c0(%rbp), %rsi
leaq -0x270(%rbp), %rdi
callq 0x2b000
jmp 0x2b602
leaq -0x198(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x4280
jmp 0x2b617
leaq -0x270(%rbp), %rdi
callq 0x4598
leaq -0x280(%rbp), %rdi
callq 0x1e090
jmp 0x2b674
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0x2b663
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x4598
leaq -0x280(%rbp), %rdi
callq 0x1e090
jmp 0x2b79d
jmp 0x2b676
movl -0x23c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x23c(%rbp)
jmp 0x2b51a
jmp 0x2b68c
jmp 0x2b76a
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x380(%rbp)
movq -0x20(%rbp), %rdi
callq 0x1ded0
movq %rax, %rsi
leaq -0x2b0(%rbp), %rdi
xorl %edx, %edx
callq 0x1e260
jmp 0x2b6ba
leaq -0x2b0(%rbp), %rdi
callq 0x1de60
movq %rax, %rdi
callq 0x1deb0
movq %rax, -0x388(%rbp)
jmp 0x2b6d7
movq -0x388(%rbp), %rdx
movsd -0x380(%rbp), %xmm0
movq -0x2c0(%rbp), %rsi
leaq -0x2a0(%rbp), %rdi
callq 0x2b000
jmp 0x2b6fb
leaq -0x198(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x4280
jmp 0x2b710
leaq -0x2a0(%rbp), %rdi
callq 0x4598
leaq -0x2b0(%rbp), %rdi
callq 0x1e090
jmp 0x2b76a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0x2b75c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x4598
leaq -0x2b0(%rbp), %rdi
callq 0x1e090
jmp 0x2b79d
jmp 0x2b76c
movq -0x2d0(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x42e0
jmp 0x2b781
leaq -0x198(%rbp), %rdi
callq 0x40a0
movq -0x2c8(%rbp), %rax
addq $0x390, %rsp            # imm = 0x390
popq %rbp
retq
leaq -0x198(%rbp), %rdi
callq 0x40a0
movq -0x1a0(%rbp), %rdi
callq 0x44e0
nopw %cs:(%rax,%rax)
nop