This part:
int min = MAX_VALUE;
int max = 0;
is correct and cleaner, but mine didn't have any problem. (the probability that it goes on forever would be ~0 for true random numbers and I suspect that for pseudo-random numbers it's even lower).(but yes, it seems useless, I don't remember why I thought it was needed)
This part:
cnt_max = NEW_MAX;
...
cnt_min = NEW_MIN;
is either semantically incorrect(that is, you didn't understand what I did) or it's useless and you chose some very bad names for the defines.