static int GLZWDecode(GifState * s, uint8_t * buf, int len)

{

    int l, c, code, oc, fc;

    uint8_t *sp;



    if (s->end_code < 0)

        return 0;



    l = len;

    sp = s->sp;

    oc = s->oc;

    fc = s->fc;



    while (sp > s->stack) {

        *buf++ = *(--sp);

        if ((--l) == 0)

            goto the_end;

    }



    for (;;) {

        c = GetCode(s);

        if (c == s->end_code) {

            s->end_code = -1;

            break;

        } else if (c == s->clear_code) {

            s->cursize = s->codesize + 1;

            s->curmask = mask[s->cursize];

            s->slot = s->newcodes;

            s->top_slot = 1 << s->cursize;

            while ((c = GetCode(s)) == s->clear_code);

            if (c == s->end_code) {

                s->end_code = -1;

                break;

            }

            /* test error */

            if (c >= s->slot)

                c = 0;

            fc = oc = c;

            *buf++ = c;

            if ((--l) == 0)

                break;

        } else {

            code = c;

            if (code >= s->slot) {

                *sp++ = fc;

                code = oc;

            }

            while (code >= s->newcodes) {

                *sp++ = s->suffix[code];

                code = s->prefix[code];

            }

            *sp++ = code;

            if (s->slot < s->top_slot) {

                s->suffix[s->slot] = fc = code;

                s->prefix[s->slot++] = oc;

                oc = c;

            }

            if (s->slot >= s->top_slot) {

                if (s->cursize < MAXBITS) {

                    s->top_slot <<= 1;

                    s->curmask = mask[++s->cursize];

                }

            }

            while (sp > s->stack) {

                *buf++ = *(--sp);

                if ((--l) == 0)

                    goto the_end;

            }

        }

    }

  the_end:

    s->sp = sp;

    s->oc = oc;

    s->fc = fc;

    return len - l;

}

static int GLZWDecode(GifState * s, uint8_t * buf, int len)

{

    int l, c, code, oc, fc;

    uint8_t *sp;



    if (s->end_code < 0)

        return 0;



    l = len;

    sp = s->sp;

    oc = s->oc;

    fc = s->fc;



    while (sp > s->stack) {

        *buf++ = *(--sp);

        if ((--l) == 0)

            goto the_end;

    }



    for (;;) {

        c = GetCode(s);

        if (c == s->end_code) {

            s->end_code = -1;

            break;

        } else if (c == s->clear_code) {

            s->cursize = s->codesize + 1;

            s->curmask = mask[s->cursize];

            s->slot = s->newcodes;

            s->top_slot = 1 << s->cursize;

            while ((c = GetCode(s)) == s->clear_code);

            if (c == s->end_code) {

                s->end_code = -1;

                break;

            }

            

            if (c >= s->slot)

                c = 0;

            fc = oc = c;

            *buf++ = c;

            if ((--l) == 0)

                break;

        } else {

            code = c;

            if (code >= s->slot) {

                *sp++ = fc;

                code = oc;

            }

            while (code >= s->newcodes) {

                *sp++ = s->suffix[code];

                code = s->prefix[code];

            }

            *sp++ = code;

            if (s->slot < s->top_slot) {

                s->suffix[s->slot] = fc = code;

                s->prefix[s->slot++] = oc;

                oc = c;

            }

            if (s->slot >= s->top_slot) {

                if (s->cursize < MAXBITS) {

                    s->top_slot <<= 1;

                    s->curmask = mask[++s->cursize];

                }

            }

            while (sp > s->stack) {

                *buf++ = *(--sp);

                if ((--l) == 0)

                    goto the_end;

            }

        }

    }

  the_end:

    s->sp = sp;

    s->oc = oc;

    s->fc = fc;

    return len - l;

}

    uint8_t *sp;         return 0;             break;                 break; static int GLZWDecode(GifState * s, uint8_t * buf, int len)     int l, c, code, oc, fc;     uint8_t *sp;     if (s->end_code < 0)         return 0;     l = len;     sp = s->sp;     oc = s->oc;     fc = s->fc;     while (sp > s->stack) {         *buf++ = *(--sp);         if ((--l) == 0)             goto the_end;     for (;;) {         c = GetCode(s);         if (c == s->end_code) {             s->end_code = -1;             break;         } else if (c == s->clear_code) {             s->cursize = s->codesize + 1;             s->curmask = mask[s->cursize];             s->slot = s->newcodes;             s->top_slot = 1 << s->cursize;             while ((c = GetCode(s)) == s->clear_code);             if (c == s->end_code) {                 s->end_code = -1;                 break;             if (c >= s->slot)                 c = 0;             fc = oc = c;             *buf++ = c;             if ((--l) == 0)                 break;         } else {             code = c;             if (code >= s->slot) {                 *sp++ = fc;                 code = oc;             while (code >= s->newcodes) {                 *sp++ = s->suffix[code];                 code = s->prefix[code];             *sp++ = code;             if (s->slot < s->top_slot) {                 s->suffix[s->slot] = fc = code;                 s->prefix[s->slot++] = oc;                 oc = c;             if (s->slot >= s->top_slot) {                 if (s->cursize < MAXBITS) {                     s->top_slot <<= 1;                     s->curmask = mask[++s->cursize];             while (sp > s->stack) {                 *buf++ = *(--sp);                 if ((--l) == 0)                     goto the_end;   the_end:     s->sp = sp;     s->oc = oc;     s->fc = fc;     return len - l;         } else {                 break;                 break;                 break;         } else {     for (;;) {             goto the_end;             goto the_end;             break;             goto the_end;   the_end:
static int FUNC_0(GifState * VAR_0, uint8_t * VAR_1, int VAR_2)

{

    int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;

    uint8_t *sp;



    if (VAR_0->end_code < 0)

        return 0;



    VAR_3 = VAR_2;

    sp = VAR_0->sp;

    VAR_6 = VAR_0->VAR_6;

    VAR_7 = VAR_0->VAR_7;



    while (sp > VAR_0->stack) {

        *VAR_1++ = *(--sp);

        if ((--VAR_3) == 0)

            goto the_end;

    }



    for (;;) {

        VAR_4 = GetCode(VAR_0);

        if (VAR_4 == VAR_0->end_code) {

            VAR_0->end_code = -1;

            break;

        } else if (VAR_4 == VAR_0->clear_code) {

            VAR_0->cursize = VAR_0->codesize + 1;

            VAR_0->curmask = mask[VAR_0->cursize];

            VAR_0->slot = VAR_0->newcodes;

            VAR_0->top_slot = 1 << VAR_0->cursize;

            while ((VAR_4 = GetCode(VAR_0)) == VAR_0->clear_code);

            if (VAR_4 == VAR_0->end_code) {

                VAR_0->end_code = -1;

                break;

            }

            

            if (VAR_4 >= VAR_0->slot)

                VAR_4 = 0;

            VAR_7 = VAR_6 = VAR_4;

            *VAR_1++ = VAR_4;

            if ((--VAR_3) == 0)

                break;

        } else {

            VAR_5 = VAR_4;

            if (VAR_5 >= VAR_0->slot) {

                *sp++ = VAR_7;

                VAR_5 = VAR_6;

            }

            while (VAR_5 >= VAR_0->newcodes) {

                *sp++ = VAR_0->suffix[VAR_5];

                VAR_5 = VAR_0->prefix[VAR_5];

            }

            *sp++ = VAR_5;

            if (VAR_0->slot < VAR_0->top_slot) {

                VAR_0->suffix[VAR_0->slot] = VAR_7 = VAR_5;

                VAR_0->prefix[VAR_0->slot++] = VAR_6;

                VAR_6 = VAR_4;

            }

            if (VAR_0->slot >= VAR_0->top_slot) {

                if (VAR_0->cursize < MAXBITS) {

                    VAR_0->top_slot <<= 1;

                    VAR_0->curmask = mask[++VAR_0->cursize];

                }

            }

            while (sp > VAR_0->stack) {

                *VAR_1++ = *(--sp);

                if ((--VAR_3) == 0)

                    goto the_end;

            }

        }

    }

  the_end:

    VAR_0->sp = sp;

    VAR_0->VAR_6 = VAR_6;

    VAR_0->VAR_7 = VAR_7;

    return VAR_2 - VAR_3;

}

static int FUNC_0(GifState * VAR_0, uint8_t * VAR_1, int VAR_2)
{ int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7; uint8_t *sp; if (VAR_0->end_code < 0)
return 0; VAR_3 = VAR_2; sp = VAR_0->sp; VAR_6 = VAR_0->VAR_6; VAR_7 = VAR_0->VAR_7; while (sp > VAR_0->stack) { *VAR_1++ = *(--sp); if ((--VAR_3) == 0)
goto the_end; } for (;;) { VAR_4 = GetCode(VAR_0); if (VAR_4 == VAR_0->end_code) { VAR_0->end_code = -1; break; } else if (VAR_4 == VAR_0->clear_code) { VAR_0->cursize = VAR_0->codesize + 1; VAR_0->curmask = mask[VAR_0->cursize]; VAR_0->slot = VAR_0->newcodes; VAR_0->top_slot = 1 << VAR_0->cursize; while ((VAR_4 = GetCode(VAR_0)) == VAR_0->clear_code); if (VAR_4 == VAR_0->end_code) { VAR_0->end_code = -1; break; } if (VAR_4 >= VAR_0->slot)
VAR_4 = 0; VAR_7 = VAR_6 = VAR_4; *VAR_1++ = VAR_4; if ((--VAR_3) == 0)
break; } else { VAR_5 = VAR_4; if (VAR_5 >= VAR_0->slot) { *sp++ = VAR_7; VAR_5 = VAR_6; } while (VAR_5 >= VAR_0->newcodes) { *sp++ = VAR_0->suffix[VAR_5]; VAR_5 = VAR_0->prefix[VAR_5]; } *sp++ = VAR_5; if (VAR_0->slot < VAR_0->top_slot) { VAR_0->suffix[VAR_0->slot] = VAR_7 = VAR_5; VAR_0->prefix[VAR_0->slot++] = VAR_6; VAR_6 = VAR_4; } if (VAR_0->slot >= VAR_0->top_slot) { if (VAR_0->cursize < MAXBITS) { VAR_0->top_slot <<= 1; VAR_0->curmask = mask[++VAR_0->cursize]; } } while (sp > VAR_0->stack) { *VAR_1++ = *(--sp); if ((--VAR_3) == 0)
goto the_end; } } } the_end:
VAR_0->sp = sp; VAR_0->VAR_6 = VAR_6; VAR_0->VAR_7 = VAR_7; return VAR_2 - VAR_3; }