// File: /workspace/github_cpp_makefile_star2_O1/myudelson[P]hmm-scalable/FitBitSt.cpp
// Function: FitBitSt::checkConvergenceBit(int, int, FitResult*)
NPAR FitBitSt::checkConvergenceBit(NDAT offset, NDAT size, FitResult *fr) {
    NUMBER criterion = 0;
    NUMBER criterion_oscil = 0; // oscillation between PAR and PARm1, i.e. PAR is close to PARm2
    NCAT i;
    NPAR res = 0;
    if (fr->iter >= this->task->first_iteration_qualify) {
        if( fr->pO0<=fr->pO) { // rough, won't go up
            res = 1;
        } else {
            switch (this->tol_mode) {
                case 'p':
                    for(i=offset; i<(offset+size); i++) {
                        criterion += pow( this->PARAM[i]-this->PARAMm1[i], 2 );
                    }
                    if( (!(sqrt(criterion) < this->tol)) && ( this->PARAMm2 != NULL ) ) {
                        for(i=offset; i<(offset+size); i++) {
                            criterion_oscil += pow( this->PARAM[i]-this->PARAMm2[i], 2 )/*:0*/;
                        }
                        res = 1*(sqrt(criterion_oscil) < this->tol); // double the truth or false
                    }
                    else
                        res = 1*(sqrt(criterion) < this->tol); // double the truth or false
                    break;
                case 'l':
                    criterion = (fr->pO0-fr->pO)/fr->ndat;
                    res = 1*(criterion < this->tol);
                    break;
            }
        }
    }
    fr->conv = res;
    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
movq 0x88(%rdi), %rax
movsbl 0x980(%rax), %eax
cmpl %eax, (%rcx)
jge 0x7cea
xorl %eax, %eax
jmp 0x7e0e
movsd 0x10(%rbx), %xmm0
movsd 0x18(%rbx), %xmm1
movb $0x1, %al
ucomisd %xmm0, %xmm1
jae 0x7e0e
movq %rdi, %r14
movzbl 0xd0(%rdi), %eax
cmpl $0x6c, %eax
je 0x7d61
cmpl $0x70, %eax
jne 0x7ce3
movl %edx, %r12d
movl %esi, %r15d
leal (%r12,%r15), %ebp
xorpd %xmm0, %xmm0
xorpd %xmm2, %xmm2
testl %edx, %edx
jle 0x7d52
movq 0x10(%r14), %rax
movq 0x18(%r14), %rcx
movslq %r15d, %rdx
movslq %ebp, %rsi
movsd (%rax,%rdx,8), %xmm1
subsd (%rcx,%rdx,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm2
incq %rdx
cmpq %rsi, %rdx
jl 0x7d38
ucomisd %xmm0, %xmm2
jb 0x7d76
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
jmp 0x7d8b
subsd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x24(%rbx), %xmm1
divsd %xmm1, %xmm0
jmp 0x7dfe
movapd %xmm2, %xmm0
movsd %xmm2, 0x8(%rsp)
callq 0x2160
movsd 0x8(%rsp), %xmm2
movsd 0xc8(%r14), %xmm1
ucomisd %xmm0, %xmm1
ja 0x7de2
cmpq $0x0, 0x20(%r14)
je 0x7de2
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
testl %r12d, %r12d
jle 0x7dd6
movq 0x10(%r14), %rax
movq 0x20(%r14), %rcx
movslq %r15d, %rdx
movslq %ebp, %rsi
movsd (%rax,%rdx,8), %xmm2
subsd (%rcx,%rdx,8), %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
incq %rdx
cmpq %rsi, %rdx
jl 0x7dbc
ucomisd %xmm1, %xmm0
jb 0x7df9
sqrtsd %xmm0, %xmm0
jmp 0x7dfe
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
jb 0x7df5
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
jmp 0x7dfe
movapd %xmm2, %xmm0
callq 0x2160
movsd 0xc8(%r14), %xmm1
ucomisd %xmm0, %xmm1
seta %al
movb %al, 0x20(%rbx)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq