// File: /workspace/github_cpp_makefile_star2_O3/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), %rdx
cmpb $0x0, 0x982(%rdx)
jle 0x26277
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r14
movl 0xd0(%rsi), %eax
testl %eax, %eax
jle 0x2640b
movq %rdi, %r13
xorl %r8d, %r8d
xorl %r9d, %r9d
movq 0xd8(%r14), %rcx
movq (%rcx,%r8,8), %r15
cmpl $0x0, 0x4(%r15)
jne 0x263f2
movl (%r15), %ecx
addl %ecx, %r9d
cmpl $0x2, %ecx
jl 0x263f2
movl %r9d, 0xc(%rsp)
movq %r8, 0x18(%rsp)
movl $0x1, %r10d
movq 0x870(%rdx), %rax
movq 0x8a8(%rdx), %r8
movq 0x10(%r15), %r9
movslq (%r9,%r10,4), %r9
movsbq (%r8,%r9), %r8
movq %r8, 0x20(%rsp)
movb (%rax,%r9), %r12b
movl %r9d, 0x8(%r15)
movb 0x8b8(%rdx), %al
testb %al, %al
jle 0x263d2
xorl %ebx, %ebx
movq %r10, 0x10(%rsp)
testb %al, %al
jle 0x263b9
xorl %ebp, %ebp
movq 0x30(%r15), %rax
movq (%rax,%r10,8), %rax
movsd (%rax,%rbp,8), %xmm0
movsd %xmm0, (%rsp)
movsd 0xd5c9(%rip), %xmm0     # 0x338f0
testb %r12b, %r12b
js 0x26346
movq (%r13), %rax
movsbl %r12b, %ecx
movsbl %bpl, %edx
movq %r13, %rdi
movq %r15, %rsi
callq *0x20(%rax)
movq 0x10(%rsp), %r10
movsd (%rsp), %xmm1
mulsd %xmm0, %xmm1
movq 0x28(%r15), %rax
movq -0x8(%rax,%r10,8), %rax
mulsd (%rax,%rbx,8), %xmm1
movsd %xmm1, (%rsp)
movsd 0x48(%r15), %xmm0
callq 0x8df8
movq 0x10(%rsp), %r10
movsd (%rsp), %xmm1
divsd %xmm0, %xmm1
movq 0x60(%r14), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax,%rbx,8), %rax
movsd (%rax,%rbp,8), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rbp,8)
incq %rbp
movq 0x88(%r13), %rdx
movb 0x8b8(%rdx), %al
movsbq %al, %rcx
cmpq %rcx, %rbp
jl 0x2630d
jmp 0x263c3
movb 0x8b8(%rdx), %al
movsbq %al, %rcx
incq %rbx
cmpq %rcx, %rbx
jl 0x26303
movl (%r15), %ecx
incq %r10
movslq %ecx, %rax
cmpq %rax, %r10
jl 0x262c6
movl 0xd0(%r14), %eax
movq 0x18(%rsp), %r8
movl 0xc(%rsp), %r9d
incq %r8
movslq %eax, %rcx
cmpq %rcx, %r8
jl 0x26291
xorps %xmm0, %xmm0
cvtsi2sd %r9d, %xmm0
jmp 0x2640f
xorpd %xmm0, %xmm0
cmpb $0x0, 0x42(%rdx)
jle 0x26268
movq %r14, %rdi
movl $0x2, %esi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd890