// File: /workspace/github_cpp_makefile_star2_O1/myudelson[P]hmm-scalable/HMMProblemSlicedAB.cpp
// Function: HMMProblemSlicedAB::setGradA(FitBitSlicedAB*)
void HMMProblemSlicedAB::setGradA (FitBitSlicedAB *fb){
    if(this->p->block_fitting[1]>0) return;
    NDAT t, ndat = 0;
    NPAR o, i, j, z;
    struct data* dt;
    for(NCAT x=0; x<fb->xndat; x++) {
        dt = fb->x_data[x];
        if( dt->cnt!=0 ) continue;
        ndat += dt->n;
        for(t=1; t<dt->n; t++) {
            z = this->p->dat_slice[ dt->ix[t] ];
            //            if(z == fb->tag) { // tag contains the current slice
            o = this->p->dat_obs[ dt->ix[t] ];//->get( dt->ix[t] );
            dt->t = dt->ix[t]; // global state pointer
            for(i=0; i<this->p->nS; i++)
                for(j=0; j<this->p->nS; j++)
                    fb->gradA[z][i][j] -= dt->beta[t][j] * ((o<0)?1:getB(dt,j,o)) * dt->alpha[t-1][i] / safe0num(dt->p_O_param);
            //            }
        }
    }
    // penalty
    if( this->p->Cslices>0 )
        fb->addL2Penalty(FBV_A, this->p, (NUMBER)ndat);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq 0x88(%rdi), %rax
cmpb $0x0, 0x982(%rax)
jle 0x266eb
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %rbx
movq %rdi, %r14
cmpl $0x0, 0xd0(%rsi)
jle 0x26892
xorl %ecx, %ecx
xorl %edx, %edx
movq 0xd8(%rbx), %rax
movq (%rax,%rcx,8), %r15
cmpl $0x0, 0x4(%r15)
jne 0x26876
movl (%r15), %eax
addl %eax, %edx
cmpl $0x2, %eax
jl 0x26876
movl %edx, 0x10(%rsp)
movq %rcx, 0x18(%rsp)
movl $0x1, %r13d
movq 0x88(%r14), %rax
movq 0x870(%rax), %rcx
movq 0x8a8(%rax), %rax
movq 0x10(%r15), %rdx
movslq (%rdx,%r13,4), %rdx
movsbq (%rax,%rdx), %rax
movq %rax, 0x20(%rsp)
movb (%rcx,%rdx), %al
movb %al, 0x7(%rsp)
movl %edx, 0x8(%r15)
movq 0x88(%r14), %rax
cmpb $0x0, 0x8b8(%rax)
jle 0x2685e
movsbl 0x7(%rsp), %eax
movl %eax, 0x14(%rsp)
xorl %ebp, %ebp
movq 0x88(%r14), %rax
cmpb $0x0, 0x8b8(%rax)
jle 0x26843
xorl %r12d, %r12d
movq 0x30(%r15), %rax
movq (%rax,%r13,8), %rax
movsd (%rax,%r12,8), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0xe137(%rip), %xmm0     # 0x348f0
cmpb $0x0, 0x7(%rsp)
js 0x267d4
movq (%r14), %rax
movsbl %r12b, %edx
movq %r14, %rdi
movq %r15, %rsi
movl 0x14(%rsp), %ecx
callq *0x20(%rax)
movsd 0x8(%rsp), %xmm1
mulsd %xmm0, %xmm1
movq 0x28(%r15), %rax
movq -0x8(%rax,%r13,8), %rax
mulsd (%rax,%rbp,8), %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x48(%r15), %xmm0
callq 0x8d88
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movq 0x60(%rbx), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax,%rbp,8), %rax
movsd (%rax,%r12,8), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rax,%r12,8)
incq %r12
movq 0x88(%r14), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %r12
jl 0x2679d
incq %rbp
movq 0x88(%r14), %rax
movsbq 0x8b8(%rax), %rax
cmpq %rax, %rbp
jl 0x26786
incq %r13
movslq (%r15), %rax
cmpq %rax, %r13
jl 0x26735
movq 0x18(%rsp), %rcx
movl 0x10(%rsp), %edx
incq %rcx
movslq 0xd0(%rbx), %rax
cmpq %rax, %rcx
jl 0x26702
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
jmp 0x26896
xorpd %xmm0, %xmm0
movq 0x88(%r14), %rdx
cmpb $0x0, 0x42(%rdx)
jle 0x266dc
movq %rbx, %rdi
movl $0x2, %esi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd866