static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize)

{

    unsigned char *destptr_bak = destptr;

    unsigned char *destptr_end = destptr + destsize;

    const unsigned char *srcptr_end = srcptr + srclen;

    unsigned mask = *srcptr++;

    unsigned maskbit = 0x80;



    while (srcptr < srcptr_end && destptr < destptr_end) {

        if (!(mask & maskbit)) {

            memcpy(destptr, srcptr, 4);

            destptr += 4;

            srcptr += 4;

        } else {

            unsigned ofs = bytestream_get_le16(&srcptr);

            unsigned cnt = (ofs >> 11) + 1;

            ofs &= 0x7ff;

            ofs = FFMIN(ofs, destptr - destptr_bak);

            cnt *= 4;

            cnt = FFMIN(cnt, destptr_end - destptr);

            av_memcpy_backptr(destptr, ofs, cnt);

            destptr += cnt;

        }

        maskbit >>= 1;

        if (!maskbit) {

            mask = *srcptr++;

            while (!mask) {

                if (destptr_end - destptr < 32 || srcptr_end - srcptr < 32) break;

                memcpy(destptr, srcptr, 32);

                destptr += 32;

                srcptr += 32;

                mask = *srcptr++;

            }

            maskbit = 0x80;

        }

    }



    return destptr - destptr_bak;

}

static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize)

{

    unsigned char *destptr_bak = destptr;

    unsigned char *destptr_end = destptr + destsize;

    const unsigned char *srcptr_end = srcptr + srclen;

    unsigned mask = *srcptr++;

    unsigned maskbit = 0x80;



    while (srcptr < srcptr_end && destptr < destptr_end) {

        if (!(mask & maskbit)) {

            memcpy(destptr, srcptr, 4);

            destptr += 4;

            srcptr += 4;

        } else {

            unsigned ofs = bytestream_get_le16(&srcptr);

            unsigned cnt = (ofs >> 11) + 1;

            ofs &= 0x7ff;

            ofs = FFMIN(ofs, destptr - destptr_bak);

            cnt *= 4;

            cnt = FFMIN(cnt, destptr_end - destptr);

            av_memcpy_backptr(destptr, ofs, cnt);

            destptr += cnt;

        }

        maskbit >>= 1;

        if (!maskbit) {

            mask = *srcptr++;

            while (!mask) {

                if (destptr_end - destptr < 32 || srcptr_end - srcptr < 32) break;

                memcpy(destptr, srcptr, 32);

                destptr += 32;

                srcptr += 32;

                mask = *srcptr++;

            }

            maskbit = 0x80;

        }

    }



    return destptr - destptr_bak;

}

            av_memcpy_backptr(destptr, ofs, cnt);
static unsigned int FUNC_0(const unsigned char * VAR_0, int VAR_1, unsigned char * VAR_2, unsigned int VAR_3)

{

    unsigned char *VAR_4 = VAR_2;

    unsigned char *VAR_5 = VAR_2 + VAR_3;

    const unsigned char *VAR_6 = VAR_0 + VAR_1;

    unsigned VAR_7 = *VAR_0++;

    unsigned VAR_8 = 0x80;



    while (VAR_0 < VAR_6 && VAR_2 < VAR_5) {

        if (!(VAR_7 & VAR_8)) {

            memcpy(VAR_2, VAR_0, 4);

            VAR_2 += 4;

            VAR_0 += 4;

        } else {

            unsigned VAR_9 = bytestream_get_le16(&VAR_0);

            unsigned VAR_10 = (VAR_9 >> 11) + 1;

            VAR_9 &= 0x7ff;

            VAR_9 = FFMIN(VAR_9, VAR_2 - VAR_4);

            VAR_10 *= 4;

            VAR_10 = FFMIN(VAR_10, VAR_5 - VAR_2);

            av_memcpy_backptr(VAR_2, VAR_9, VAR_10);

            VAR_2 += VAR_10;

        }

        VAR_8 >>= 1;

        if (!VAR_8) {

            VAR_7 = *VAR_0++;

            while (!VAR_7) {

                if (VAR_5 - VAR_2 < 32 || VAR_6 - VAR_0 < 32) break;

                memcpy(VAR_2, VAR_0, 32);

                VAR_2 += 32;

                VAR_0 += 32;

                VAR_7 = *VAR_0++;

            }

            VAR_8 = 0x80;

        }

    }



    return VAR_2 - VAR_4;

}

static unsigned int FUNC_0(const unsigned char * VAR_0, int VAR_1, unsigned char * VAR_2, unsigned int VAR_3)
{ unsigned char *VAR_4 = VAR_2; unsigned char *VAR_5 = VAR_2 + VAR_3; const unsigned char *VAR_6 = VAR_0 + VAR_1; unsigned VAR_7 = *VAR_0++; unsigned VAR_8 = 0x80; while (VAR_0 < VAR_6 && VAR_2 < VAR_5) { if (!(VAR_7 & VAR_8)) { memcpy(VAR_2, VAR_0, 4); VAR_2 += 4; VAR_0 += 4; } else { unsigned VAR_9 = bytestream_get_le16(&VAR_0); unsigned VAR_10 = (VAR_9 >> 11) + 1; VAR_9 &= 0x7ff; VAR_9 = FFMIN(VAR_9, VAR_2 - VAR_4); VAR_10 *= 4; VAR_10 = FFMIN(VAR_10, VAR_5 - VAR_2); av_memcpy_backptr(VAR_2, VAR_9, VAR_10); VAR_2 += VAR_10; } VAR_8 >>= 1; if (!VAR_8) { VAR_7 = *VAR_0++; while (!VAR_7) { if (VAR_5 - VAR_2 < 32 || VAR_6 - VAR_0 < 32) break; memcpy(VAR_2, VAR_0, 32); VAR_2 += 32; VAR_0 += 32; VAR_7 = *VAR_0++; } VAR_8 = 0x80; } } return VAR_2 - VAR_4; }