// File: WShabti-Team[P]WShabtiPict/wshabtilib/api/model.cpp
// Function: pictcore::Model::mapExclusionsToPseudoParameters()
bool Model::mapExclusionsToPseudoParameters()
{
    bool ret = false;

    // for each pseudoparameter
    for( size_t index = 0; index < GetParameters().size(); ++index )
    {
        Parameter* param = GetParameters()[ index ];
        ParamCollection* comps = param->GetComponents();
        
        if( comps )
        {
            // orepare a temporary collection for all exclusions being added
            ExclusionCollection newExcls;
        
            // this parameter is really a pseudoparameter
            for( ExclusionCollection::iterator iexcls = m_exclusions.begin(); iexcls != m_exclusions.end(); )
            {
                // partition exclusion terms into related, unrelated (to pseudoparam)
                Exclusion relatedTerms;
                Exclusion unrelatedTerms;
                for( Exclusion::iterator iexcl = iexcls->begin(); iexcl != iexcls->end(); ++iexcl )
                {
                    if( find( comps->begin(), comps->end(), iexcl->first ) == comps->end() )
                    {
                        unrelatedTerms.insert( *iexcl );
                    }
                    else
                    {
                        relatedTerms.insert( *iexcl );
                    }
                }

                // if any of exclusion's terms relate to underlying parameters
                if( !relatedTerms.empty() )
                {
                    // Get rid of the exclusion, since we'll replace it
                    m_exclusions.erase( iexcls++ );

                    // for each value of the pseudoparameter
                    for( int vidx = 0; vidx < param->GetValueCount(); ++vidx )
                    {
                        Exclusion::iterator irel;
                        for( irel = relatedTerms.begin(); irel != relatedTerms.end(); ++irel )
                        {
                            vector<Parameter*>::iterator ip = find( comps->begin(), comps->end(), irel->first );
                            if( comps->end() == ip )
                            {
                                break;
                            }
                            int nParam = static_cast<int>( distance( comps->begin(), ip ) );
                            size_t nRealVal = param->GetModel()->GetResults()[ vidx ][ nParam ];
                            if( nRealVal != irel->second )
                            {
                                break;
                            }
                        }

                        // if value is excluded in overlapping underlying params
                        if( relatedTerms.end() == irel )
                        {
                            // generate a new exclusion using unrelated + this pseudo/value
                            Exclusion newExclusion( unrelatedTerms );
                            newExclusion.insert( make_pair( param, vidx ) );
                            // Put it into a temporary collection so we don't hit it again on this iteration
                            newExcls.insert( newExclusion );
                            ret = true;
                        }
                    }
                }
                else
                {
                    // no new exclusion, just increment loop iterator
                    ++iexcls;
                }
            }

            // copy all new exclusions to the main collection
            __insert( m_exclusions, newExcls.begin(), newExcls.end() );
        }
    }

    return( ret );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x360, %rsp            # imm = 0x360
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x288(%rbp)
movb $0x0, -0x9(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x288(%rbp), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0x290(%rbp)
callq 0x1c780
movq %rax, %rdi
callq 0x8fd0
movq %rax, %rcx
movq -0x290(%rbp), %rax
cmpq %rcx, %rax
jae 0x1a9f0
movq -0x288(%rbp), %rdi
callq 0x1c780
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x1c7a0
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1a9dd
leaq -0x58(%rbp), %rdi
callq 0x1d040
movq -0x288(%rbp), %rdi
addq $0x20, %rdi
callq 0xaf20
movq %rax, -0x60(%rbp)
movq -0x288(%rbp), %rdi
addq $0x20, %rdi
callq 0xab70
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xaf50
testb $0x1, %al
jne 0x1a347
jmp 0x1a96f
leaq -0xb8(%rbp), %rdi
callq 0xb6c0
jmp 0x1a355
leaq -0x118(%rbp), %rdi
callq 0xb6c0
jmp 0x1a363
leaq -0x60(%rbp), %rdi
callq 0xaed0
movq %rax, %rdi
callq 0xb030
movq %rax, -0x298(%rbp)
jmp 0x1a37d
movq -0x298(%rbp), %rax
movq %rax, -0x120(%rbp)
leaq -0x60(%rbp), %rdi
callq 0xaed0
movq %rax, %rdi
callq 0xb060
movq %rax, -0x2a0(%rbp)
jmp 0x1a3a5
movq -0x2a0(%rbp), %rax
movq %rax, -0x128(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x9130
testb $0x1, %al
jne 0x1a3cf
jmp 0x1a539
movq -0x28(%rbp), %rdi
callq 0x8c90
movq %rax, -0x138(%rbp)
movq -0x28(%rbp), %rdi
callq 0x8cc0
movq %rax, -0x140(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x9160
movq %rax, %rdx
movq -0x138(%rbp), %rdi
movq -0x140(%rbp), %rsi
callq 0x91c0
movq %rax, -0x2a8(%rbp)
jmp 0x1a41a
movq -0x2a8(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x28(%rbp), %rdi
callq 0x8cc0
movq %rax, -0x148(%rbp)
leaq -0x130(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x8ff0
testb $0x1, %al
jne 0x1a454
jmp 0x1a4e2
leaq -0x120(%rbp), %rdi
callq 0x9910
movq %rax, %rsi
leaq -0x118(%rbp), %rdi
callq 0xd9b0
movb %dl, -0x2b1(%rbp)
movq %rax, -0x2b0(%rbp)
jmp 0x1a47e
movb -0x2b1(%rbp), %al
movq -0x2b0(%rbp), %rcx
movq %rcx, -0x158(%rbp)
movb %al, -0x150(%rbp)
jmp 0x1a526
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x1a9d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x1a961
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x1a955
leaq -0x120(%rbp), %rdi
callq 0x9910
movq %rax, %rsi
leaq -0xb8(%rbp), %rdi
callq 0xd9b0
movb %dl, -0x2c1(%rbp)
movq %rax, -0x2c0(%rbp)
jmp 0x1a50c
movb -0x2c1(%rbp), %al
movq -0x2c0(%rbp), %rcx
movq %rcx, -0x168(%rbp)
movb %al, -0x160(%rbp)
jmp 0x1a528
leaq -0x120(%rbp), %rdi
callq 0x9210
jmp 0x1a38b
leaq -0xb8(%rbp), %rdi
callq 0xaf00
movb %al, -0x2c2(%rbp)
jmp 0x1a54d
movb -0x2c2(%rbp), %al
testb $0x1, %al
jne 0x1a92f
jmp 0x1a55d
movq -0x288(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x2d8(%rbp)
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
callq 0x1d060
movq -0x2d8(%rbp), %rdi
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rsi
callq 0x13630
movq %rax, -0x2d0(%rbp)
jmp 0x1a59d
movq -0x2d0(%rbp), %rax
movq %rax, -0x178(%rbp)
movl $0x0, -0x17c(%rbp)
movl -0x17c(%rbp), %eax
movl %eax, -0x2e0(%rbp)
movq -0x20(%rbp), %rdi
callq 0x8eb0
movl %eax, -0x2dc(%rbp)
jmp 0x1a5d2
movl -0x2e0(%rbp), %eax
movl -0x2dc(%rbp), %ecx
cmpl %ecx, %eax
jge 0x1a92d
leaq -0x188(%rbp), %rdi
callq 0x1d0a0
leaq -0xb8(%rbp), %rdi
callq 0x9090
movq %rax, -0x2e8(%rbp)
jmp 0x1a607
movq -0x2e8(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0x190(%rbp), %rax
movq %rax, -0x188(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x90c0
movq %rax, -0x2f0(%rbp)
jmp 0x1a638
movq -0x2f0(%rbp), %rax
movq %rax, -0x198(%rbp)
leaq -0x188(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x9130
testb $0x1, %al
jne 0x1a662
jmp 0x1a7c9
movq -0x28(%rbp), %rdi
callq 0x8c90
movq %rax, -0x1a8(%rbp)
movq -0x28(%rbp), %rdi
callq 0x8cc0
movq %rax, -0x1b0(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x9160
movq %rax, %rdx
movq -0x1a8(%rbp), %rdi
movq -0x1b0(%rbp), %rsi
callq 0x91c0
movq %rax, -0x2f8(%rbp)
jmp 0x1a6ad
movq -0x2f8(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movq -0x28(%rbp), %rdi
callq 0x8cc0
movq %rax, -0x1b8(%rbp)
leaq -0x1b8(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x8ff0
testb $0x1, %al
jne 0x1a6e4
jmp 0x1a6e9
jmp 0x1a7c9
movq -0x28(%rbp), %rdi
callq 0x8c90
movq %rax, -0x1c8(%rbp)
movq -0x1a0(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq -0x1c8(%rbp), %rdi
movq -0x1d0(%rbp), %rsi
callq 0x1b770
movq %rax, -0x300(%rbp)
jmp 0x1a723
movq -0x300(%rbp), %rax
movl %eax, -0x1bc(%rbp)
movq -0x20(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, -0x308(%rbp)
jmp 0x1a746
movq -0x308(%rbp), %rdi
callq 0x1c890
movq %rax, -0x310(%rbp)
jmp 0x1a75b
movq -0x310(%rbp), %rdi
movslq -0x17c(%rbp), %rsi
callq 0x1c6c0
movq %rax, %rdi
movslq -0x1bc(%rbp), %rsi
callq 0x1c6e0
movq (%rax), %rax
movq %rax, -0x1d8(%rbp)
movq -0x1d8(%rbp), %rax
movq %rax, -0x318(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x9160
movq %rax, %rcx
movq -0x318(%rbp), %rax
movslq 0x8(%rcx), %rcx
cmpq %rcx, %rax
je 0x1a7b6
jmp 0x1a7c9
jmp 0x1a7b8
leaq -0x188(%rbp), %rdi
callq 0x9210
jmp 0x1a623
leaq -0xb8(%rbp), %rdi
callq 0x90c0
movq %rax, -0x320(%rbp)
jmp 0x1a7de
movq -0x320(%rbp), %rax
movq %rax, -0x1e0(%rbp)
leaq -0x1e0(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0xaa50
testb $0x1, %al
jne 0x1a808
jmp 0x1a917
leaq -0x230(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0xd930
jmp 0x1a81d
leaq -0x20(%rbp), %rdi
leaq -0x17c(%rbp), %rsi
callq 0x1ca40
movl %edx, -0x32c(%rbp)
movq %rax, -0x328(%rbp)
jmp 0x1a83c
movl -0x32c(%rbp), %eax
movq -0x328(%rbp), %rcx
movq %rcx, -0x250(%rbp)
movl %eax, -0x248(%rbp)
movl -0x248(%rbp), %eax
movl %eax, -0x238(%rbp)
movq -0x250(%rbp), %rax
movq %rax, -0x240(%rbp)
leaq -0x230(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0xd9b0
movb %dl, -0x339(%rbp)
movq %rax, -0x338(%rbp)
jmp 0x1a892
movb -0x339(%rbp), %al
movq -0x338(%rbp), %rcx
movq %rcx, -0x260(%rbp)
movb %al, -0x258(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0xaba0
movb %dl, -0x349(%rbp)
movq %rax, -0x348(%rbp)
jmp 0x1a8cb
movb -0x349(%rbp), %al
movq -0x348(%rbp), %rcx
movq %rcx, -0x270(%rbp)
movb %al, -0x268(%rbp)
movb $0x1, -0x9(%rbp)
leaq -0x230(%rbp), %rdi
callq 0xbc70
jmp 0x1a917
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x230(%rbp), %rdi
callq 0xbc70
jmp 0x1a955
jmp 0x1a919
movl -0x17c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x17c(%rbp)
jmp 0x1a5b5
jmp 0x1a938
leaq -0x60(%rbp), %rdi
callq 0xb000
leaq -0x118(%rbp), %rdi
callq 0xbc70
leaq -0xb8(%rbp), %rdi
callq 0xbc70
jmp 0x1a31d
leaq -0x118(%rbp), %rdi
callq 0xbc70
leaq -0xb8(%rbp), %rdi
callq 0xbc70
jmp 0x1a9d2
movq -0x288(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x358(%rbp)
leaq -0x58(%rbp), %rdi
movq %rdi, -0x360(%rbp)
callq 0xaf20
movq -0x360(%rbp), %rdi
movq %rax, -0x278(%rbp)
callq 0xab70
movq -0x358(%rbp), %rdi
movq %rax, -0x280(%rbp)
movq -0x278(%rbp), %rsi
movq -0x280(%rbp), %rdx
callq 0x1d0c0
jmp 0x1a9c7
leaq -0x58(%rbp), %rdi
callq 0x1d120
jmp 0x1a9dd
leaq -0x58(%rbp), %rdi
callq 0x1d120
jmp 0x1a9fe
jmp 0x1a9df
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x1a296
movb -0x9(%rbp), %al
andb $0x1, %al
addq $0x360, %rsp            # imm = 0x360
popq %rbp
retq
movq -0xc0(%rbp), %rdi
callq 0x79d0
nopw (%rax,%rax)