// File: millanek[P]Dsuite/Dsuite_fBranch.cpp
// Function: Tree::updateProgenyIds()
void Tree::updateProgenyIds() {
    // Determine the progeny of each branch (needed to know whether conditions are met, and for fossil constraints).
    // First of all, set progeniesComplete to 2 for all extinct and present branches.
    for (std::vector<Branch*>::iterator b = branches.begin(); b != branches.end(); b++) {
        if ((*b)->daughterId1 == "none") {
            (*b)->progeniesComplete = 2;
            (*b)->progenyIds.push_back((*b)->terminalSpeciesId);
        }
        // Set progenyPassedOn to true for the two root branches.
        if ((*b)->parentId == "treeOrigin") (*b)->progenyPassedOn = true;
    }
    bool allProgeniesComplete = false;
    while(!allProgeniesComplete) {
        std::vector<Branch*> newlyCompleted;
        for (std::vector<Branch*>::iterator b = branches.begin(); b != branches.end(); b++) {
            // Determine if the progeny of this branch is clear but has not been passed on to the parent yet.
            if ((*b)->progeniesComplete == 2 && (*b)->progenyPassedOn == false) {
                newlyCompleted.push_back(*b);
            }
        }
        if (newlyCompleted.size() == 0) allProgeniesComplete = true;
        for (std::vector<Branch*>::iterator b = newlyCompleted.begin(); b != newlyCompleted.end(); b++) {
            // Find parent, pass progeny+self on to parents progeny, add parent.progeniesComplete += 1, and change own progenyPassedOn to true.
            for (std::vector<Branch*>::iterator bb = branches.begin(); bb != branches.end(); bb++) {
                if ((*bb)->id == (*b)->parentId) {
                    (*b)->parentBranch = *bb;
                    (*bb)->progenyIds.insert((*bb)->progenyIds.end(), (*b)->progenyIds.begin(), (*b)->progenyIds.end() );
                    (*bb)->progeniesComplete++;
                    (*b)->progenyPassedOn = true;
                    break;
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
addq $0x18, %rdi
callq 0x49490
movq %rax, -0x10(%rbp)
movq -0xc8(%rbp), %rdi
addq $0x18, %rdi
callq 0x49500
movq %rax, -0x18(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x494c0
testb $0x1, %al
jne 0x473e1
jmp 0x4749c
leaq -0x10(%rbp), %rdi
callq 0x49530
movq (%rax), %rdi
addq $0x40, %rdi
leaq 0x43f8c(%rip), %rsi     # 0x8b384
callq 0x9ab0
testb $0x1, %al
jne 0x47403
jmp 0x47451
leaq -0x10(%rbp), %rdi
callq 0x49530
movq (%rax), %rax
movl $0x2, 0x110(%rax)
leaq -0x10(%rbp), %rdi
callq 0x49530
movq (%rax), %rax
addq $0x80, %rax
movq %rax, -0xd0(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x49530
movq -0xd0(%rbp), %rdi
movq (%rax), %rsi
addq $0x98, %rsi
callq 0x11d10
leaq -0x10(%rbp), %rdi
callq 0x49530
movq (%rax), %rdi
addq $0x20, %rdi
leaq 0x43edc(%rip), %rsi     # 0x8b344
callq 0x9ab0
testb $0x1, %al
jne 0x47473
jmp 0x47486
leaq -0x10(%rbp), %rdi
callq 0x49530
movq (%rax), %rax
movb $0x1, 0x114(%rax)
jmp 0x47488
leaq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x49ac0
movq %rax, -0x20(%rbp)
jmp 0x473b7
movb $0x0, -0x21(%rbp)
movb -0x21(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x474ae
jmp 0x47798
leaq -0x40(%rbp), %rdi
callq 0x49b20
movq -0xc8(%rbp), %rdi
addq $0x18, %rdi
callq 0x49490
movq %rax, -0x48(%rbp)
movq -0xc8(%rbp), %rdi
addq $0x18, %rdi
callq 0x49500
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x494c0
testb $0x1, %al
jne 0x474f2
jmp 0x4756c
leaq -0x48(%rbp), %rdi
callq 0x49530
movq (%rax), %rax
cmpl $0x2, 0x110(%rax)
jne 0x47556
leaq -0x48(%rbp), %rdi
callq 0x49530
movq (%rax), %rax
movb 0x114(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x47556
leaq -0x48(%rbp), %rdi
callq 0x49530
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x49b40
jmp 0x4753a
jmp 0x47556
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x49cc0
jmp 0x477a1
jmp 0x47558
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
callq 0x49ac0
movq %rax, -0x68(%rbp)
jmp 0x474cb
leaq -0x40(%rbp), %rdi
callq 0x49bb0
cmpq $0x0, %rax
jne 0x4757f
movb $0x1, -0x21(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x49490
movq %rax, -0x70(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x49500
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x494c0
testb $0x1, %al
jne 0x475af
jmp 0x4778a
movq -0xc8(%rbp), %rdi
addq $0x18, %rdi
callq 0x49490
movq %rax, -0x80(%rbp)
movq -0xc8(%rbp), %rdi
addq $0x18, %rdi
callq 0x49500
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x494c0
testb $0x1, %al
jne 0x475f3
jmp 0x47771
leaq -0x80(%rbp), %rdi
callq 0x49530
movq (%rax), %rax
movq %rax, -0xd8(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x49530
movq -0xd8(%rbp), %rdi
movq (%rax), %rsi
addq $0x20, %rsi
callq 0x18dd0
testb $0x1, %al
jne 0x4762b
jmp 0x47758
leaq -0x80(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x49530
movq (%rax), %rax
movq %rax, -0x100(%rbp)
leaq -0x70(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x49530
movq -0x100(%rbp), %rcx
movq -0xf8(%rbp), %rdi
movq (%rax), %rax
movq %rcx, 0xb8(%rax)
callq 0x49530
movq -0xf8(%rbp), %rdi
movq (%rax), %rax
subq $-0x80, %rax
movq %rax, -0xe8(%rbp)
callq 0x49530
movq (%rax), %rdi
subq $-0x80, %rdi
callq 0x10670
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x49c80
movq -0xf0(%rbp), %rdi
callq 0x49530
movq (%rax), %rdi
subq $-0x80, %rdi
callq 0x10640
movq -0xf0(%rbp), %rdi
movq %rax, -0xa0(%rbp)
callq 0x49530
movq (%rax), %rdi
subq $-0x80, %rdi
callq 0x10670
movq -0xe8(%rbp), %rdi
movq %rax, -0xa8(%rbp)
movq -0x90(%rbp), %rsi
movq -0xa0(%rbp), %rdx
movq -0xa8(%rbp), %rcx
callq 0x49bd0
movq %rax, -0xe0(%rbp)
jmp 0x4771a
movq -0xe0(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x49530
movq (%rax), %rax
movl 0x110(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x110(%rax)
leaq -0x70(%rbp), %rdi
callq 0x49530
movq (%rax), %rax
movb $0x1, 0x114(%rax)
jmp 0x47771
jmp 0x4775a
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
callq 0x49ac0
movq %rax, -0xb8(%rbp)
jmp 0x475c3
jmp 0x47773
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
callq 0x49ac0
movq %rax, -0xc0(%rbp)
jmp 0x4758c
leaq -0x40(%rbp), %rdi
callq 0x49cc0
jmp 0x474a0
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x8a50
nopw (%rax,%rax)