>>107116325
I'm a catastrophe.
>>107113513
>>107115972
This finds sequences where there are 3 or more consecutive 1 bits.
It's very simple. There is a bit sequence of 1s of length >= 3 starting at bit n if bit(n) == 1 && bit(n + 1) == 1 && bit(n + 2) == 1.
From there, if locations is not 0 you can easily find n by counting the number of leading 0s.
uint32_t bitmap = 0b011110111011010;
uint32_t x = bitmap;
uint32_t locations = x & x >> 1 & x >> 2;
if (locations == 0) {
// no sequence of bits is long enough
}
else {
printf("bitmap 0b%032b\n", bitmap);
printf("locations 0b%032b\n", locations);
}
bitmap 0b00000000000000000011110111011010
locations 0b00000000000000000000110001000000