def zlib
gralha-bytes@0.1.0.1 · bytes.bend:396
import gralha-bytes@0.1.0.1/bytes.bend as Bytes
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
396def zlib(+src: Bytes, +expected: U32) -> Maybe<&2, Bytes>:
397 +n = bytes.size(src)
398 +cmf = bytes.get(src, 0)
399 +flg = bytes.get(src, 1)
400 U.branch(Maybe<&2, Bytes>, U32.is_ge(n, 6) && U32.is_eq(U32.and(cmf, 15), 8) && U32.is_le(U32.shrn(cmf, 4n), 7) && U32.is_eq(U32.and(flg, 32), 0) && U32.is_eq(((cmf * 256 + flg) % 31 : U32), 0),
401 _ => zlib.result(inflate.blocks(BitStream{src, 16, ((n - 4) * 8 : U32), True{}}, bytes.empty(), expected), expected, bytes.be(src, (n - 4 : U32), 4n, 0)), _ => None{})