1 2 3 4 5 6 7 8 9 10 11 12 13
#include <stdint.h> typedef uint64_t u64; int msb(u64 v) { long n = -1; __asm__("bsrq %1,%0" : "+r" (n) : "rm" (v)); return n + 1; }