public static void decompress(OutputStream dst, InputStream src) throws IOException {
		/* Ring buffer of size N, with extra F-1 bytes to aid string comparison */
		ByteBuffer textBuf = ByteBuffer.allocate(N + F - 1);

		int flags;

		for (int i = 0; i < N - F; i++) {
			textBuf.put((byte) ' ');
		}
		textBuf.position(N - F);
		flags = 0;
		for (;;) {
			if (((flags >>>= 1) & 0x100) == 0) {
				int c = src.read();
				if (c == -1) {
					break;
				}
				flags = c | 0xFF00; /* uses higher byte cleverly */
			} /* count to eight */
			if ((flags & 1) != 0) {
				int c = src.read();
				if (c == -1) {
					break;
				}
				dst.write(c);
				textBuf.put((byte) c);
				textBuf.position(textBuf.position() & (N - 1));
			}
			else {
				int i = src.read();
				if (i == -1) {
					break;
				}
				int j = src.read();
				if (j == -1) {
					break;
				}
				i |= ((j & 0xF0) << 4);
				j = (j & 0x0F) + THRESHOLD;
				for (int k = 0; k <= j; k++) {
					int c = textBuf.get((i + k) & (N - 1));
					dst.write(c);
					textBuf.put((byte) c);
					textBuf.position(textBuf.position() & (N - 1));
				}
			}
		}
		dst.flush();
	}
initialize state, mostly the trees

For i = 0 to N - 1, rchild[i] and lchild[i] will be the right and
left children of node i. These nodes need not be initialized. Also
parent[i] is the parent of node i. These are initialzied to NIL (=N),
which stands for 'not used.' For i = 0 to 256, rchild[N + i + 1] is
the root of the tree for strings that begin with character i. These
are initialized to NIL. Note there are 256 trees.
Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/lzss/LzssCodec.java