// File: /workspace/github_cpp_makefile_star2_O3/WShabti-Team[P]WShabtiPict/wshabtilib/api/model.cpp
// Function: pictcore::Model::processExclusions(std::vector<pictcore::Combination*, std::allocator<pictcore::Combination*>>&)
void Model::processExclusions( ComboCollection& vecCombo )
{
    // Sort every parameter's collection of combinations to prepare for set intersection
    for( vector<Parameter*>::iterator ip = m_parameters.begin(); ip != m_parameters.end(); ++ip )
    {
        ( *ip )->SortCombinations();
    }

    for( ExclusionCollection::iterator iexcl = m_exclusions.begin(); iexcl != m_exclusions.end(); ++iexcl )
    {
        // paranoia; shouldn't happen
        assert( !iexcl->empty() );
        if( iexcl->empty() ) continue;

        // form the intersection of the combinations associated with each of the
        //  parameters that make up this exclusion
        ComboCollection intersection;
        Exclusion::iterator iexclterm = iexcl->begin();
        Parameter* sourceParam = iexclterm->first;
        ComboCollection::const_iterator posCandidate = sourceParam->GetCombinationBegin();
        while( true )
        {
            // We're going around and around...
            if( iexcl->end() == ++iexclterm )
            {
                iexclterm = iexcl->begin();
            }

            if( iexclterm->first == sourceParam )
            {
                intersection.push_back( *posCandidate );
                if( ++posCandidate == sourceParam->GetCombinationEnd() ) break;
            }
            // find next >= in this param
            ComboCollection::const_iterator posLB = lower_bound( iexclterm->first->GetCombinationBegin(),
                                                                 iexclterm->first->GetCombinationEnd(),
                                                                 *posCandidate, CombinationPtrSortPred() );
            if( iexclterm->first->GetCombinationEnd() == posLB ) break;
            
            // if >, reset candidate and source
            if( *posLB != *posCandidate )
            {
                posCandidate = posLB;
                sourceParam = iexclterm->first;
            }
        }
        // If the result is empty, make a new combination from the exclusion,
        // mark all of its members satisfied, and make sure all the parameters in the new
        // combination still have sorted combination collections.
        if( intersection.empty() )
        {
            Combination *pNewCombo = new Combination( this );
            int size = 1;
            for( Exclusion::iterator ix = iexcl->begin(); ix != iexcl->end(); ++ix )
            {
                pNewCombo->PushParameter( ( ix->first ) );
                ix->first->LinkCombination( pNewCombo );
                ix->first->SortCombinations();
                size *= ix->first->GetValueCount();
            }
            // Set size of combination's bit vector
            pNewCombo->SetMapSize( size, COVERED );
            vecCombo.push_back( pNewCombo );
            intersection.push_back( pNewCombo );
        }

        for( ComboCollection::iterator ic = intersection.begin(); ic != intersection.end(); ++ic )
        {
            // all exclusions must be applied to the combo and not just the current one
            for( ExclusionCollection::iterator ie = m_exclusions.begin(); ie != m_exclusions.end(); ++ie )
            {
                ( *ic )->ApplyExclusion( const_cast<Exclusion&> ( *ie ) );
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, 0x28(%rsp)
movq %rdi, %r14
movq 0x8(%rdi), %rbx
cmpq 0x10(%rdi), %rbx
je 0x9a1a
movq (%rbx), %rdi
callq 0xc284
addq $0x8, %rbx
cmpq 0x10(%r14), %rbx
jne 0x9a08
movq 0x38(%r14), %rax
leaq 0x28(%r14), %r12
cmpq %r12, %rax
je 0x9c6d
movq %r14, 0x30(%rsp)
cmpq $0x0, 0x48(%rax)
je 0x9c7c
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x38(%rax), %r13
movq 0x20(%r13), %r15
movq 0x40(%r15), %rbp
movq %rax, %r14
leaq 0x28(%rax), %rbx
movq %r13, %rdi
callq 0x54b0
movq %rax, %r13
cmpq %rax, %rbx
jne 0x9a73
movq 0x38(%r14), %r13
movq 0x20(%r13), %rax
cmpq %r15, %rax
jne 0x9ab2
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x9a97
movq (%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0x9aa4
leaq 0x10(%rsp), %rdi
movq %rbp, %rdx
callq 0xd208
addq $0x8, %rbp
cmpq 0x48(%r15), %rbp
je 0x9b0d
movq 0x20(%r13), %rax
movq 0x40(%rax), %rcx
movq 0x48(%rax), %rdx
movq %rdx, %r8
subq %rcx, %r8
sarq $0x3, %r8
testq %r8, %r8
jle 0x9af4
movq (%rbp), %rsi
movl (%rsi), %esi
movq %r8, %rdi
shrq %rdi
movq (%rcx,%rdi,8), %r9
cmpl %esi, (%r9)
jae 0x9aec
leaq (%rcx,%rdi,8), %rcx
addq $0x8, %rcx
notq %rdi
addq %r8, %rdi
movq %rdi, %r8
testq %rdi, %rdi
jg 0x9ad2
cmpq %rcx, %rdx
je 0x9b0d
movq (%rcx), %rdx
cmpq (%rbp), %rdx
cmovneq %rcx, %rbp
cmovneq %rax, %r15
jmp 0x9a5f
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rax
cmpq %rax, %r13
movq %r14, %r15
movq 0x30(%rsp), %r14
jne 0x9c09
movl $0x40, %edi
callq 0x53c0
movq %rax, %r13
movq %rax, %rdi
movq %r14, %rsi
callq 0x630e
movq %r13, 0x8(%rsp)
movq %r13, %rdi
movq 0x38(%r15), %r13
movl $0x1, %ebp
cmpq %rbx, %r13
je 0x9b98
movq 0x8(%rsp), %rdi
movq 0x20(%r13), %rsi
callq 0xbf22
movq 0x20(%r13), %rdi
movq 0x8(%rsp), %rsi
callq 0xbef8
movq 0x20(%r13), %rdi
callq 0xc284
movq 0x20(%r13), %rax
imull 0x38(%rax), %ebp
movq %r13, %rdi
callq 0x54b0
movq %rax, %r13
cmpq %rbx, %rax
jne 0x9b56
movq 0x8(%rsp), %rdi
movl %ebp, %esi
movl $0x1, %edx
callq 0x5ddc
movq 0x28(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x9bc2
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x9bcc
leaq 0x8(%rsp), %rdx
callq 0xd208
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x9bf0
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
movq 0x18(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x18(%rsp)
jmp 0x9c04
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xd208
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %r13
cmpq %rax, %r13
je 0x9c47
movq 0x38(%r14), %rbx
cmpq %r12, %rbx
je 0x9c39
movq (%r13), %rdi
leaq 0x20(%rbx), %rsi
callq 0x6208
movq %rbx, %rdi
callq 0x54b0
movq %rax, %rbx
cmpq %r12, %rax
jne 0x9c17
movq 0x18(%rsp), %rax
addq $0x8, %r13
cmpq %rax, %r13
jne 0x9c0e
movq 0x10(%rsp), %r13
testq %r13, %r13
je 0x9c5c
movq 0x20(%rsp), %rsi
subq %r13, %rsi
movq %r13, %rdi
callq 0x53e0
movq %r15, %rdi
callq 0x54b0
cmpq %r12, %rax
jne 0x9a30
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1cc16(%rip), %rdi     # 0x26899
leaq 0x1c9b3(%rip), %rsi     # 0x2663d
leaq 0x1cc18(%rip), %rcx     # 0x268a9
movl $0x481, %edx            # imm = 0x481
callq 0x52c0
jmp 0x9cb5
movq %rax, %r14
movl $0x40, %esi
movq %r13, %rdi
callq 0x53e0
jmp 0x9cb8
jmp 0x9cb5
jmp 0x9cb5
jmp 0x9cb5
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x9ccf
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x53e0
movq %r14, %rdi
callq 0x56a0
nop