// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
movq %rdi, %r14
movq 0x8(%rdi), %rbx
cmpq 0x10(%rdi), %rbx
je 0x9b66
movq (%rbx), %rdi
callq 0xc3a4
addq $0x8, %rbx
cmpq 0x10(%r14), %rbx
jne 0x9b54
movq 0x38(%r14), %rax
leaq 0x28(%r14), %rbx
cmpq %rbx, %rax
je 0x9da9
movq %r15, 0x30(%rsp)
cmpq $0x0, 0x48(%rax)
je 0x9db8
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, 0x28(%rsp)
leaq 0x28(%rax), %r12
movq %r13, %rdi
callq 0x54b0
movq %rax, %r13
cmpq %rax, %r12
jne 0x9bc6
movq 0x28(%rsp), %rax
movq 0x38(%rax), %r13
cmpq %r15, 0x20(%r13)
jne 0x9bfe
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x9be7
movq (%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0x9bf4
leaq 0x10(%rsp), %rdi
movq %rbp, %rdx
callq 0xd33a
addq $0x8, %rbp
cmpq 0x48(%r15), %rbp
je 0x9c61
movq 0x20(%r13), %rdx
movq 0x40(%rdx), %rax
movq 0x48(%rdx), %rcx
movq %rcx, %r8
subq %rax, %r8
sarq $0x3, %r8
testq %r8, %r8
jle 0x9c44
movq (%rbp), %rsi
movl (%rsi), %esi
movq %r8, %rdi
shrq %rdi
movq (%rax,%rdi,8), %r9
cmpl %esi, (%r9)
jae 0x9c3c
leaq (%rax,%rdi,8), %rax
addq $0x8, %rax
notq %rdi
addq %r8, %rdi
movq %rdi, %r8
testq %rdi, %rdi
jg 0x9c22
cmpq %rax, %rcx
je 0x9c58
movq (%rax), %rsi
cmpq (%rbp), %rsi
cmovneq %rax, %rbp
cmovneq %rdx, %r15
cmpq %rax, %rcx
jne 0x9bad
movq 0x10(%rsp), %rax
cmpq 0x18(%rsp), %rax
movq 0x28(%rsp), %rbp
jne 0x9d4a
movl $0x40, %edi
callq 0x53c0
movq %rax, %r13
movq %rax, %rdi
movq %r14, %rsi
callq 0x62c8
movq %r13, 0x8(%rsp)
movq 0x38(%rbp), %r13
cmpq %r12, %r13
movq 0x30(%rsp), %r15
movl $0x1, %ebp
je 0x9ce3
movq 0x8(%rsp), %rdi
movq 0x20(%r13), %rsi
callq 0xc048
movq 0x20(%r13), %rdi
movq 0x8(%rsp), %rsi
callq 0xc01e
movq 0x20(%r13), %rdi
callq 0xc3a4
movq 0x20(%r13), %rax
imull 0x38(%rax), %ebp
movq %r13, %rdi
callq 0x54b0
movq %rax, %r13
cmpq %r12, %rax
jne 0x9ca6
movq 0x8(%rsp), %rdi
movl %ebp, %esi
movl $0x1, %edx
callq 0x5dcc
movq 0x28(%rsp), %rbp
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x9d12
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%r15)
jmp 0x9d1f
movq %r15, %rdi
leaq 0x8(%rsp), %rdx
callq 0xd33a
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x9d3b
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0x9d4a
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xd33a
movq 0x10(%rsp), %r15
cmpq 0x18(%rsp), %r15
je 0x9d81
movq 0x38(%r14), %r13
cmpq %rbx, %r13
je 0x9d7b
movq (%r15), %rdi
leaq 0x20(%r13), %rsi
callq 0x61ae
movq %r13, %rdi
callq 0x54b0
movq %rax, %r13
cmpq %rbx, %rax
jne 0x9d5f
addq $0x8, %r15
jmp 0x9d4f
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x9d98
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x53e0
movq %rbp, %rdi
callq 0x54b0
cmpq %rbx, %rax
jne 0x9b7c
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1cada(%rip), %rdi     # 0x26899
leaq 0x1c877(%rip), %rsi     # 0x2663d
leaq 0x1cadc(%rip), %rcx     # 0x268a9
movl $0x481, %edx            # imm = 0x481
callq 0x52c0
jmp 0x9df1
movq %rax, %rbx
movl $0x40, %esi
movq %r13, %rdi
callq 0x53e0
jmp 0x9df4
jmp 0x9df1
jmp 0x9df1
jmp 0x9df1
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x9e0b
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x53e0
movq %rbx, %rdi
callq 0x56a0
nop