// File: /workspace/github_cpp_makefile_star2_O2/WShabti-Team[P]WShabtiPict/wshabtilib/api/deriver.cpp
// Function: pictcore::ExclusionDeriver::buildExclusion(pictcore::Exclusion&, __gnu_cxx::__normal_iterator<std::__cxx11::list<pictcore::Exclusion*, std::allocator<pictcore::Exclusion*>>*, std::vector<std::__cxx11::list<pictcore::Exclusion*, std::allocator<pictcore::Exclusion*>>, std::allocator<std::__cxx11::list<pictcore::Exclusion*, std::allocator<pictcore::Exclusion*>>>>>)
inline void ExclusionDeriver::buildExclusion( Exclusion& exclImplied, vector<ExclPtrList>::iterator begin )
{
    // derivation can take a long time, use the call back to check if it should be aborted
    if( m_task->AbortGeneration() )
    {
        throw GenerationError( __FILE__, __LINE__, GenerationCancelled );
    }

    if( begin != m_end )
    {
        // for each exclusion in this bucket
        for( ExclPtrList::iterator i = begin->begin(); i != begin->end(); ++i )
        {
            // don't bother if the exclusion was already marked obsolete
            if( ( *i )->isDeleted() ) continue;

            // check for contradiction, continue if found
            if( !consistent( exclImplied, **i ) ) continue; 

            // merge the exclusion into the given one to make a new one
            Exclusion excl( exclImplied );
            for( Exclusion::iterator ie = ( *i )->begin(); ie != ( *i )->end(); ++ie )
            {
                if( ie->first != m_currentParam )
                {
                    excl.insert( *ie );
                }
            }

            // checking for being in the collection while still in progress of generation 
            // is just an optimization but it speeds things up considerably
            // The reasoning: if at this point the exclusion being built is already obsolete
            // we should stop building immediatelly and move on
            // however, it does not make sense to check if an exclusion is in the collection
            // before it reaches a size of 3; very rarely there will be an broader
            // exclusion for size <3

            if( alreadyInCollection( excl ) ) continue;

            // call buildExclusion on next bucket, passing our exclusion in progress
            buildExclusion( excl, begin + 1 );
        }
    }
    else
    {
        // add new exclusion to model
        //   first  = an iterator to the new exclusion,
        //   second = return whether item was added (true means it wasn't a duplicate)
        pair<ExclusionCollection::iterator, bool> addResult = AddExclusion( exclImplied, false );
        if( !addResult.second ) return;

        // now go through the collection and mark those that became obsolete
        markObsolete( addResult.first );

        DOUT( static_cast<int>( m_exclusions.size() ) << L" " );

        // add new references to existing structures
        AddExclusionParamBackPtrs( addResult.first );

        // if exclusion count >= value count for any params in new exclusion
        for( Exclusion::iterator i = exclImplied.begin(); i != exclImplied.end(); ++i )
        {
            if( i->first->GetExclusionCount() >= i->first->GetValueCount() &&
                m_worklist.end() == find( m_worklist.begin(), m_worklist.end(), i->first ) )
            {
                m_worklist.push_back( i->first );
                DOUT( L"worklist: 1 added\n" );
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdx, %r12
movq %rsi, %rbp
movq %rdi, %r14
movq 0x50(%rdi), %rax
movq 0x50(%rax), %rax
testq %rax, %rax
je 0x790d
callq *%rax
testb %al, %al
jne 0x7abb
cmpq %r12, 0x58(%r14)
je 0x79c8
leaq 0x18(%r12), %rax
movq %rax, 0x8(%rsp)
leaq 0x88(%rsp), %r13
movq %r12, %r15
movq %rbp, (%rsp)
movq (%r15), %r15
cmpq %r12, %r15
je 0x7aa9
movq 0x10(%r15), %rdx
cmpb $0x0, 0x48(%rdx)
jne 0x7930
movq %r14, %rdi
movq %rbp, %rsi
callq 0x7108
testb %al, %al
je 0x7930
movq %r13, %rdi
movq %rbp, %rsi
callq 0x7f9c
movq 0x10(%r15), %rbx
movq 0x18(%rbx), %rbp
leaq 0x8(%rbx), %rax
cmpq %rax, %rbp
je 0x7998
movq 0x20(%rbp), %rax
cmpq 0x48(%r14), %rax
je 0x798b
leaq 0x20(%rbp), %rsi
movq %r13, %rdi
callq 0x7fda
movq 0x10(%r15), %rbx
movq %rbp, %rdi
callq 0x6500
movq %rax, %rbp
jmp 0x7968
movq %r14, %rdi
movq %r13, %rsi
callq 0x75e4
testb %al, %al
jne 0x79b7
movq %r14, %rdi
movq %r13, %rsi
movq 0x8(%rsp), %rdx
callq 0x78dc
movq %r13, %rdi
callq 0x7b50
movq (%rsp), %rbp
jmp 0x7930
movq %r14, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x71aa
movq %rax, 0x10(%rsp)
movb %dl, 0x18(%rsp)
testb $0x1, %dl
je 0x7aa9
movq %r14, %rdi
movq %rax, %rsi
callq 0x721e
leaq 0x10(%rsp), %rdi
callq 0x7290
movq 0x18(%rbp), %r12
addq $0x8, %rbp
leaq 0x60(%r14), %rax
movq %rax, (%rsp)
leaq 0x20(%rsp), %r15
cmpq %rbp, %r12
je 0x7aa9
movq 0x20(%r12), %rax
movl 0x38(%rax), %ecx
cmpl 0x80(%rax), %ecx
jg 0x7a99
leaq 0x20(%r12), %r13
movq 0x90(%r14), %rbx
movups 0x70(%r14), %xmm0
movaps %xmm0, 0x40(%rsp)
movups 0x80(%r14), %xmm0
movaps %xmm0, 0x50(%rsp)
movq %rbx, 0x20(%rsp)
movups 0x98(%r14), %xmm0
movups %xmm0, 0x28(%rsp)
movq 0xa8(%r14), %rax
movq %rax, 0x38(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x8043
cmpq 0x88(%rsp), %rbx
jne 0x7a99
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x8086
movq %r12, %rdi
callq 0x6500
movq %rax, %r12
jmp 0x7a11
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x30
popq %rdi
callq 0x6220
movq %rax, %rbx
leaq 0x1a69d(%rip), %rsi     # 0x2216a
leaq 0x68(%rsp), %rdi
leaq 0x88(%rsp), %rdx
callq 0x7f56
andl $0x0, (%rbx)
movq %rbx, %rdi
addq $0x8, %rdi
movb $0x1, %bpl
leaq 0x68(%rsp), %rsi
callq 0x65b0
movl $0xb4, 0x28(%rbx)
xorl %ebp, %ebp
leaq 0x2cf3a(%rip), %rsi     # 0x34a40
leaq 0x485(%rip), %rdx       # 0x7f92
movq %rbx, %rdi
callq 0x66c0
movq %rax, %r14
leaq 0x68(%rsp), %rdi
callq 0x61e0
testb %bpl, %bpl
jne 0x7b2c
jmp 0x7b48
movq %rax, %r14
movq %rbx, %rdi
callq 0x6340
jmp 0x7b48
jmp 0x7b38
movq %rax, %r14
leaq 0x88(%rsp), %rdi
callq 0x7b50
movq %r14, %rdi
callq 0x66e0