Check bitpermutate correctness with asserts

Signed-off-by: Pauli Nieminen <suokkos@gmail.com>
Refactor bitpermutation to do less branching

Signed-off-by: Pauli Nieminen <suokkos@gmail.com>
Use ctz to count trailing zeros

Signed-off-by: Pauli Nieminen <suokkos@gmail.com>
Optimise exc_shuffle with xor

Xoring two integer gets bit difference of those. That allows easily
calculate changes in a bitmask. When change has been calculated that can
be applied with another xor to a mask.

Signed-off-by: Pauli Nieminen <suokkos@gmail.com>