Example 1: Calculating shift and mask based on offset and number of bits.

unsigned int bitOffset = 8 + 1 + 1 + 2 + 12 + 16 + 2;
unsigned int numBits   = 5;
unsigned int version   = extract_bits(data, bitOffset, numBits);