// File: /workspace/github_cpp_makefile_star2_O1/myudelson[P]hmm-scalable/FitBit.cpp
// Function: FitBit::checkConvergence(FitResult*)
bool FitBit::checkConvergence(FitResult *fr) {
    
    NUMBER criterion = 0;
    NUMBER criterion_oscil = 0; // oscillation between PAR and PARm1, i.e. PAR is close to PARm2
    bool res = false;
    switch (this->tol_mode) {
        case 'p':
            for(NPAR i=0; i<this->nS; i++)
            {
                if(this->pi != NULL) criterion += pow( this->pi[i]-this->PIm1[i], 2 )/*:0*/;
                for(NPAR j=0; (this->A != NULL) && j<this->nS; j++) {
                    criterion += pow(this->A[i][j] - this->Am1[i][j],2);
                }
                for(NPAR k=0; (this->B != NULL) && k<this->nO; k++) {
                    criterion += pow(this->B[i][k] - this->Bm1[i][k],2);
                }
            }
            
            if( (!(sqrt(criterion) < this->tol)) && ( this->PIm2 != NULL || this->Am2 != NULL || this->Bm2 != NULL ) ) {
                for(NPAR i=0; i<this->nS; i++)
                {
                    if(this->pi != NULL) criterion_oscil += pow( this->pi[i]-this->PIm2[i], 2 )/*:0*/;
                    for(NPAR j=0; (this->A != NULL) && j<this->nS; j++) {
                        criterion_oscil += pow(this->A[i][j] - this->Am2[i][j],2);
                    }
                    for(NPAR k=0; (this->B != NULL) && k<this->nO; k++) {
                        criterion_oscil += pow(this->B[i][k] - this->Bm2[i][k],2);
                    }
                }
                res = sqrt(criterion_oscil) < this->tol; // double the truth or false
            }
            else
                res = sqrt(criterion) < this->tol; // double the truth or false
            break;
        case 'l':
            criterion = (fr->pOmid-fr->pO)/fr->ndat;
            res = criterion < this->tol;
            break;
    }
    return res;
}

// Assembly:
movzbl 0x108(%rdi), %eax
cmpl $0x6c, %eax
je 0xb2a6
cmpl $0x70, %eax
jne 0xb2c9
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, 0x8(%rsp)
movsbq 0x1(%rdi), %rax
xorpd %xmm0, %xmm0
xorpd %xmm2, %xmm2
testq %rax, %rax
jle 0xb297
movq 0x8(%rsp), %r14
movq 0x10(%r14), %rcx
movq 0x18(%r14), %rdx
movq 0x28(%r14), %rsi
testq %rdx, %rdx
setne %r9b
movsbq 0x1(%r14), %rdi
testq %rdi, %rdi
setg %r8b
andb %r9b, %r8b
movq 0x30(%r14), %r9
movq %r9, 0x10(%rsp)
movq 0x20(%r14), %r10
testq %r10, %r10
setne %bl
movsbq (%r14), %r11
testq %r11, %r11
setg %bpl
andb %bl, %bpl
movq 0x38(%r14), %r14
xorl %r15d, %r15d
testq %rcx, %rcx
je 0xb20c
movsd (%rcx,%r15,8), %xmm1
subsd (%rsi,%r15,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm2
testb %r8b, %r8b
je 0xb24e
movq (%rdx,%r15,8), %r12
movq 0x10(%rsp), %r9
movq (%r9,%r15,8), %r13
movl $0x1, %ebx
movapd %xmm2, %xmm1
movsd -0x8(%r12,%rbx,8), %xmm2
subsd -0x8(%r13,%rbx,8), %xmm2
mulsd %xmm2, %xmm2
addsd %xmm1, %xmm2
testq %rdx, %rdx
je 0xb24e
leaq 0x1(%rbx), %r9
cmpq %rdi, %rbx
movq %r9, %rbx
jl 0xb223
testb %bpl, %bpl
je 0xb28b
movq (%r10,%r15,8), %r12
movq (%r14,%r15,8), %r13
movl $0x1, %ebx
movapd %xmm2, %xmm1
movsd -0x8(%r12,%rbx,8), %xmm2
subsd -0x8(%r13,%rbx,8), %xmm2
mulsd %xmm2, %xmm2
addsd %xmm1, %xmm2
testq %r10, %r10
je 0xb28b
leaq 0x1(%rbx), %r9
cmpq %r11, %rbx
movq %r9, %rbx
jl 0xb260
incq %r15
cmpq %rax, %r15
jne 0xb1f3
ucomisd %xmm0, %xmm2
jb 0xb2cc
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
jmp 0xb2e1
movsd 0x10(%rsi), %xmm0
subsd 0x18(%rsi), %xmm0
cvtsi2sdl 0x24(%rsi), %xmm1
divsd %xmm1, %xmm0
movsd 0x100(%rdi), %xmm1
ucomisd %xmm0, %xmm1
seta %al
retq
xorl %eax, %eax
retq
movapd %xmm2, %xmm0
movsd %xmm2, 0x10(%rsp)
callq 0x41a0
movsd 0x10(%rsp), %xmm2
movq 0x8(%rsp), %rbx
movsd 0x100(%rbx), %xmm1
ucomisd %xmm0, %xmm1
ja 0xb309
cmpq $0x0, 0x40(%rbx)
jne 0xb332
cmpq $0x0, 0x48(%rbx)
jne 0xb332
cmpq $0x0, 0x50(%rbx)
jne 0xb332
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
jb 0xb31c
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
jmp 0xb325
movapd %xmm2, %xmm0
callq 0x41a0
movsd 0x100(%rbx), %xmm1
jmp 0xb459
movsbq 0x1(%rbx), %rax
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
testq %rax, %rax
jle 0xb43b
movq 0x8(%rsp), %r14
movq 0x10(%r14), %rcx
movq 0x18(%r14), %rdx
movq 0x40(%r14), %rsi
testq %rdx, %rdx
setne %r9b
movsbq 0x1(%r14), %rdi
testq %rdi, %rdi
setg %r8b
andb %r9b, %r8b
movq 0x48(%r14), %r9
movq %r9, 0x10(%rsp)
movq 0x20(%r14), %r10
testq %r10, %r10
setne %bl
movsbq (%r14), %r11
testq %r11, %r11
setg %bpl
andb %bl, %bpl
movq 0x50(%r14), %r14
xorl %r15d, %r15d
testq %rcx, %rcx
je 0xb3b0
movsd (%rcx,%r15,8), %xmm2
subsd (%rsi,%r15,8), %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
testb %r8b, %r8b
je 0xb3f2
movq (%rdx,%r15,8), %r12
movq 0x10(%rsp), %r9
movq (%r9,%r15,8), %r13
movl $0x1, %ebx
movapd %xmm0, %xmm2
movsd -0x8(%r12,%rbx,8), %xmm0
subsd -0x8(%r13,%rbx,8), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm2, %xmm0
testq %rdx, %rdx
je 0xb3f2
leaq 0x1(%rbx), %r9
cmpq %rdi, %rbx
movq %r9, %rbx
jl 0xb3c7
testb %bpl, %bpl
je 0xb42f
movq (%r10,%r15,8), %r12
movq (%r14,%r15,8), %r13
movl $0x1, %ebx
movapd %xmm0, %xmm2
movsd -0x8(%r12,%rbx,8), %xmm0
subsd -0x8(%r13,%rbx,8), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm2, %xmm0
testq %r10, %r10
je 0xb42f
leaq 0x1(%rbx), %r9
cmpq %r11, %rbx
movq %r9, %rbx
jl 0xb404
incq %r15
cmpq %rax, %r15
jne 0xb397
ucomisd %xmm1, %xmm0
jb 0xb447
sqrtsd %xmm0, %xmm0
jmp 0xb44c
callq 0x41a0
movq 0x8(%rsp), %rax
movsd 0x100(%rax), %xmm1
ucomisd %xmm0, %xmm1
seta %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop