// File: /workspace/github_cpp_makefile_star2_O2/myudelson[P]hmm-scalable/FitBit.cpp
// Function: FitBit::doLog10ScaleGentle(FIT_BIT_SLOT)
void FitBit::doLog10ScaleGentle(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;
	NDAT n = (  (this->pi != NULL)*1 + (this->A != NULL)*nS + (this->B != NULL)*nO  ) * nS;
	NUMBER* grad = Calloc(NUMBER, n);
	NUMBER* par = Calloc(NUMBER, n);
	NDAT cpar = 0, cgrad = 0;
	for(NPAR i=0; i<nS; i++) {
		if(this->pi != NULL) { par[cpar++] = this->pi[i]; grad[cgrad++] = a_PI[i]; }
		if(this->A  != NULL) for(NPAR j=0; j<nS; j++) { par[cpar++] = this->A[i][j]; grad[cgrad++] = a_A[i][j]; }
		if(this->B  != NULL) for(NPAR m=0; m<nO; m++) { par[cpar++] = this->B[i][m]; grad[cgrad++] = a_B[i][m]; }
	}
	
	NUMBER scale = doLog10Scale1DGentle(grad, par, (NPAR)n);
	
	for(NPAR i=0; i<nS; i++) {
		if(this->pi != NULL) { a_PI[i] *= scale; }
		if(this->A  != NULL) for(NPAR j=0; j<nS; j++) { a_A[i][j] *= scale; }
		if(this->B  != NULL) for(NPAR m=0; m<nO; m++) { a_B[i][m] *= scale; }
	}
	free(grad);
	free(par);
	
	//	if(this->pi != NULL) doLog10Scale1DGentle(a_PI, this->pi, this->nS);
	//	if(this->A  != NULL) doLog10Scale2DGentle(a_A,  this->A,  this->nS, this->nS);
	//	if(this->B  != NULL) doLog10Scale2DGentle(a_B,  this->B,  this->nS, this->nO);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r12
leaq 0x50(%rsp), %rdx
andq $0x0, (%rdx)
leaq 0x48(%rsp), %rcx
andq $0x0, (%rcx)
leaq 0x40(%rsp), %r8
andq $0x0, (%r8)
callq 0x8876
movsbl 0x1(%r12), %r15d
movsbl (%r12), %edx
movl %edx, 0xc(%rsp)
movq 0x10(%r12), %rcx
movq 0x18(%r12), %rbx
xorl %r14d, %r14d
testq %rbx, %rbx
movl %r15d, %eax
cmovel %r14d, %eax
movq %rcx, 0x38(%rsp)
cmpq $0x1, %rcx
sbbl $-0x1, %eax
movq %r12, 0x30(%rsp)
movq 0x20(%r12), %r12
testq %r12, %r12
movl %edx, %ecx
cmovel %r14d, %ecx
addl %eax, %ecx
imull %r15d, %ecx
movl %ecx, 0x24(%rsp)
movslq %ecx, %r13
pushq $0x8
popq %rbp
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4120
movq %rax, 0x18(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4120
movq %rax, 0x10(%rsp)
leaq 0x50(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x28(%rsp)
leaq 0x48(%rsp), %rax
movq (%rax), %r13
leaq 0x40(%rsp), %rax
movq (%rax), %rbp
testb %r15b, %r15b
cmovlel %r14d, %r15d
movl 0xc(%rsp), %eax
testb %al, %al
cmovlel %r14d, %eax
movl %eax, %ecx
movslq %r15d, %r15
movl $0xff, %edx
movl %r15d, %eax
andl %edx, %eax
shll $0x3, %eax
movl %ecx, 0xc(%rsp)
andl %edx, %ecx
shll $0x3, %ecx
xorl %edx, %edx
xorl %esi, %esi
cmpq %r15, %r14
je 0x8e4d
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x8d95
movsd (%rdi,%r14,8), %xmm0
movslq %esi, %rdi
incl %esi
movq 0x10(%rsp), %r8
movsd %xmm0, (%r8,%rdi,8)
movq 0x28(%rsp), %rdi
movsd (%rdi,%r14,8), %xmm0
movslq %edx, %rdi
incl %edx
movq 0x18(%rsp), %r8
movsd %xmm0, (%r8,%rdi,8)
testq %rbx, %rbx
je 0x8ded
movslq %edx, %r8
movslq %esi, %rdi
movq 0x10(%rsp), %r9
leaq (%r9,%rdi,8), %rdi
movq 0x18(%rsp), %r9
leaq (%r9,%r8,8), %r9
xorl %r10d, %r10d
xorl %r8d, %r8d
cmpq %r10, %rax
je 0x8de7
movq (%rbx,%r14,8), %r11
movsd (%r11,%r10), %xmm0
movsd %xmm0, (%rdi,%r10)
movq (%r13,%r14,8), %r11
movsd (%r11,%r10), %xmm0
movsd %xmm0, (%r9,%r10)
decl %r8d
addq $0x8, %r10
jmp 0x8db8
subl %r8d, %esi
subl %r8d, %edx
testq %r12, %r12
je 0x8e45
movslq %edx, %r8
movslq %esi, %rdi
movq 0x10(%rsp), %r9
leaq (%r9,%rdi,8), %rdi
movq 0x18(%rsp), %r9
leaq (%r9,%r8,8), %r9
xorl %r10d, %r10d
xorl %r8d, %r8d
cmpq %r10, %rcx
je 0x8e3f
movq (%r12,%r14,8), %r11
movsd (%r11,%r10), %xmm0
movsd %xmm0, (%rdi,%r10)
movq (%rbp,%r14,8), %r11
movsd (%r11,%r10), %xmm0
movsd %xmm0, (%r9,%r10)
decl %r8d
addq $0x8, %r10
jmp 0x8e10
subl %r8d, %esi
subl %r8d, %edx
incq %r14
jmp 0x8d51
movsbl 0x24(%rsp), %edx
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x6d73
movq 0x30(%rsp), %rdx
movq 0x10(%rdx), %rax
movq 0x18(%rdx), %rcx
movq 0x20(%rdx), %rdx
movzbl 0xc(%rsp), %esi
xorl %edi, %edi
cmpq %r15, %rdi
je 0x8eeb
testq %rax, %rax
je 0x8e98
movq 0x28(%rsp), %r8
movsd (%r8,%rdi,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%r8,%rdi,8)
testq %rcx, %rcx
je 0x8ebf
xorl %r8d, %r8d
cmpq %r8, %r15
je 0x8ebf
movq (%r13,%rdi,8), %r9
movsd (%r9,%r8,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%r9,%r8,8)
incq %r8
jmp 0x8ea0
testq %rdx, %rdx
je 0x8ee6
xorl %r8d, %r8d
cmpq %r8, %rsi
je 0x8ee6
movq (%rbp,%rdi,8), %r9
movsd (%r9,%r8,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%r9,%r8,8)
incq %r8
jmp 0x8ec7
incq %rdi
jmp 0x8e79
movq 0x18(%rsp), %rdi
callq 0x4290
movq 0x10(%rsp), %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4290
nop