// File: myudelson[P]hmm-scalable/FitBit.cpp
// Function: FitBit::doLog10ScaleGentleByRow(FIT_BIT_SLOT)
void FitBit::doLog10ScaleGentleByRow(enum FIT_BIT_SLOT fbs) {
	//    // fbs - gradient or direction
	NUMBER *a_PI = NULL;
	NUMBER **a_A = NULL;
	NUMBER **a_B = NULL;
	get(fbs, a_PI, a_A, a_B);
	
	
	NPAR nS = this->nS, nO = this->nO;
	NPAR n_scales = (NPAR)2*nS + 1;
	NUMBER* scales = Calloc(NUMBER, n_scales);
	
	
	if(this->pi != NULL)
		scales[0] = doLog10Scale1DGentle(a_PI, this->pi, nS);
	if(this->A  != NULL) {
		for(NPAR i=0; i<nS; i++) {
			scales[i+1] = doLog10Scale1DGentle(a_A[i], this->A[i], nS);
		}
	}
	if(this->B  != NULL) {
		for(NPAR i=0; i<nS; i++) {
			scales[i+1+nS] = doLog10Scale1DGentle(a_B[i], this->B[i], nO);
		}
	}
	
	for(NPAR i=0; i<nS; i++) {
		if(this->pi != NULL) { a_PI[i] *= scales[0]; }
		if(this->A  != NULL) for(NPAR j=0; j<nS; j++) { a_A[i][j] *= scales[i+1]; }
		if(this->B  != NULL) for(NPAR m=0; m<nO; m++) { a_B[i][m] *= scales[i+1+nS]; }
	}
	
	free(scales);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x48(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movl -0xc(%rbp), %esi
leaq -0x18(%rbp), %rdx
leaq -0x20(%rbp), %rcx
leaq -0x28(%rbp), %r8
callq 0xe2e0
movq -0x48(%rbp), %rax
movb 0x1(%rax), %cl
movb %cl, -0x29(%rbp)
movb (%rax), %al
movb %al, -0x2a(%rbp)
movsbl -0x29(%rbp), %eax
shll %eax
addl $0x1, %eax
movb %al, -0x2b(%rbp)
movsbq -0x2b(%rbp), %rdi
movl $0x8, %esi
callq 0x5180
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0x38(%rbp)
cmpq $0x0, 0x10(%rax)
je 0xf02c
movq -0x48(%rbp), %rax
movq -0x18(%rbp), %rdi
movq 0x10(%rax), %rsi
movsbl -0x29(%rbp), %edx
callq 0xa590
movq -0x38(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xf08d
movb $0x0, -0x39(%rbp)
movsbl -0x39(%rbp), %eax
movsbl -0x29(%rbp), %ecx
cmpl %ecx, %eax
jge 0xf08b
movq -0x48(%rbp), %rax
movq -0x20(%rbp), %rcx
movsbq -0x39(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movq 0x18(%rax), %rax
movsbq -0x39(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movsbl -0x29(%rbp), %edx
callq 0xa590
movq -0x38(%rbp), %rax
movsbl -0x39(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movb -0x39(%rbp), %al
addb $0x1, %al
movb %al, -0x39(%rbp)
jmp 0xf03b
jmp 0xf08d
movq -0x48(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xf0f4
movb $0x0, -0x3a(%rbp)
movsbl -0x3a(%rbp), %eax
movsbl -0x29(%rbp), %ecx
cmpl %ecx, %eax
jge 0xf0f2
movq -0x48(%rbp), %rax
movq -0x28(%rbp), %rcx
movsbq -0x3a(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movq 0x20(%rax), %rax
movsbq -0x3a(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movsbl -0x2a(%rbp), %edx
callq 0xa590
movq -0x38(%rbp), %rax
movsbl -0x3a(%rbp), %ecx
addl $0x1, %ecx
movsbl -0x29(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movb -0x3a(%rbp), %al
addb $0x1, %al
movb %al, -0x3a(%rbp)
jmp 0xf09c
jmp 0xf0f4
movb $0x0, -0x3b(%rbp)
movsbl -0x3b(%rbp), %eax
movsbl -0x29(%rbp), %ecx
cmpl %ecx, %eax
jge 0xf1ef
movq -0x48(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xf12e
movq -0x38(%rbp), %rax
movsd (%rax), %xmm0
movq -0x18(%rbp), %rax
movsbq -0x3b(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xf184
movb $0x0, -0x3c(%rbp)
movsbl -0x3c(%rbp), %eax
movsbl -0x29(%rbp), %ecx
cmpl %ecx, %eax
jge 0xf182
movq -0x38(%rbp), %rax
movsbl -0x3b(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movsbq -0x3b(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x3c(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0x3c(%rbp), %al
addb $0x1, %al
movb %al, -0x3c(%rbp)
jmp 0xf13d
jmp 0xf184
movq -0x48(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xf1e0
movb $0x0, -0x3d(%rbp)
movsbl -0x3d(%rbp), %eax
movsbl -0x2a(%rbp), %ecx
cmpl %ecx, %eax
jge 0xf1de
movq -0x38(%rbp), %rax
movsbl -0x3b(%rbp), %ecx
addl $0x1, %ecx
movsbl -0x29(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movsbq -0x3b(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x3d(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0x3d(%rbp), %al
addb $0x1, %al
movb %al, -0x3d(%rbp)
jmp 0xf193
jmp 0xf1e0
jmp 0xf1e2
movb -0x3b(%rbp), %al
addb $0x1, %al
movb %al, -0x3b(%rbp)
jmp 0xf0f8
movq -0x38(%rbp), %rdi
callq 0x5380
addq $0x50, %rsp
popq %rbp
retq
nop