Rewrite count_1s() to be similar to 64bit counterpart