// File: /workspace/github_cpp_makefile_star2_O2/WShabti-Team[P]WShabtiPict/wshabtilib/api/model.cpp
// Function: pictcore::Model::GenerateVirtualRoot()
void Model::GenerateVirtualRoot()
{
    DOUT( L"GenerateVirtualRoot: Begin" << endl );

    // no support for result rows in this generation mode
    assert( 0 == GetResultParameterCount() );

    GlobalZerosCount = 0;

    // this node is a virtual root node
    // muster all parameters out of the sub-models
    // use IDs to avoid adding any parameter twice
    set<wstring> paramIds;
    for( SubmodelCollection::iterator i = m_submodels.begin(); i != m_submodels.end(); ++i )
    {
        for( vector<Parameter*>::iterator ip = ( *i )->GetParameters().begin(); ip != ( *i )->GetParameters().end(); ++ip )
        {
            if( paramIds.end() == find( paramIds.begin(), paramIds.end(), ( *ip )->GetName() ) )
            {
                paramIds.insert( ( *ip )->GetName() );
                AddParameter( *ip );
            }
        }
    }
    
    // don't need this, so don't wait for it to go out of scope
    paramIds.clear();

    // create a combination for every sub-model
    // mark all satisfied except those corresponding to output rows in sub-models
    ComboCollection vecCombo;
    for( SubmodelCollection::iterator i = m_submodels.begin(); i != m_submodels.end(); ++i )
    {
        Combination *combo = new Combination( this );
        vecCombo.push_back( combo );
        int size = 1;
        for( ParamCollection::iterator ip = ( *i )->GetParameters().begin(); ip != ( *i )->GetParameters().end(); ++ip )
        {
            ( *ip )->LinkCombination( combo );
            combo->PushParameter( *ip );
            size *= ( *ip )->GetValueCount();
        }

        // init all combinations to satisfied, don't count any zeros
        combo->SetMapSize( size, COVERED );
        // for each result row
        for( int ridx = 0; ridx < ( *i )->GetResultCount(); ++ridx )
        {
            size_t index = 0;
            // calculate index to combination corresponding to this sub-model output row
            const ResultRow& results = ( *i )->GetResults()[ ridx ];
            int cidx = 0;
            for( ParamCollection::iterator ip = ( *i )->GetParameters().begin(); ip != ( *i )->GetParameters().end(); ++ip )
            {
                index *= ( *ip )->GetValueCount();
                index += results[ cidx++ ];
            }
            // make this index a target to generate
            combo->SetOpen( (int) index );
        }
    }

    gcd( vecCombo );
    DOUT( L"GenerateVirtualRoot: End << end " );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
callq 0xc4cc
testq %rax, %rax
jne 0xbb70
andl $0x0, (%rbx)
leaq 0x30(%rsp), %r14
andl $0x0, (%r14)
andq $0x0, 0x8(%r14)
movq %r14, 0x10(%r14)
movq %r14, 0x18(%r14)
andq $0x0, 0x20(%r14)
leaq 0x50(%rbx), %rbp
leaq 0x28(%rsp), %r15
movq %rbp, %r12
movq (%r12), %r12
cmpq %rbp, %r12
je 0xba2c
movq 0x10(%r12), %rax
movq 0x8(%rax), %r13
cmpq 0x10(%rax), %r13
je 0xb9d3
movq 0x40(%rsp), %rdi
movq (%r13), %rdx
addq $0x8, %rdx
movq %r14, %rsi
callq 0xeda1
cmpq %rax, %r14
jne 0xba21
movq (%r13), %rsi
addq $0x8, %rsi
movq %r15, %rdi
callq 0xee10
movq (%r13), %rsi
movq %rbx, %rdi
callq 0xc5c2
addq $0x8, %r13
movq 0x10(%r12), %rax
jmp 0xb9e5
leaq 0x28(%rsp), %rdi
callq 0xf002
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
pushq $0x18
popq %r15
movq %rbp, %r12
movq (%r12), %r12
cmpq %rbp, %r12
je 0xbb40
pushq $0x40
popq %rdi
callq 0x6440
movq %rax, %r13
movq %rax, %rdi
movq %rbx, %rsi
callq 0x6fa6
movq %r13, 0x8(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xc402
movq 0x10(%r12), %rax
movq 0x8(%rax), %r14
pushq $0x1
popq %r13
cmpq 0x10(%rax), %r14
je 0xbac4
movq (%r14), %rdi
movq 0x8(%rsp), %rsi
callq 0xc420
movq 0x8(%rsp), %rdi
movq (%r14), %rsi
callq 0xc436
movq (%r14), %rax
imull 0x38(%rax), %r13d
addq $0x8, %r14
movq 0x10(%r12), %rax
jmp 0xba91
movq 0x8(%rsp), %rdi
movl %r13d, %esi
pushq $0x1
popq %rdx
callq 0x6adc
xorl %r13d, %r13d
movq 0x10(%r12), %rsi
movq 0xd0(%rsi), %rcx
movq 0xd8(%rsi), %rax
subq %rcx, %rax
cqto
idivq %r15
cltq
cmpq %rax, %r13
jge 0xba4d
imulq $0x18, %r13, %rax
addq %rax, %rcx
movq 0x8(%rsi), %rax
movq 0x10(%rsi), %rdx
xorl %edi, %edi
xorl %esi, %esi
leaq (%rax,%rdi), %r8
cmpq %rdx, %r8
je 0xbb31
movq (%r8), %r8
movl 0x38(%r8), %r8d
imulq %r8, %rsi
movq (%rcx), %r8
addq (%r8,%rdi), %rsi
addq $0x8, %rdi
jmp 0xbb10
movq 0x8(%rsp), %rdi
callq 0x6f66
incq %r13
jmp 0xbad7
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x9ce0
leaq 0x10(%rsp), %rdi
callq 0xd978
leaq 0x28(%rsp), %rdi
callq 0xd100
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16c4b(%rip), %rdi     # 0x227c2
leaq 0x16ab7(%rip), %rsi     # 0x22635
leaq 0x16c5c(%rip), %rcx     # 0x227e1
movl $0x2bf, %edx            # imm = 0x2BF
callq 0x6310
jmp 0xbbae
jmp 0xbbae
movq %rax, %rbx
pushq $0x40
popq %rsi
movq %r13, %rdi
callq 0x6460
jmp 0xbbb1
jmp 0xbbae
jmp 0xbba9
jmp 0xbbae
movq %rax, %rbx
jmp 0xbbbb
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xd978
leaq 0x28(%rsp), %rdi
callq 0xd100
movq %rbx, %rdi
callq 0x66e0
nop