// File: myudelson[P]hmm-scalable/HMMProblem.cpp
// Function: HMMProblem::setGradA(FitBit*)
void HMMProblem::setGradA (FitBit *fb){
    if(this->p->block_fitting[1]>0) return;
    NDAT t, ndat = 0;
    NPAR o, i, j;
    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++) {
            o = this->p->dat_obs[ dt->ix[t] ];//->get( dt->ix[t] );
            for(i=0; i<this->p->nS; i++)
                for(j=0; j<this->p->nS; j++)
                    fb->gradA[i][j] -= dt->beta[t][j] * ((o<0)?1:fb->B[j][o]) * dt->alpha[t-1][i] / safe0num(dt->p_O_param);
        }
    }
    if( this->p->Cslices>0 ) // penalty
        fb->addL2Penalty(FBV_A, this->p, (NUMBER)ndat);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq 0x88(%rax), %rax
movsbl 0x982(%rax), %eax
cmpl $0x0, %eax
jle 0x1bf90
jmp 0x1c197
movl $0x0, -0x18(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xe8(%rcx), %eax
jge 0x1c165
movq -0x10(%rbp), %rax
movq 0xf0(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x1bfd7
jmp 0x1c157
movq -0x28(%rbp), %rax
movl (%rax), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x1c155
movq -0x38(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x870(%rax), %rax
movq -0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq -0x14(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movb (%rax,%rcx), %al
movb %al, -0x19(%rbp)
movb $0x0, -0x1a(%rbp)
movq -0x38(%rbp), %rcx
movsbl -0x1a(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x1c145
movb $0x0, -0x1b(%rbp)
movq -0x38(%rbp), %rcx
movsbl -0x1b(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x1c136
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x1b(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x40(%rbp)
movsbl -0x19(%rbp), %eax
cmpl $0x0, %eax
jge 0x1c09c
movsd 0x33973(%rip), %xmm0    # 0x4fa08
movsd %xmm0, -0x48(%rbp)
jmp 0x1c0bc
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x1b(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x19(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x40(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
mulsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x1a(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x28(%rbp), %rax
movsd 0x48(%rax), %xmm0
callq 0x9a40
movsd -0x50(%rbp), %xmm1
divsd %xmm0, %xmm1
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movsbq -0x1a(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x1b(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0x1b(%rbp), %al
addb $0x1, %al
movb %al, -0x1b(%rbp)
jmp 0x1c047
jmp 0x1c138
movb -0x1a(%rbp), %al
addb $0x1, %al
movb %al, -0x1a(%rbp)
jmp 0x1c025
jmp 0x1c147
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1bfea
jmp 0x1c157
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1bf9e
movq -0x38(%rbp), %rax
movq 0x88(%rax), %rax
movsbl 0x42(%rax), %eax
cmpl $0x0, %eax
jle 0x1c197
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rdi
movq 0x88(%rax), %rdx
cvtsi2sdl -0x18(%rbp), %xmm0
movl $0x2, %esi
callq 0xf200
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)