static void lz_unpack(const unsigned char *src, unsigned char *dest, int dest_len)

{

    const unsigned char *s;

    unsigned char *d;

    unsigned char *d_end;

    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;

    d_end = d + dest_len;

    dataleft = AV_RL32(s);

    s += 4;

    memset(queue, 0x20, QUEUE_SIZE);

    if (AV_RL32(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)) {

            if (d + 8 > d_end)

                return;

            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) {

                    if (d + 1 > d_end)

                        return;

                    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;

                    if (d + chainlen > d_end)

                        return;

                    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(const unsigned char *src, unsigned char *dest, int dest_len)

{

    const unsigned char *s;

    unsigned char *d;

    unsigned char *d_end;

    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;

    d_end = d + dest_len;

    dataleft = AV_RL32(s);

    s += 4;

    memset(queue, 0x20, QUEUE_SIZE);

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

        s += 4;

        qpos = 0x111;

        speclen = 0xF + 3;

    } else {

        qpos = 0xFEE;

        speclen = 100;  

    }



    while (dataleft > 0) {

        tag = *s++;

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

            if (d + 8 > d_end)

                return;

            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) {

                    if (d + 1 > d_end)

                        return;

                    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;

                    if (d + chainlen > d_end)

                        return;

                    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(const unsigned char *src, unsigned char *dest, int dest_len)     while (dataleft > 0) {             if (d + 8 > d_end)                     if (d + 1 > d_end)                     if (chainlen == speclen)
static void FUNC_0(const unsigned char *VAR_0, unsigned char *VAR_1, int VAR_2)

{

    const unsigned char *VAR_3;

    unsigned char *VAR_4;

    unsigned char *VAR_5;

    unsigned char VAR_6[QUEUE_SIZE];

    unsigned int VAR_7;

    unsigned int VAR_8;

    unsigned int VAR_9;

    unsigned int VAR_10;

    unsigned int VAR_11;

    unsigned char VAR_12;

    unsigned int VAR_13, VAR_14;



    VAR_3 = VAR_0;

    VAR_4 = VAR_1;

    VAR_5 = VAR_4 + VAR_2;

    VAR_8 = AV_RL32(VAR_3);

    VAR_3 += 4;

    memset(VAR_6, 0x20, QUEUE_SIZE);

    if (AV_RL32(VAR_3) == 0x56781234) {

        VAR_3 += 4;

        VAR_7 = 0x111;

        VAR_11 = 0xF + 3;

    } else {

        VAR_7 = 0xFEE;

        VAR_11 = 100;  

    }



    while (VAR_8 > 0) {

        VAR_12 = *VAR_3++;

        if ((VAR_12 == 0xFF) && (VAR_8 > 8)) {

            if (VAR_4 + 8 > VAR_5)

                return;

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

                VAR_6[VAR_7++] = *VAR_4++ = *VAR_3++;

                VAR_7 &= QUEUE_MASK;

            }

            VAR_8 -= 8;

        } else {

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

                if (VAR_8 == 0)

                    break;

                if (VAR_12 & 0x01) {

                    if (VAR_4 + 1 > VAR_5)

                        return;

                    VAR_6[VAR_7++] = *VAR_4++ = *VAR_3++;

                    VAR_7 &= QUEUE_MASK;

                    VAR_8--;

                } else {

                    VAR_9 = *VAR_3++;

                    VAR_9 |= ((*VAR_3 & 0xF0) << 4);

                    VAR_10 = (*VAR_3++ & 0x0F) + 3;

                    if (VAR_10 == VAR_11)

                        VAR_10 = *VAR_3++ + 0xF + 3;

                    if (VAR_4 + VAR_10 > VAR_5)

                        return;

                    for (VAR_14 = 0; VAR_14 < VAR_10; VAR_14++) {

                        *VAR_4 = VAR_6[VAR_9++ & QUEUE_MASK];

                        VAR_6[VAR_7++] = *VAR_4++;

                        VAR_7 &= QUEUE_MASK;

                    }

                    VAR_8 -= VAR_10;

                }

                VAR_12 >>= 1;

            }

        }

    }

}

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