// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
movq %rdi, %r14
movq 0x50(%rdi), %rax
movq 0x50(%rax), %rax
testq %rax, %rax
movq %rdx, 0x8(%rsp)
je 0x6d55
callq *%rax
movq 0x8(%rsp), %rcx
testb %al, %al
jne 0x6fff
cmpq %rcx, 0x58(%r14)
movq %rbx, 0x10(%rsp)
je 0x6ec6
movq (%rcx), %r13
cmpq %rcx, %r13
je 0x6fed
leaq 0x58(%rsp), %r12
leaq 0x30(%rbx), %rax
movq %rax, 0x20(%rsp)
leaq 0xb0(%r14), %rbp
leaq 0x18(%rcx), %rax
movq %rax, 0x18(%rsp)
movq 0x10(%r13), %rdx
cmpb $0x0, 0x48(%rdx)
jne 0x6eb4
movq %r14, %rdi
movq %rbx, %rsi
callq 0x63b8
movq 0x8(%rsp), %rcx
testb %al, %al
je 0x6eb4
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x772a
movq %r12, %rdi
movq 0x20(%rsp), %rsi
callq 0x76b2
movb 0x48(%rbx), %al
movb %al, 0x70(%rsp)
movq 0x10(%r13), %rax
movq 0x18(%rax), %rbx
addq $0x8, %rax
cmpq %rax, %rbx
je 0x6e0f
movq 0x20(%rbx), %rax
cmpq 0x48(%r14), %rax
je 0x6dfe
leaq 0x20(%rbx), %rsi
leaq 0x28(%rsp), %rdi
callq 0x7510
movq %rbx, %rdi
callq 0x54b0
movq %rax, %rbx
movq 0x10(%r13), %rax
jmp 0x6ddd
movq 0x58(%rsp), %rbx
movq 0x60(%rsp), %r15
cmpq %r15, %rbx
je 0x6e4b
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 0x8232
movq %rbx, %rdi
movq %r15, %rsi
callq 0x82e5
movb $0x1, %bl
movq %rbp, %rdi
movq %r12, %rsi
callq 0x72e4
testq %rax, %rax
jne 0x6e72
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x73c7
movl %eax, %ebx
testb %al, %al
jne 0x6e4d
testb $0x1, %bl
jne 0x6e89
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0x6d1a
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x6ea0
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x53e0
leaq 0x28(%rsp), %rdi
callq 0x791a
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %rcx
movq (%r13), %r13
cmpq %rcx, %r13
jne 0x6d8e
jmp 0x6fed
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x648c
movq %rax, 0x78(%rsp)
movb %dl, 0x80(%rsp)
testb $0x1, %dl
je 0x6fed
movq %r14, %rdi
movq %rax, %rsi
callq 0x65ac
leaq 0x78(%rsp), %rdi
callq 0x661e
movq 0x10(%rsp), %rax
movq 0x18(%rax), %r15
addq $0x8, %rax
cmpq %rax, %r15
je 0x6fed
movq %rax, %rbp
leaq 0x60(%r14), %rax
movq %rax, 0x8(%rsp)
leaq 0xa8(%rsp), %r12
movq 0x20(%r15), %rax
movl 0x38(%rax), %ecx
cmpl 0x80(%rax), %ecx
jg 0x6fd9
leaq 0x20(%r15), %rbx
movq 0x90(%r14), %r13
movups 0x70(%r14), %xmm0
movups 0x80(%r14), %xmm1
movups 0x98(%r14), %xmm2
movq 0xa8(%r14), %rax
movups %xmm0, 0x28(%rsp)
movups %xmm1, 0x38(%rsp)
movq %r13, 0xa8(%rsp)
movups %xmm2, 0xb0(%rsp)
movq %rax, 0xc0(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x7b8b
cmpq 0xc8(%rsp), %r13
jne 0x6fd9
movq 0x90(%r14), %rax
movq 0xa0(%r14), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x6fcc
movq (%rbx), %rcx
movq %rcx, (%rax)
addq $0x8, 0x90(%r14)
jmp 0x6fd9
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x7e36
movq %r15, %rdi
callq 0x54b0
movq %rax, %r15
cmpq %rbp, %rax
jne 0x6f27
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 0x1f169(%rip), %rsi     # 0x26188
leaq 0x1f17c(%rip), %rdx     # 0x261a2
leaq 0x88(%rsp), %rdi
callq 0x7592
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 0x7622
movl $0xb4, 0x28(%rbx)
xorl %ebp, %ebp
leaq 0x2d99d(%rip), %rsi     # 0x34a10
leaq 0x47a(%rip), %rdx       # 0x74f4
movq %rbx, %rdi
callq 0x5680
movq %rax, %r14
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x70aa
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x53e0
jmp 0x70aa
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x70d9
movq %rbx, %rdi
callq 0x5300
jmp 0x70d9
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x791a
jmp 0x70d9
jmp 0x70cc
jmp 0x70cc
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x70e2
movq %r14, %rdi
callq 0x56a0
nop