// File: 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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq -0x8(%rbp), %rcx
movq %rcx, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
movb $0x0, -0x2d(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movq 0x88(%rcx), %rcx
movsbl 0x980(%rcx), %ecx
cmpl %ecx, %eax
jl 0xb249
movq -0x18(%rbp), %rax
movsd 0x10(%rax), %xmm1
movq -0x18(%rbp), %rax
movsd 0x18(%rax), %xmm0
ucomisd %xmm1, %xmm0
jb 0xb0af
movb $0x1, -0x2d(%rbp)
jmp 0xb247
movq -0x38(%rbp), %rax
movsbl 0xd0(%rax), %eax
movl %eax, -0x3c(%rbp)
subl $0x6c, %eax
je 0xb1fe
jmp 0xb0c8
movl -0x3c(%rbp), %eax
subl $0x70, %eax
jne 0xb245
jmp 0xb0d6
movl -0xc(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0xc(%rbp), %ecx
addl -0x10(%rbp), %ecx
cmpl %ecx, %eax
jge 0xb126
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rcx
movslq -0x2c(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x18(%rax), %rax
movslq -0x2c(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm0
movl $0x2, %edi
callq 0xb8b0
addsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xb0dc
movsd -0x20(%rbp), %xmm0
callq 0x31f0
movq -0x38(%rbp), %rax
movaps %xmm0, %xmm1
movsd 0xc8(%rax), %xmm0
ucomisd %xmm1, %xmm0
ja 0xb1d1
movq -0x38(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xb1d1
movl -0xc(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0xc(%rbp), %ecx
addl -0x10(%rbp), %ecx
cmpl %ecx, %eax
jge 0xb1a4
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rcx
movslq -0x2c(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x20(%rax), %rax
movslq -0x2c(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm0
movl $0x2, %edi
callq 0xb8b0
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xb15a
movsd -0x28(%rbp), %xmm0
callq 0x31f0
movq -0x38(%rbp), %rax
movaps %xmm0, %xmm1
movsd 0xc8(%rax), %xmm0
ucomisd %xmm1, %xmm0
seta %al
andb $0x1, %al
movzbl %al, %eax
shll $0x0, %eax
movb %al, -0x2d(%rbp)
jmp 0xb1fc
movsd -0x20(%rbp), %xmm0
callq 0x31f0
movq -0x38(%rbp), %rax
movaps %xmm0, %xmm1
movsd 0xc8(%rax), %xmm0
ucomisd %xmm1, %xmm0
seta %al
andb $0x1, %al
movzbl %al, %eax
shll $0x0, %eax
movb %al, -0x2d(%rbp)
jmp 0xb245
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
movsd 0x10(%rcx), %xmm0
movq -0x18(%rbp), %rcx
subsd 0x18(%rcx), %xmm0
movq -0x18(%rbp), %rcx
cvtsi2sdl 0x24(%rcx), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm1
movsd 0xc8(%rax), %xmm0
ucomisd %xmm1, %xmm0
seta %al
andb $0x1, %al
movzbl %al, %eax
shll $0x0, %eax
movb %al, -0x2d(%rbp)
jmp 0xb247
jmp 0xb249
movb -0x2d(%rbp), %cl
movq -0x18(%rbp), %rax
movb %cl, 0x20(%rax)
movb -0x2d(%rbp), %al
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)