I should probably add that the inline asm version can be
simplified to a much more readable:
return x <= 2 ? x : 2 << __asm!uint("bsrl $1, $0", "=r,r", x - 1);
Check out
http://llvm.org/docs/LangRef.html#inline-asm-constraint-string if
interested in LLVM inline assembly.