Use GCC builtins for bsr/bsf where available.

Emscripten in particular can't deal with inline ASM well.
While this appears to work fine, I'm still not 100% confident that it's correct.

@dvander