// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x68(%rdi), %rax
movl 0x908(%rax), %ebp
movb 0x900(%rax), %r12b
movb 0x901(%rax), %al
movb %al, 0xc(%rsp)
movsbl %r12b, %r13d
leal 0x1(,%r13,2), %eax
imull %ebp, %eax
movl %eax, 0xc0(%rsi)
movslq %eax, %r15
movl $0x4, %esi
movq %r15, %rdi
callq 0x2110
movq %rax, 0x98(%rbx)
movl $0x1, %esi
movq %r15, %rdi
callq 0x2110
movq %rax, 0xa8(%rbx)
movl $0x4, %esi
movq %r15, %rdi
callq 0x2110
movq %rax, 0xb0(%rbx)
movslq 0xc(%rbx), %rdi
movl $0x4, %esi
callq 0x2110
movq %rax, 0xb8(%rbx)
movl $0x4, %esi
movq %r15, %rdi
callq 0x2110
movq %rax, 0xa0(%rbx)
movl %ebp, 0x14(%rsp)
testl %ebp, %ebp
jle 0xe6b9
movsbl 0xc(%rsp), %eax
leal 0x1(%r13), %ecx
imull %r13d, %ecx
movl %ecx, 0x10(%rsp)
movl %r13d, %edx
notl %edx
xorl %r10d, %r10d
movabsq $0x100000000, %rsi      # imm = 0x100000000
xorl %edi, %edi
xorl %ebp, %ebp
movl %r10d, %r8d
testb %r12b, %r12b
js 0xe676
movl %ebp, 0xc(%rsp)
movslq %ebp, %r15
movq %r15, %r10
shlq $0x20, %r10
xorl %ecx, %ecx
xorl %r11d, %r11d
addq %rsi, %r10
leal (%rdi,%rcx), %ebp
movq 0x98(%rbx), %r9
movl %ebp, (%r9,%r15,4)
movq 0xa0(%rbx), %r9
movl %ecx, (%r9,%r15,4)
movq 0xa8(%rbx), %r9
movb %r12b, (%r9,%r15)
movq 0xb0(%rbx), %r9
movl %r8d, (%r9,%r15,4)
incq %r15
decl %r11d
addl %r13d, %ecx
cmpl %r11d, %edx
jne 0xe5e0
addl %ecx, %edi
testb %r12b, %r12b
jle 0xe66f
sarq $0x20, %r10
movl 0x10(%rsp), %ecx
movl %r13d, %r9d
movq 0x98(%rbx), %r11
movl %edi, (%r11,%r10,4)
movq 0xa0(%rbx), %r11
movl %ecx, (%r11,%r10,4)
movq 0xa8(%rbx), %r11
movb %al, (%r11,%r10)
movq 0xb0(%rbx), %r11
movl %r8d, (%r11,%r10,4)
addl %eax, %edi
incq %r10
addl %eax, %ecx
decl %r9d
jne 0xe632
movl %r10d, %ebp
jmp 0xe676
movl 0xc(%rsp), %ebp
subl %r11d, %ebp
movl 0x38(%r14), %ecx
movl %ecx, %r11d
imull %r8d, %r11d
movslq %r8d, %r10
incq %r10
imull %r10d, %ecx
cmpl %ecx, %r11d
jge 0xe6ae
movq 0xb8(%rbx), %rcx
movslq %r11d, %r11
movl %r8d, (%rcx,%r11,4)
incq %r11
movslq 0x38(%r14), %r9
imulq %r10, %r9
cmpq %r9, %r11
jl 0xe69a
cmpl 0x14(%rsp), %r10d
jne 0xe5c1
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq