private void normalize() {
		if (nonzerosize <= 0) {	// Check if alwaystrue or alwaysfalse
			offset = 0;
			maskvec = null;
			valvec = null;
			return;
		}
		int iter1 = 0;
		int iter2 = 0;		// Cut zeros from beginning of mask
		while ((iter1 != maskvec.length) && (maskvec[iter1] == 0)) {
			iter1++;
			iter2++;
			offset += 4;	// Sizeof int
		}
		maskvec = eraseArray(maskvec, 0, iter1);
		valvec = eraseArray(valvec, 0, iter2);

		if (maskvec.length != 0) {
			int suboff = 0;		// Cut off unaligned zeros from beginning
			int tmp = maskvec[0];
			while (tmp != 0) {
				suboff += 1;
				tmp >>>= 8;
			}
			suboff = 4 - suboff;
			if (suboff != 0) {
				offset += suboff;	// Slide up maskvec by suboff bytes
				for (int i = 0; i < maskvec.length - 1; ++i) {
					tmp = maskvec[i] << (suboff * 8);
					tmp |= (maskvec[i + 1] >>> ((4 - suboff) * 8));
					maskvec[i] = tmp;
				}
				maskvec[maskvec.length - 1] <<= suboff * 8;
				for (int i = 0; i < valvec.length - 1; ++i) {	// Slide up valvec
					tmp = valvec[i] << (suboff * 8);
					tmp |= (valvec[i] >>> ((4 - suboff) * 8));
					valvec[i] = tmp;
				}
				valvec[valvec.length - 1] <<= suboff * 8;
			}

			iter1 = maskvec.length;		// Cut zeros from end of mask
			iter2 = valvec.length;
			while (iter1 != 0) {
				--iter1;
				--iter2;
				if (maskvec[iter1] != 0) {
					break;	// Find last non-zero
				}
			}
			if (iter1 != maskvec.length) {
				iter1++;			// Find first zero,in last zero chain
				iter2++;
			}
			maskvec = eraseArray(maskvec, iter1, maskvec.length);
			valvec = eraseArray(valvec, iter2, valvec.length);
		}

		if (maskvec.length == 0) {
			offset = 0;
			nonzerosize = 0;	// Always true
			maskvec = null;
			valvec = null;
			return;
		}
		nonzerosize = maskvec.length * 4;
		int tmp = maskvec[maskvec.length - 1];	// tmp must be nonzero
		while ((tmp & 0xff) == 0) {
			nonzerosize -= 1;
			tmp >>>= 8;
		}
	}
A mask/value pair viewed as two bitstreams
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/pattern/PatternBlock.java