Expand auto for readability.
Make bitmask an unsigned type.
Remove an unnecessary local variable.
Use size_t instead of uint64_t to represent the vector length.