// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x18(%rdi), %r12
leaq 0x19990(%rip), %r14     # 0x38fec
leaq 0x19949(%rip), %r15     # 0x38fac
cmpq 0x20(%rbx), %r12
je 0x1f6c3
movq (%r12), %rdi
addq $0x40, %rdi
movq %r14, %rsi
callq 0x813d
testb %al, %al
je 0x1f69e
movq (%r12), %rsi
movl $0x2, 0x110(%rsi)
leaq 0x80(%rsi), %rdi
addq $0x98, %rsi
callq 0xbdc2
movq (%r12), %rdi
addq $0x20, %rdi
movq %r15, %rsi
callq 0x813d
testb %al, %al
je 0x1f6bd
movq (%r12), %rax
movb $0x1, 0x114(%rax)
addq $0x8, %r12
jmp 0x1f663
movq %rsp, %r14
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
movq 0x18(%rbx), %r15
cmpq 0x20(%rbx), %r15
je 0x1f703
movq (%r15), %rax
cmpl $0x2, 0x110(%rax)
jne 0x1f6fd
cmpb $0x0, 0x114(%rax)
jne 0x1f6fd
movq %r14, %rdi
movq %r15, %rsi
callq 0x209d4
addq $0x8, %r15
jmp 0x1f6d7
movq (%rsp), %r15
movq 0x8(%rsp), %r12
movq %r12, %rax
movq %r15, %r13
cmpq %rax, %r13
je 0x1f78d
movq 0x18(%rbx), %rbp
cmpq 0x20(%rbx), %rbp
je 0x1f782
movq (%rbp), %rdi
movq (%r13), %rsi
addq $0x20, %rsi
callq 0xd5bf
testb %al, %al
jne 0x1f73c
addq $0x8, %rbp
jmp 0x1f71b
movq (%rbp), %rdi
movq (%r13), %rax
movq %rdi, 0xb8(%rax)
movq 0x88(%rdi), %rsi
subq $-0x80, %rdi
movq (%r13), %rax
movq 0x80(%rax), %rdx
movq 0x88(%rax), %rcx
callq 0x209f2
movq (%rbp), %rax
incl 0x110(%rax)
movq (%r13), %rax
movb $0x1, 0x114(%rax)
addq $0x8, %r13
movq 0x8(%rsp), %rax
jmp 0x1f712
movq %r14, %rdi
callq 0x2cf4a
cmpq %r15, %r12
jne 0x1f6c6
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1f7af
movq %rax, %rbx
movq %rsp, %rdi
callq 0x2cf4a
movq %rbx, %rdi
callq 0x7750