title: Index of first byte having its MSB set
body: <p>I have eight 8-bit values stored in a 64-bit integer. The MSB of each byte can either be 1 or 0, and the rest of their bits are all 0. Example:</p>
  <p>MSB 10000000 00000000 10000000 ... 10000000 00000000 00000000 LSB</p>
  <p>I now need to find the index of first byte that has its bit set. First meaning that we search from the least significant direction. In the above example the result would be 2.</p>
  <p>Using de Bruijn we could scan for the first set bit and divide by 8 to get its byte index.</p>
  <p>Here's my question: de Bruijn is generic, it works for any input. But in my use case we are limited to bytes having only their MSB set. Is it possible to optimize for this case?</p>
  <p>The implementation is in C++. I can't use any intrinsics or inline assembly (_BitScanForward64(), __builtin_clzll etc).</p>