distRandGeneral in C and implemented in objfun