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

{

    unsigned char *destptr_bak = destptr;

    unsigned char *destptr_end = destptr + destsize;

    unsigned char mask = 0;

    unsigned char maskbit = 0;

    unsigned int ofs, cnt;



    while (srclen > 0 && destptr < destptr_end) {

        if (maskbit == 0) {

            mask = *srcptr++;

            maskbit = 8;

            srclen--;

            continue;

        }

        if ((mask & (1 << (--maskbit))) == 0) {

            if (destptr + 4 > destptr_end)

                break;

            memcpy(destptr, srcptr, 4);

            srclen -= 4;

            destptr += 4;

            srcptr += 4;

        } else {

            ofs = *srcptr++;

            cnt = *srcptr++;

            ofs += cnt * 256;

            cnt = ((cnt >> 3) & 0x1f) + 1;

            ofs &= 0x7ff;

            srclen -= 2;

            cnt *= 4;

            if (destptr + cnt > destptr_end) {

                cnt =  destptr_end - destptr;

            }

            for (; cnt > 0; cnt--) {

                *destptr = *(destptr - ofs);

                destptr++;

            }

        }

    }



    return destptr - destptr_bak;

}

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

{

    unsigned char *destptr_bak = destptr;

    unsigned char *destptr_end = destptr + destsize;

    unsigned char mask = 0;

    unsigned char maskbit = 0;

    unsigned int ofs, cnt;



    while (srclen > 0 && destptr < destptr_end) {

        if (maskbit == 0) {

            mask = *srcptr++;

            maskbit = 8;

            srclen--;

            continue;

        }

        if ((mask & (1 << (--maskbit))) == 0) {

            if (destptr + 4 > destptr_end)

                break;

            memcpy(destptr, srcptr, 4);

            srclen -= 4;

            destptr += 4;

            srcptr += 4;

        } else {

            ofs = *srcptr++;

            cnt = *srcptr++;

            ofs += cnt * 256;

            cnt = ((cnt >> 3) & 0x1f) + 1;

            ofs &= 0x7ff;

            srclen -= 2;

            cnt *= 4;

            if (destptr + cnt > destptr_end) {

                cnt =  destptr_end - destptr;

            }

            for (; cnt > 0; cnt--) {

                *destptr = *(destptr - ofs);

                destptr++;

            }

        }

    }



    return destptr - destptr_bak;

}

            if (destptr + 4 > destptr_end)             if (destptr + cnt > destptr_end) {
static unsigned int FUNC_0(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;

    unsigned char VAR_6 = 0;

    unsigned char VAR_7 = 0;

    unsigned int VAR_8, VAR_9;



    while (VAR_1 > 0 && VAR_2 < VAR_5) {

        if (VAR_7 == 0) {

            VAR_6 = *VAR_0++;

            VAR_7 = 8;

            VAR_1--;

            continue;

        }

        if ((VAR_6 & (1 << (--VAR_7))) == 0) {

            if (VAR_2 + 4 > VAR_5)

                break;

            memcpy(VAR_2, VAR_0, 4);

            VAR_1 -= 4;

            VAR_2 += 4;

            VAR_0 += 4;

        } else {

            VAR_8 = *VAR_0++;

            VAR_9 = *VAR_0++;

            VAR_8 += VAR_9 * 256;

            VAR_9 = ((VAR_9 >> 3) & 0x1f) + 1;

            VAR_8 &= 0x7ff;

            VAR_1 -= 2;

            VAR_9 *= 4;

            if (VAR_2 + VAR_9 > VAR_5) {

                VAR_9 =  VAR_5 - VAR_2;

            }

            for (; VAR_9 > 0; VAR_9--) {

                *VAR_2 = *(VAR_2 - VAR_8);

                VAR_2++;

            }

        }

    }



    return VAR_2 - VAR_4;

}

static unsigned int FUNC_0(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; unsigned char VAR_6 = 0; unsigned char VAR_7 = 0; unsigned int VAR_8, VAR_9; while (VAR_1 > 0 && VAR_2 < VAR_5) { if (VAR_7 == 0) { VAR_6 = *VAR_0++; VAR_7 = 8; VAR_1--; continue; } if ((VAR_6 & (1 << (--VAR_7))) == 0) { if (VAR_2 + 4 > VAR_5)
break; memcpy(VAR_2, VAR_0, 4); VAR_1 -= 4; VAR_2 += 4; VAR_0 += 4; } else { VAR_8 = *VAR_0++; VAR_9 = *VAR_0++; VAR_8 += VAR_9 * 256; VAR_9 = ((VAR_9 >> 3) & 0x1f) + 1; VAR_8 &= 0x7ff; VAR_1 -= 2; VAR_9 *= 4; if (VAR_2 + VAR_9 > VAR_5) { VAR_9 =  VAR_5 - VAR_2; } for (; VAR_9 > 0; VAR_9--) { *VAR_2 = *(VAR_2 - VAR_8); VAR_2++; } } } return VAR_2 - VAR_4; }