function checkHealth(s, endOfStream) {
    if (s.endOfStreamReached == 0) {
      return;
    }
    let /** @type{number} */ byteOffset = (s.halfOffset << 1) + ((s.bitOffset + 7) >> 3) - 4;
    if (byteOffset > s.tailBytes) {
      throw "Read after end";
    }
    if ((endOfStream != 0) && (byteOffset != s.tailBytes)) {
      throw "Unused bytes after end";
    }
  }
@param {!State} s
@param {number} endOfStream
@return {void}