// File: 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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x68(%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 -0x68(%rbp), %rcx
movb 0x1(%rcx), %al
movb %al, -0x29(%rbp)
movb (%rcx), %al
movb %al, -0x2a(%rbp)
cmpq $0x0, 0x10(%rcx)
setne %al
andb $0x1, %al
movzbl %al, %eax
shll $0x0, %eax
cmpq $0x0, 0x18(%rcx)
setne %dl
andb $0x1, %dl
movzbl %dl, %edx
movsbl -0x29(%rbp), %esi
imull %esi, %edx
addl %edx, %eax
cmpq $0x0, 0x20(%rcx)
setne %cl
andb $0x1, %cl
movzbl %cl, %ecx
movsbl -0x2a(%rbp), %edx
imull %edx, %ecx
addl %ecx, %eax
movsbl -0x29(%rbp), %ecx
imull %ecx, %eax
movl %eax, -0x30(%rbp)
movslq -0x30(%rbp), %rdi
movl $0x8, %esi
callq 0x5180
movq %rax, -0x38(%rbp)
movslq -0x30(%rbp), %rdi
movl $0x8, %esi
callq 0x5180
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movb $0x0, -0x49(%rbp)
movsbl -0x49(%rbp), %eax
movsbl -0x29(%rbp), %ecx
cmpl %ecx, %eax
jge 0xee86
movq -0x68(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xed69
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movsbq -0x49(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x40(%rbp), %rax
movl -0x44(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x44(%rbp)
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movsbq -0x49(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x38(%rbp), %rax
movl -0x48(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x48(%rbp)
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x68(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xedf0
movb $0x0, -0x4a(%rbp)
movsbl -0x4a(%rbp), %eax
movsbl -0x29(%rbp), %ecx
cmpl %ecx, %eax
jge 0xedee
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movsbq -0x49(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x4a(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x40(%rbp), %rax
movl -0x44(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x44(%rbp)
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movsbq -0x49(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x4a(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x38(%rbp), %rax
movl -0x48(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x48(%rbp)
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movb -0x4a(%rbp), %al
addb $0x1, %al
movb %al, -0x4a(%rbp)
jmp 0xed78
jmp 0xedf0
movq -0x68(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xee77
movb $0x0, -0x4b(%rbp)
movsbl -0x4b(%rbp), %eax
movsbl -0x2a(%rbp), %ecx
cmpl %ecx, %eax
jge 0xee75
movq -0x68(%rbp), %rax
movq 0x20(%rax), %rax
movsbq -0x49(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x4b(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x40(%rbp), %rax
movl -0x44(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x44(%rbp)
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
movsbq -0x49(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x4b(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x38(%rbp), %rax
movl -0x48(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x48(%rbp)
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movb -0x4b(%rbp), %al
addb $0x1, %al
movb %al, -0x4b(%rbp)
jmp 0xedff
jmp 0xee77
jmp 0xee79
movb -0x49(%rbp), %al
addb $0x1, %al
movb %al, -0x49(%rbp)
jmp 0xed00
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl -0x30(%rbp), %eax
movsbl %al, %edx
callq 0xa590
movsd %xmm0, -0x58(%rbp)
movb $0x0, -0x59(%rbp)
movsbl -0x59(%rbp), %eax
movsbl -0x29(%rbp), %ecx
cmpl %ecx, %eax
jge 0xef74
movq -0x68(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xeed5
movsd -0x58(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsbq -0x59(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq -0x68(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xef1d
movb $0x0, -0x5a(%rbp)
movsbl -0x5a(%rbp), %eax
movsbl -0x29(%rbp), %ecx
cmpl %ecx, %eax
jge 0xef1b
movsd -0x58(%rbp), %xmm0
movq -0x20(%rbp), %rax
movsbq -0x59(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x5a(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0x5a(%rbp), %al
addb $0x1, %al
movb %al, -0x5a(%rbp)
jmp 0xeee4
jmp 0xef1d
movq -0x68(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xef65
movb $0x0, -0x5b(%rbp)
movsbl -0x5b(%rbp), %eax
movsbl -0x2a(%rbp), %ecx
cmpl %ecx, %eax
jge 0xef63
movsd -0x58(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsbq -0x59(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x5b(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0x5b(%rbp), %al
addb $0x1, %al
movb %al, -0x5b(%rbp)
jmp 0xef2c
jmp 0xef65
jmp 0xef67
movb -0x59(%rbp), %al
addb $0x1, %al
movb %al, -0x59(%rbp)
jmp 0xeea2
movq -0x38(%rbp), %rdi
callq 0x5380
movq -0x40(%rbp), %rdi
callq 0x5380
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)