Use GCC/Clang builtins for bit arithmetics

As suggested by @OlegHahm in #290