// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x68(%rdi), %rax
movl 0x908(%rax), %ebp
movb 0x900(%rax), %r12b
movb 0x901(%rax), %al
movb %al, (%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, 0x4(%rsp)
testl %ebp, %ebp
jle 0xe586
movsbl (%rsp), %eax
leal 0x1(%r13), %ecx
imull %r13d, %ecx
movl %ecx, (%rsp)
movl %r13d, %edx
notl %edx
movl %r13d, %esi
negl %esi
xorl %r10d, %r10d
xorl %edi, %edi
xorl %r8d, %r8d
movl %r10d, %r9d
testb %r12b, %r12b
js 0xe4f5
movslq %r8d, %r11
xorl %r10d, %r10d
xorl %r15d, %r15d
leal (%rdi,%r10), %ecx
movq 0x98(%rbx), %rbp
movl %ecx, (%rbp,%r11,4)
movq 0xa0(%rbx), %rcx
movl %r10d, (%rcx,%r11,4)
movq 0xa8(%rbx), %rcx
movb %r12b, (%rcx,%r11)
movq 0xb0(%rbx), %rcx
movl %r9d, (%rcx,%r11,4)
incq %r11
decl %r15d
addl %r13d, %r10d
cmpl %r15d, %edx
jne 0xe4b0
subl %r15d, %r8d
addl %r10d, %edi
testb %r12b, %r12b
jle 0xe543
movslq %r8d, %r11
xorl %r10d, %r10d
movl (%rsp), %r15d
movq 0x98(%rbx), %rcx
movl %edi, (%rcx,%r11,4)
movq 0xa0(%rbx), %rcx
movl %r15d, (%rcx,%r11,4)
movq 0xa8(%rbx), %rcx
movb %al, (%rcx,%r11)
movq 0xb0(%rbx), %rcx
movl %r9d, (%rcx,%r11,4)
addl %eax, %edi
incq %r11
decl %r10d
addl %eax, %r15d
cmpl %r10d, %esi
jne 0xe504
subl %r10d, %r8d
movl 0x38(%r14), %ecx
movl %ecx, %r15d
imull %r9d, %r15d
movslq %r9d, %r10
incq %r10
imull %r10d, %ecx
cmpl %ecx, %r15d
jge 0xe57b
movq 0xb8(%rbx), %r11
movslq %r15d, %r15
movl %r9d, (%r11,%r15,4)
incq %r15
movslq 0x38(%r14), %rcx
imulq %r10, %rcx
cmpq %rcx, %r15
jl 0xe567
cmpl 0x4(%rsp), %r10d
jne 0xe49f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop