// File: WShabti-Team[P]WShabtiPict/wshabtilib/api/model.cpp
// Function: pictcore::Model::choose(__gnu_cxx::__normal_iterator<pictcore::Parameter**, std::vector<pictcore::Parameter*, std::allocator<pictcore::Parameter*>>>, __gnu_cxx::__normal_iterator<pictcore::Parameter**, std::vector<pictcore::Parameter*, std::allocator<pictcore::Parameter*>>>, int, int, pictcore::Combination&, std::vector<pictcore::Combination*, std::allocator<pictcore::Combination*>>&)
void Model::choose( ParamCollection::iterator first,     // the iterators apply to current stage of recursion
                    ParamCollection::iterator last,
                    int                       order,     // number of items to choose in the range from first to last
                    int                       realOrder, // real order of this combination
                    Combination&              baseCombo,
                    ComboCollection&          vecCombo ) // where to put result vector
{
    assert( order >= 0 && order <= realOrder );
    assert( realOrder > 0 );

    if( 0 == order )
    {
        // add the current combination to the result vector
        Combination *combo = new Combination( this );
        combo->Assign( baseCombo );
        vecCombo.push_back( combo );

        // add the combination to all the parameters
        // set up its bit vector
        // initialize the zero count
        // add to the global zero count Combination::GlobalZero
        int size = 1;
        for( int n = 0; n < combo->GetParameterCount(); ++n )
        {
            // link all parameters in the combination to this combination
            ( *combo )[ n ].LinkCombination( combo );
            // determine size of bit vector
            size *= ( *combo )[ n ].GetValueCount();
        }

        // set size of combination's bit vector
        combo->SetMapSize( size );
        return;
    }

    // iterate over the possible first element in the combination
    // the three parts of the loop conditional are all necessary!
    // first part makes sure we have enough elements for the current combination
    // second part decrements the loop variable, then ensures that we don't emit
    //   subsets of higher-order combinations
    while( distance( first, last ) >= order && ( ( *( --last ) )->GetOrder() == order || order != realOrder ) )
    {
        // add the parameter to the combination
        baseCombo.PushParameter( *last );

        // recurse over remaining elements
        choose( first, last, order - 1, realOrder, baseCombo, vecCombo );
        baseCombo.PopParameter();
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0x10(%rbp), %rax
movq %rsi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x69(%rbp)
jl 0x15145
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
setle %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x1514e
jmp 0x15150
jmp 0x1516f
leaq 0x4f4c9(%rip), %rdi     # 0x64620
leaq 0x4f4e3(%rip), %rsi     # 0x64641
movl $0x22, %edx
leaq 0x4f4f0(%rip), %rcx     # 0x6465a
callq 0x7450
cmpl $0x0, -0x20(%rbp)
jle 0x15177
jmp 0x15196
leaq 0x4f55b(%rip), %rdi     # 0x646d9
leaq 0x4f4bc(%rip), %rsi     # 0x64641
movl $0x23, %edx
leaq 0x4f4c9(%rip), %rcx     # 0x6465a
callq 0x7450
xorl %eax, %eax
cmpl -0x1c(%rbp), %eax
jne 0x1527e
movl $0x40, %edi
callq 0x75e0
movq -0x78(%rbp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x80(%rbp)
callq 0x8b60
jmp 0x151c0
movq -0x80(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x1b630
movq 0x10(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1b6a0
movl $0x1, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x30(%rbp), %rdi
callq 0x92c0
movl %eax, %ecx
movl -0x84(%rbp), %eax
cmpl %ecx, %eax
jge 0x1526b
movq -0x30(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x1b710
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x1b740
movq -0x30(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x1b710
movq %rax, %rdi
callq 0x8eb0
imull -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x151f0
movq -0x80(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x40, %esi
callq 0x7600
jmp 0x15371
movq -0x30(%rbp), %rdi
movl -0x40(%rbp), %esi
xorl %edx, %edx
callq 0x7f60
jmp 0x15368
jmp 0x15280
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x1b770
movq %rax, %rcx
movslq -0x1c(%rbp), %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x85(%rbp)
jl 0x152f4
leaq -0x10(%rbp), %rdi
callq 0x9340
movq %rax, %rdi
callq 0x8d30
movq (%rax), %rdi
callq 0x1b7b0
movl %eax, %ecx
movb $0x1, %al
cmpl -0x1c(%rbp), %ecx
movb %al, -0x86(%rbp)
je 0x152e8
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
setne %al
movb %al, -0x86(%rbp)
movb -0x86(%rbp), %al
movb %al, -0x85(%rbp)
movb -0x85(%rbp), %al
testb $0x1, %al
jne 0x15300
jmp 0x15368
movq -0x28(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x8d30
movq -0x90(%rbp), %rdi
movq (%rax), %rsi
callq 0x1b7d0
movq -0x78(%rbp), %rdi
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movl -0x20(%rbp), %r8d
movq -0x28(%rbp), %r9
movq 0x10(%rbp), %rax
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq %rax, (%rsp)
callq 0x15100
movq -0x28(%rbp), %rdi
callq 0x1b800
jmp 0x15280
addq $0xa0, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x79d0
nopw (%rax,%rax)