When I run the own written function it runs and does no exit. I was waiting for 5-6 hours, checked dstats, no disk writes, only 1 core works and no memory usage. It is like stuck and can not exit. It happens when I use function separately for each variable, without callingm for example:

while( *a ){
        countA += *a & 1;
        *a >>= 1;
    }
   while( *b ){
        countB += *b & 1;
        *b >>= 1;
    }
   while( c ){
        countC += c & 1;
        c >>= 1;
    }

but when I call functions like this monetdb works fine:

int countSetBits1(unsigned int n){
        unsigned int count = 0;
        while(n){
            count += n & 1;
            n >>= 1;
        }
    return count;
    }    

countA = countSetBits1(*a);
countB = countSetBits1(*b);
countC = countSetBits1(c);


I am not strong in C or monetdb internals, but in Netbeans both codes work well. The entire code :


str
UDFbitanddec(flt *ret, lng *a, lng *b) {
    int c = 0;
    int countA = 0;
int countB = 0;
    int countC = 0;
int maxCount = 0;
unsigned int iA = *a;
unsigned int iB = *b;
    
    c = iA & iB;

    while( iA ){
        countA += iA & 1;
        iA >>= 1;
    }
   while( iB ){
        countB += iB & 1;
        iB >>= 1;
    }
   while( c ){
        countC += c & 1;
        c >>= 1;
    }
if (countA >= countB) {
maxCount = countA;
}
else {
maxCount = countB;
}
   
    *ret = (float)countC /maxCount;
    return MAL_SUCCEED;
    
}