static void lz_unpack(unsigned char *src, unsigned char *dest)

{

    unsigned char *s;

    unsigned char *d;

    unsigned char queue[QUEUE_SIZE];

    unsigned int qpos;

    unsigned int dataleft;

    unsigned int chainofs;

    unsigned int chainlen;

    unsigned int speclen;

    unsigned char tag;

    unsigned int i, j;



    s = src;

    d = dest;

    dataleft = LE_32(s);

    s += 4;

    memset(queue, QUEUE_SIZE, 0x20);

    if (LE_32(s) == 0x56781234) {

        s += 4;

        qpos = 0x111;

        speclen = 0xF + 3;

    } else {

        qpos = 0xFEE;

        speclen = 100;  /* no speclen */

    }



    while (dataleft > 0) {

        tag = *s++;

        if ((tag == 0xFF) && (dataleft > 8)) {

            for (i = 0; i < 8; i++) {

                queue[qpos++] = *d++ = *s++;

                qpos &= QUEUE_MASK;

            }

            dataleft -= 8;

        } else {

            for (i = 0; i < 8; i++) {

                if (dataleft == 0)

                    break;

                if (tag & 0x01) {

                    queue[qpos++] = *d++ = *s++;

                    qpos &= QUEUE_MASK;

                    dataleft--;

                } else {

                    chainofs = *s++;

                    chainofs |= ((*s & 0xF0) << 4);

                    chainlen = (*s++ & 0x0F) + 3;

                    if (chainlen == speclen)

                        chainlen = *s++ + 0xF + 3;

                    for (j = 0; j < chainlen; j++) {

                        *d = queue[chainofs++ & QUEUE_MASK];

                        queue[qpos++] = *d++;

                        qpos &= QUEUE_MASK;

                    }

                    dataleft -= chainlen;

                }

                tag >>= 1;

            }

        }

    }

}

static void lz_unpack(unsigned char *src, unsigned char *dest)

{

    unsigned char *s;

    unsigned char *d;

    unsigned char queue[QUEUE_SIZE];

    unsigned int qpos;

    unsigned int dataleft;

    unsigned int chainofs;

    unsigned int chainlen;

    unsigned int speclen;

    unsigned char tag;

    unsigned int i, j;



    s = src;

    d = dest;

    dataleft = LE_32(s);

    s += 4;

    memset(queue, QUEUE_SIZE, 0x20);

    if (LE_32(s) == 0x56781234) {

        s += 4;

        qpos = 0x111;

        speclen = 0xF + 3;

    } else {

        qpos = 0xFEE;

        speclen = 100;  

    }



    while (dataleft > 0) {

        tag = *s++;

        if ((tag == 0xFF) && (dataleft > 8)) {

            for (i = 0; i < 8; i++) {

                queue[qpos++] = *d++ = *s++;

                qpos &= QUEUE_MASK;

            }

            dataleft -= 8;

        } else {

            for (i = 0; i < 8; i++) {

                if (dataleft == 0)

                    break;

                if (tag & 0x01) {

                    queue[qpos++] = *d++ = *s++;

                    qpos &= QUEUE_MASK;

                    dataleft--;

                } else {

                    chainofs = *s++;

                    chainofs |= ((*s & 0xF0) << 4);

                    chainlen = (*s++ & 0x0F) + 3;

                    if (chainlen == speclen)

                        chainlen = *s++ + 0xF + 3;

                    for (j = 0; j < chainlen; j++) {

                        *d = queue[chainofs++ & QUEUE_MASK];

                        queue[qpos++] = *d++;

                        qpos &= QUEUE_MASK;

                    }

                    dataleft -= chainlen;

                }

                tag >>= 1;

            }

        }

    }

}

static void FUNC_0(unsigned char *VAR_0, unsigned char *VAR_1)

{

    unsigned char *VAR_2;

    unsigned char *VAR_3;

    unsigned char VAR_4[QUEUE_SIZE];

    unsigned int VAR_5;

    unsigned int VAR_6;

    unsigned int VAR_7;

    unsigned int VAR_8;

    unsigned int VAR_9;

    unsigned char VAR_10;

    unsigned int VAR_11, VAR_12;



    VAR_2 = VAR_0;

    VAR_3 = VAR_1;

    VAR_6 = LE_32(VAR_2);

    VAR_2 += 4;

    memset(VAR_4, QUEUE_SIZE, 0x20);

    if (LE_32(VAR_2) == 0x56781234) {

        VAR_2 += 4;

        VAR_5 = 0x111;

        VAR_9 = 0xF + 3;

    } else {

        VAR_5 = 0xFEE;

        VAR_9 = 100;  

    }



    while (VAR_6 > 0) {

        VAR_10 = *VAR_2++;

        if ((VAR_10 == 0xFF) && (VAR_6 > 8)) {

            for (VAR_11 = 0; VAR_11 < 8; VAR_11++) {

                VAR_4[VAR_5++] = *VAR_3++ = *VAR_2++;

                VAR_5 &= QUEUE_MASK;

            }

            VAR_6 -= 8;

        } else {

            for (VAR_11 = 0; VAR_11 < 8; VAR_11++) {

                if (VAR_6 == 0)

                    break;

                if (VAR_10 & 0x01) {

                    VAR_4[VAR_5++] = *VAR_3++ = *VAR_2++;

                    VAR_5 &= QUEUE_MASK;

                    VAR_6--;

                } else {

                    VAR_7 = *VAR_2++;

                    VAR_7 |= ((*VAR_2 & 0xF0) << 4);

                    VAR_8 = (*VAR_2++ & 0x0F) + 3;

                    if (VAR_8 == VAR_9)

                        VAR_8 = *VAR_2++ + 0xF + 3;

                    for (VAR_12 = 0; VAR_12 < VAR_8; VAR_12++) {

                        *VAR_3 = VAR_4[VAR_7++ & QUEUE_MASK];

                        VAR_4[VAR_5++] = *VAR_3++;

                        VAR_5 &= QUEUE_MASK;

                    }

                    VAR_6 -= VAR_8;

                }

                VAR_10 >>= 1;

            }

        }

    }

}

static void FUNC_0(unsigned char *VAR_0, unsigned char *VAR_1)
{ unsigned char *VAR_2; unsigned char *VAR_3; unsigned char VAR_4[QUEUE_SIZE]; unsigned int VAR_5; unsigned int VAR_6; unsigned int VAR_7; unsigned int VAR_8; unsigned int VAR_9; unsigned char VAR_10; unsigned int VAR_11, VAR_12; VAR_2 = VAR_0; VAR_3 = VAR_1; VAR_6 = LE_32(VAR_2); VAR_2 += 4; memset(VAR_4, QUEUE_SIZE, 0x20); if (LE_32(VAR_2) == 0x56781234) { VAR_2 += 4; VAR_5 = 0x111; VAR_9 = 0xF + 3; } else { VAR_5 = 0xFEE; VAR_9 = 100; } while (VAR_6 > 0) { VAR_10 = *VAR_2++; if ((VAR_10 == 0xFF) && (VAR_6 > 8)) { for (VAR_11 = 0; VAR_11 < 8; VAR_11++) { VAR_4[VAR_5++] = *VAR_3++ = *VAR_2++; VAR_5 &= QUEUE_MASK; } VAR_6 -= 8; } else { for (VAR_11 = 0; VAR_11 < 8; VAR_11++) { if (VAR_6 == 0)
break; if (VAR_10 & 0x01) { VAR_4[VAR_5++] = *VAR_3++ = *VAR_2++; VAR_5 &= QUEUE_MASK; VAR_6--; } else { VAR_7 = *VAR_2++; VAR_7 |= ((*VAR_2 & 0xF0) << 4); VAR_8 = (*VAR_2++ & 0x0F) + 3; if (VAR_8 == VAR_9)
VAR_8 = *VAR_2++ + 0xF + 3; for (VAR_12 = 0; VAR_12 < VAR_8; VAR_12++) { *VAR_3 = VAR_4[VAR_7++ & QUEUE_MASK]; VAR_4[VAR_5++] = *VAR_3++; VAR_5 &= QUEUE_MASK; } VAR_6 -= VAR_8; } VAR_10 >>= 1; } } } }