// File: myudelson[P]hmm-scalable/HMMProblemSt.cpp
// Function: HMMProblemSt::createGradientScaleSimplexAffordances(FitBitSt*)
void HMMProblemSt::createGradientScaleSimplexAffordances(FitBitSt *fb) {
    NCAT nK = this->task->nK, nO = this->task->nO, nS = this->task->nS, i;
    fb->sclsmplx_n = nK * (1 + 2 * nS);
    fb->sclsmplx_offsets = init1D<NCAT>(fb->sclsmplx_n);
    fb->sclsmplx_sizes = init1D<NPAR>(fb->sclsmplx_n);
    fb->sclsmplx_blocks = init1D<NCAT>(fb->sclsmplx_n);
    fb->param_blocks = init1D<NCAT>(fb->nPARAM);
    fb->sclsmplx_bound_offsets = init1D<NCAT>(fb->sclsmplx_n);
    NCAT c = 0;
    NDAT offset = 0;
    for(NCAT k=0; k<nK; k++) {
        for(i=0; i<(1+nS); i++) {
            fb->sclsmplx_offsets[c] = offset;
            fb->sclsmplx_bound_offsets[c] = i*nS;
            fb->sclsmplx_sizes[c] = (NPAR)nS;
            fb->sclsmplx_blocks[c] = k; // which [skill] block this simplex is part of
            offset+=nS;
            c++;
        }
        for(i=0; i<nS; i++) {
            fb->sclsmplx_offsets[c] = offset;
            fb->sclsmplx_bound_offsets[c] = (1+nS)*nS + i*nO;
            fb->sclsmplx_sizes[c] = (NPAR)nO;
            fb->sclsmplx_blocks[c] = k; // which [skill] block this simplex is part of
            offset+=nO;
            c++;
        }
        for(i=(k*this->skill1_n);i<((1+k)*this->skill1_n);i++) fb->param_blocks[i]=k;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq 0x68(%rax), %rcx
movl 0x908(%rcx), %ecx
movl %ecx, -0x14(%rbp)
movq 0x68(%rax), %rcx
movsbl 0x901(%rcx), %ecx
movl %ecx, -0x18(%rbp)
movq 0x68(%rax), %rax
movsbl 0x900(%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x14(%rbp), %ecx
movl -0x1c(%rbp), %eax
shll %eax
addl $0x1, %eax
imull %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc0(%rax)
movq -0x10(%rbp), %rax
movl 0xc0(%rax), %edi
callq 0x190c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x98(%rax)
movq -0x10(%rbp), %rax
movl 0xc0(%rax), %edi
callq 0xf360
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa8(%rax)
movq -0x10(%rbp), %rax
movl 0xc0(%rax), %edi
callq 0x190c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xb0(%rax)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %edi
callq 0x190c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xb8(%rax)
movq -0x10(%rbp), %rax
movl 0xc0(%rax), %edi
callq 0x190c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa0(%rax)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x16092
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x15fa6
movl -0x28(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x20(%rbp), %edx
imull -0x1c(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x1c(%rbp), %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rax
movslq -0x24(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x15f1f
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x1603f
movl -0x28(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x1c(%rbp), %edx
addl $0x1, %edx
imull -0x1c(%rbp), %edx
movl -0x20(%rbp), %eax
imull -0x18(%rbp), %eax
addl %eax, %edx
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rax
movslq -0x24(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x15fad
movq -0x38(%rbp), %rcx
movl -0x2c(%rbp), %eax
imull 0x38(%rcx), %eax
movl %eax, -0x20(%rbp)
movq -0x38(%rbp), %rdx
movl -0x20(%rbp), %eax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
imull 0x38(%rdx), %ecx
cmpl %ecx, %eax
jge 0x16082
movl -0x2c(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0xb8(%rax), %rax
movslq -0x20(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1604d
jmp 0x16084
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x15f0c
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)