count += ((unsigned long)buf[i] & ~(~0ul >> 1)) / ~(~0ul >> 1);