Optimize another form of division-by-constant
Fix remaining bugs happening with 2^32-1 or more matches

See also commit 9611b6abd8dcef7acc67ac6c245e32753b9534c8.

To do: Replace inrange macros with templated functions.