// File: WShabti-Team[P]WShabtiPict/wshabtilib/api/model.cpp
// Function: pictcore::Model::generateMixedOrder()
void Model::generateMixedOrder()
{
    GlobalZerosCount = 0;
    // turn each submodel's output into a PseudoParameter and add to model
    for( SubmodelCollection::iterator im = m_submodels.begin(); im != m_submodels.end(); ++im )
    {
        // make a pseudo-parameter from the submodel, add to this model
        // ignore first arg (order) - it'll be reset below
        Parameter *pseudo = new PseudoParameter( m_order, ++m_lastParamId, *im );
        AddParameter( pseudo );
    }

    // initialize combinations based on contents of m_parameters
    vector<Combination*> vecCombo;

    // sort parameter vector by order to generate parameter combinations
    sort( m_parameters.begin(), m_parameters.end(), GreaterThanByOrder() );

    bool r1 = mapExclusionsToPseudoParameters();
    bool r2 = excludeConflictingParamValues();
    // TODO: do we realy need to derive if the real exclusions were mapped?
    //       exclusions for conflicting param values don't conflict with one another
    if( r1 || r2 ) deriveSubmodelExclusions();

    mapRowSeedsToPseudoParameters();

    // for (each order, from highest to lowest)
    //   for every N-way combinations of these and higher-order parameters
    for( ParamCollection::iterator lastOrder = m_parameters.begin(); lastOrder != m_parameters.end(); /*increment in mid-loop*/ )
    {
        int order = ( *lastOrder )->GetOrder();
        // Get the range of each order
        while( lastOrder != m_parameters.end() && ( *lastOrder )->GetOrder() == order )
            ++lastOrder;
        Combination baseCombo( this );
        choose( m_parameters.begin(), lastOrder, order, order, baseCombo, vecCombo );
    }

    gcd( vecCombo );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
movl $0x0, (%rdi)
addq $0x50, %rdi
callq 0x1ca90
movq %rax, -0x10(%rbp)
movq -0xd8(%rbp), %rdi
addq $0x50, %rdi
callq 0x1caf0
movq %rax, -0x18(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x1cac0
testb $0x1, %al
jne 0x18a67
jmp 0x18b1a
movl $0xd8, %edi
callq 0x75e0
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0xe8(%rbp)
movq %rcx, -0xf0(%rbp)
movl 0x108(%rax), %ecx
movl %ecx, -0xe0(%rbp)
movl 0x130(%rax), %ecx
incl %ecx
movl %ecx, -0xdc(%rbp)
movl %ecx, 0x130(%rax)
leaq -0x10(%rbp), %rdi
callq 0x1cb20
movq -0xe8(%rbp), %rdi
movl -0xe0(%rbp), %esi
movl -0xdc(%rbp), %edx
movq (%rax), %rcx
callq 0x2d8b0
jmp 0x18acf
movq -0xd8(%rbp), %rdi
movq -0xf0(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rsi
callq 0x1c940
leaq -0x10(%rbp), %rdi
callq 0x1cc90
jmp 0x18a3d
movq -0xf0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0xd8, %esi
callq 0x7600
jmp 0x18d6d
leaq -0x48(%rbp), %rdi
callq 0x1ccd0
movq -0xd8(%rbp), %rdi
addq $0x8, %rdi
movq %rdi, -0xf8(%rbp)
callq 0x8c90
movq -0xf8(%rbp), %rdi
movq %rax, -0x50(%rbp)
callq 0x8cc0
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x1cdc0
jmp 0x18b5d
movq -0xd8(%rbp), %rdi
callq 0x1a270
movb %al, -0xf9(%rbp)
jmp 0x18b71
movq -0xd8(%rbp), %rdi
movb -0xf9(%rbp), %al
andb $0x1, %al
movb %al, -0x5a(%rbp)
callq 0x18300
movb %al, -0xfa(%rbp)
jmp 0x18b90
movb -0xfa(%rbp), %al
andb $0x1, %al
movb %al, -0x5b(%rbp)
testb $0x1, -0x5a(%rbp)
jne 0x18ba7
testb $0x1, -0x5b(%rbp)
je 0x18bc8
movq -0xd8(%rbp), %rdi
callq 0x1aa10
jmp 0x18bb5
jmp 0x18bc8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x18d64
movq -0xd8(%rbp), %rdi
callq 0x1ac90
jmp 0x18bd6
movq -0xd8(%rbp), %rdi
addq $0x8, %rdi
callq 0x8c90
movq %rax, -0x68(%rbp)
movq -0xd8(%rbp), %rdi
addq $0x8, %rdi
callq 0x8cc0
movq %rax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8cf0
testb $0x1, %al
jne 0x18c14
jmp 0x18d40
leaq -0x68(%rbp), %rdi
callq 0x8d30
movq (%rax), %rdi
callq 0x1b7b0
movl %eax, -0x100(%rbp)
jmp 0x18c2d
movl -0x100(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0xd8(%rbp), %rdi
addq $0x8, %rdi
callq 0x8cc0
movq %rax, -0x80(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x8cf0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x101(%rbp)
jne 0x18c68
jmp 0x18c93
leaq -0x68(%rbp), %rdi
callq 0x8d30
movq (%rax), %rdi
callq 0x1b7b0
movl %eax, -0x108(%rbp)
jmp 0x18c81
movl -0x108(%rbp), %eax
cmpl -0x74(%rbp), %eax
sete %al
movb %al, -0x101(%rbp)
movb -0x101(%rbp), %al
testb $0x1, %al
jne 0x18c9f
jmp 0x18caa
leaq -0x68(%rbp), %rdi
callq 0x8d70
jmp 0x18c36
movq -0xd8(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x8b60
jmp 0x18cbf
movq -0xd8(%rbp), %rdi
addq $0x8, %rdi
callq 0x8c90
movq -0xd8(%rbp), %rdi
movq %rax, -0xc8(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xd0(%rbp)
movl -0x74(%rbp), %r8d
movq -0xc8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
movq %rsp, %rax
leaq -0x48(%rbp), %rcx
movq %rcx, (%rax)
leaq -0xc0(%rbp), %r9
movl %r8d, %ecx
callq 0x15100
jmp 0x18d15
leaq -0xc0(%rbp), %rdi
callq 0x8bd0
jmp 0x18bea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x8bd0
jmp 0x18d64
movq -0xd8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x15380
jmp 0x18d52
leaq -0x48(%rbp), %rdi
callq 0x1cd40
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x1cd40
movq -0x28(%rbp), %rdi
callq 0x79d0
nopw %cs:(%rax,%rax)