// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
movq %rdi, %rbx
movq 0x18(%rdi), %r12
cmpq 0x20(%rdi), %r12
je 0x25e2b
leaq 0x1e296(%rip), %r14     # 0x4405c
leaq 0x1e24f(%rip), %r15     # 0x4401c
movq (%r12), %rdi
addq $0x40, %rdi
movq %r14, %rsi
callq 0x70f0
testl %eax, %eax
jne 0x25e02
movq (%r12), %rsi
movl $0x2, 0x110(%rsi)
leaq 0x80(%rsi), %rdi
addq $0x98, %rsi
callq 0xd894
movq (%r12), %rdi
addq $0x20, %rdi
movq %r15, %rsi
callq 0x70f0
testl %eax, %eax
jne 0x25e21
movq (%r12), %rax
movb $0x1, 0x114(%rax)
addq $0x8, %r12
cmpq 0x20(%rbx), %r12
jne 0x25dcd
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x18(%rbx), %r15
cmpq 0x20(%rbx), %r15
je 0x25f9d
movq %rbx, 0x28(%rsp)
movq (%r15), %rax
cmpl $0x2, 0x110(%rax)
jne 0x25e88
cmpb $0x0, 0x114(%rax)
jne 0x25e88
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x25e7b
movq %rax, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0x25e88
leaq 0x10(%rsp), %rdi
movq %r15, %rdx
callq 0x3684e
addq $0x8, %r15
cmpq 0x20(%rbx), %r15
jne 0x25e4f
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %rcx
cmpq %r15, %rcx
sete %al
je 0x25f61
movb %al, 0xf(%rsp)
movq 0x18(%rbx), %r14
movq 0x20(%rbx), %rbp
cmpq %rbp, %r14
je 0x25f48
movq %rcx, 0x30(%rsp)
movq (%r15), %rbx
movq 0x28(%rbx), %r12
movq (%r14), %r13
cmpq %r12, 0x8(%r13)
jne 0x25eeb
testq %r12, %r12
je 0x25f00
movq 0x20(%rbx), %rsi
movq (%r13), %rdi
movq %r12, %rdx
callq 0x7440
testl %eax, %eax
je 0x25f00
addq $0x8, %r14
cmpq %rbp, %r14
jne 0x25ec9
movq 0x28(%rsp), %rbx
movq 0x30(%rsp), %rcx
jmp 0x25f48
movq %r13, 0xb8(%rbx)
movq (%r14), %rdi
movq 0x88(%rdi), %rsi
subq $-0x80, %rdi
movq (%r15), %rax
movq 0x80(%rax), %rdx
movq 0x88(%rax), %rcx
callq 0x3692a
movq (%r14), %rax
incl 0x110(%rax)
movq (%r15), %rax
movb $0x1, 0x114(%rax)
movq 0x18(%rsp), %rcx
movq 0x28(%rsp), %rbx
addq $0x8, %r15
cmpq %rcx, %r15
jne 0x25eac
movq 0x10(%rsp), %r15
movb 0xf(%rsp), %bpl
jmp 0x25f64
movb $0x1, %bpl
testq %r15, %r15
je 0x25f79
movq 0x20(%rsp), %rsi
subq %r15, %rsi
movq %r15, %rdi
callq 0x7420
testb %bpl, %bpl
jne 0x25f9d
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x18(%rbx), %r15
cmpq 0x20(%rbx), %r15
jne 0x25e4f
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x25fae
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x25fc8
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x7420
movq %rbx, %rdi
callq 0x7740