/* Convert an integer from unsigned big-endian encoding to a sequence of 30-bit words in little-endian order. The final "partial" word is returned.  */
static uint32_t be8_to_le30(uint32_t *dst, const unsigned char *src, size_t len)
/* Convert an integer from unsigned big-endian encoding to a sequence of 30-bit words in little-endian order. The final "partial" word is returned.  */
static uint32_t be8_to_le30(uint32_t *dst, const unsigned char *src, size_t len)
{
	uint32_t acc;
	int acc_len;
	acc = 0;
	acc_len = 0;
	while (len -- > 0) {
		uint32_t b;
		b = src[len];
		if (acc_len < 22) {
			acc |= b << acc_len;
			acc_len += 8;
		} else {
			*dst ++ = (acc | (b << acc_len)) & 0x3FFFFFFF;
			acc = b >> (30 - acc_len);
			acc_len -= 22;
		}
	}
	return acc;
}