// File: /workspace/github_cpp_makefile_star2_O3/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 $0xe8, %rsp
movq %rdx, %rcx
movq %rsi, %rbp
movq %rdi, %r14
movq 0x50(%rdi), %rax
movq 0x50(%rax), %rax
testq %rax, %rax
movq %rdx, (%rsp)
je 0x6d23
callq *%rax
movq (%rsp), %rcx
testb %al, %al
jne 0x6fbf
cmpq %rcx, 0x58(%r14)
je 0x6e90
movq %rbp, 0x8(%rsp)
movq (%rcx), %r13
cmpq %rcx, %r13
je 0x6fad
leaq 0x50(%rsp), %r12
movq 0x8(%rsp), %rax
addq $0x30, %rax
movq %rax, 0x18(%rsp)
leaq 0xb0(%r14), %rbp
leaq 0x18(%rcx), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%r13), %rdx
cmpb $0x0, 0x48(%rdx)
jne 0x6e7e
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x6408
movq (%rsp), %rcx
testb %al, %al
je 0x6e7e
leaq 0x20(%rsp), %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x768c
movq %r12, %rdi
movq 0x18(%rsp), %rsi
callq 0x7614
movb 0x48(%rbx), %al
movb %al, 0x68(%rsp)
movq 0x10(%r13), %r15
movq 0x18(%r15), %rbx
leaq 0x8(%r15), %rax
cmpq %rax, %rbx
je 0x6de8
movq 0x20(%rbx), %rax
cmpq 0x48(%r14), %rax
je 0x6ddb
leaq 0x20(%rbx), %rsi
leaq 0x20(%rsp), %rdi
callq 0x7466
movq 0x10(%r13), %r15
movq %rbx, %rdi
callq 0x54b0
movq %rax, %rbx
jmp 0x6db6
movq 0x50(%rsp), %rbx
movq 0x58(%rsp), %r15
cmpq %r15, %rbx
je 0x6e24
movq %r15, %rax
subq %rbx, %rax
sarq $0x4, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8152
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8205
movq %rbp, %rdi
movq %r12, %rsi
callq 0x72a2
testq %rax, %rax
jne 0x6e59
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x7358
testb %al, %al
jne 0x6e24
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
movq 0x10(%rsp), %rdx
callq 0x6cea
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x6e70
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x53e0
leaq 0x20(%rsp), %rdi
callq 0x787c
movq (%rsp), %rcx
movq (%r13), %r13
cmpq %rcx, %r13
jne 0x6d61
jmp 0x6fad
movq %r14, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x64ca
movq %rax, 0x78(%rsp)
movb %dl, 0x80(%rsp)
testb $0x1, %dl
je 0x6fad
movq %r14, %rdi
movq %rax, %rsi
callq 0x65ca
leaq 0x78(%rsp), %rdi
callq 0x663c
movq 0x18(%rbp), %r15
addq $0x8, %rbp
cmpq %rbp, %r15
je 0x6fad
leaq 0x60(%r14), %rax
movq %rax, (%rsp)
leaq 0xa8(%rsp), %r12
movq 0x20(%r15), %rax
movl 0x38(%rax), %ecx
cmpl 0x80(%rax), %ecx
jg 0x6f99
leaq 0x20(%r15), %rbx
movq 0x90(%r14), %r13
movq 0xa8(%r14), %rax
movups 0x70(%r14), %xmm0
movaps %xmm0, 0x20(%rsp)
movups 0x80(%r14), %xmm0
movaps %xmm0, 0x30(%rsp)
movq %r13, 0xa8(%rsp)
movups 0x98(%r14), %xmm0
movups %xmm0, 0xb0(%rsp)
movq %rax, 0xc0(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x7aef
cmpq 0xc8(%rsp), %r13
jne 0x6f99
movq 0x90(%r14), %rax
movq 0xa0(%r14), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x6f8d
movq (%rbx), %rcx
movq %rcx, (%rax)
addq $0x8, 0x90(%r14)
jmp 0x6f99
movq (%rsp), %rdi
movq %rbx, %rsi
callq 0x7d54
movq %r15, %rdi
callq 0x54b0
movq %rax, %r15
cmpq %rbp, %rax
jne 0x6ee8
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x30, %edi
callq 0x51e0
movq %rax, %rbx
leaq 0x98(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1f1a9(%rip), %rsi     # 0x26188
leaq 0x1f1bc(%rip), %rdx     # 0x261a2
leaq 0x88(%rsp), %rdi
callq 0x74e8
movl $0x0, (%rbx)
leaq 0x8(%rbx), %rdi
movq %rbx, %rax
addq $0x18, %rax
movq %rax, 0x8(%rbx)
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
addq %rsi, %rdx
movb $0x1, %bpl
callq 0x757e
movl $0xb4, 0x28(%rbx)
xorl %ebp, %ebp
leaq 0x2da1d(%rip), %rsi     # 0x34a50
leaq 0x410(%rip), %rdx       # 0x744a
movq %rbx, %rdi
callq 0x5680
movq %rax, %r14
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x7062
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x53e0
testb %bpl, %bpl
jne 0x706c
jmp 0x7096
movq %rax, %r14
movq %rbx, %rdi
callq 0x5300
jmp 0x7096
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x787c
jmp 0x7096
jmp 0x7089
jmp 0x7089
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x709e
movq %r14, %rdi
callq 0x56a0