if (stackp == stack + MAX_BITS) return -1;
static int do_lzw(gif_struct *gs, const PRUint8 *q){  int code;  int incode;  const PRUint8 *ch;  /* Copy all the decoder state variables into locals so the compiler   * won't worry about them being aliased.  The locals will be homed   * back into the GIF decoder structure when we exit.   */  int avail       = gs->avail;  int bits        = gs->bits;  int codesize    = gs->codesize;  int codemask    = gs->codemask;  int count       = gs->count;  int oldcode     = gs->oldcode;  int clear_code  = gs->clear_code;  PRUint8 firstchar = gs->firstchar;  PRInt32 datum     = gs->datum;  PRUint16 *prefix  = gs->prefix;  PRUint8 *stackp   = gs->stackp;  PRUint8 *suffix   = gs->suffix;  PRUint8 *stack    = gs->stack;  PRUint8 *rowp     = gs->rowp;  PRUint8 *rowend   = gs->rowend;  PRUintn rows_remaining = gs->rows_remaining;  if (rowp == rowend)    return 0;#define OUTPUT_ROW(gs)                                                  \  PR_BEGIN_MACRO                                                        \    output_row(gs);                                                     \    rows_remaining--;                                                   \    rowp = gs->rowp;                                                    \    if (!rows_remaining)                                                \      goto END;                                                         \  PR_END_MACRO  for (ch = q; count-- > 0; ch++)  {    /* Feed the next byte into the decoder's 32-bit input buffer. */    datum += ((int32) *ch) << bits;    bits += 8;    /* Check for underflow of decoder's 32-bit input buffer. */    while (bits >= codesize)    {      /* Get the leading variable-length symbol from the data stream */      code = datum & codemask;      datum >>= codesize;      bits -= codesize;      /* Reset the dictionary to its original state, if requested */      if (code == clear_code) {        codesize = gs->datasize + 1;        codemask = (1 << codesize) - 1;        avail = clear_code + 2;        oldcode = -1;        continue;      }      /* Check for explicit end-of-stream code */      if (code == (clear_code + 1))        return 0;      if (oldcode == -1) {        *rowp++ = suffix[code];        if (rowp == rowend)          OUTPUT_ROW(gs);        firstchar = oldcode = code;        continue;      }      /* Check for a code not defined in the dictionary yet. */      if (code > avail)        return -1;      incode = code;      if (code == avail) {        /* the first code is always < avail */        *stackp++ = firstchar;        code = oldcode;      }      int code2 = 0;      while (code > clear_code)      {        code2 = code;        if (code == prefix[code])          return -1;        *stackp++ = suffix[code];        code = prefix[code];        if (code2 == prefix[code])          return -1;      }      *stackp++ = firstchar = suffix[code];      /* Define a new codeword in the dictionary. */      if (avail < 4096) {        prefix[avail] = oldcode;        suffix[avail] = firstchar;        avail++;        /* If we've used up all the codewords of a given length         * increase the length of codewords by one bit, but don't         * exceed the specified maximum codeword size of 12 bits.         */        if (((avail & codemask) == 0) && (avail < 4096)) {          codesize++;          codemask += avail;        }      }      oldcode = incode;        /* Copy the decoded data out to the scanline buffer. */      do {        *rowp++ = *--stackp;        if (rowp == rowend) {          OUTPUT_ROW(gs);        }      } while (stackp > stack);    }  }  END:  /* Home the local copies of the GIF decoder state variables */  gs->avail = avail;  gs->bits = bits;  gs->codesize = codesize;  gs->codemask = codemask;  gs->count = count;  gs->oldcode = oldcode;  gs->firstchar = firstchar;  gs->datum = datum;  gs->stackp = stackp;  gs->rowp = rowp;  gs->rows_remaining = rows_remaining;  return 0;}