static int expand_rle_row(const uint8_t *in_buf, const uint8_t* in_end,

            unsigned char *out_buf, uint8_t* out_end, int pixelstride)

{

    unsigned char pixel, count;

    unsigned char *orig = out_buf;



    while (1) {

        if(in_buf + 1 > in_end) return -1;

        pixel = bytestream_get_byte(&in_buf);

        if (!(count = (pixel & 0x7f))) {

            return (out_buf - orig) / pixelstride;

        }



        /* Check for buffer overflow. */

        if(out_buf + pixelstride * count >= out_end) return -1;



        if (pixel & 0x80) {

            while (count--) {

                *out_buf = bytestream_get_byte(&in_buf);

                out_buf += pixelstride;

            }

        } else {

            pixel = bytestream_get_byte(&in_buf);



            while (count--) {

                *out_buf = pixel;

                out_buf += pixelstride;

            }

        }

    }

}

static int expand_rle_row(const uint8_t *in_buf, const uint8_t* in_end,

            unsigned char *out_buf, uint8_t* out_end, int pixelstride)

{

    unsigned char pixel, count;

    unsigned char *orig = out_buf;



    while (1) {

        if(in_buf + 1 > in_end) return -1;

        pixel = bytestream_get_byte(&in_buf);

        if (!(count = (pixel & 0x7f))) {

            return (out_buf - orig) / pixelstride;

        }



        

        if(out_buf + pixelstride * count >= out_end) return -1;



        if (pixel & 0x80) {

            while (count--) {

                *out_buf = bytestream_get_byte(&in_buf);

                out_buf += pixelstride;

            }

        } else {

            pixel = bytestream_get_byte(&in_buf);



            while (count--) {

                *out_buf = pixel;

                out_buf += pixelstride;

            }

        }

    }

}

static int expand_rle_row(const uint8_t *in_buf, const uint8_t* in_end,             unsigned char *out_buf, uint8_t* out_end, int pixelstride)         if(in_buf + 1 > in_end) return -1;         pixel = bytestream_get_byte(&in_buf);                 *out_buf = bytestream_get_byte(&in_buf);             pixel = bytestream_get_byte(&in_buf);
static int FUNC_0(const uint8_t *VAR_0, const uint8_t* VAR_1,

            unsigned char *VAR_2, uint8_t* VAR_3, int VAR_4)

{

    unsigned char VAR_5, VAR_6;

    unsigned char *VAR_7 = VAR_2;



    while (1) {

        if(VAR_0 + 1 > VAR_1) return -1;

        VAR_5 = bytestream_get_byte(&VAR_0);

        if (!(VAR_6 = (VAR_5 & 0x7f))) {

            return (VAR_2 - VAR_7) / VAR_4;

        }



        

        if(VAR_2 + VAR_4 * VAR_6 >= VAR_3) return -1;



        if (VAR_5 & 0x80) {

            while (VAR_6--) {

                *VAR_2 = bytestream_get_byte(&VAR_0);

                VAR_2 += VAR_4;

            }

        } else {

            VAR_5 = bytestream_get_byte(&VAR_0);



            while (VAR_6--) {

                *VAR_2 = VAR_5;

                VAR_2 += VAR_4;

            }

        }

    }

}

static int FUNC_0(const uint8_t *VAR_0, const uint8_t* VAR_1,
unsigned char *VAR_2, uint8_t* VAR_3, int VAR_4)
{ unsigned char VAR_5, VAR_6; unsigned char *VAR_7 = VAR_2; while (1) { if(VAR_0 + 1 > VAR_1) return -1; VAR_5 = bytestream_get_byte(&VAR_0); if (!(VAR_6 = (VAR_5 & 0x7f))) { return (VAR_2 - VAR_7) / VAR_4; } if(VAR_2 + VAR_4 * VAR_6 >= VAR_3) return -1; if (VAR_5 & 0x80) { while (VAR_6--) { *VAR_2 = bytestream_get_byte(&VAR_0); VAR_2 += VAR_4; } } else { VAR_5 = bytestream_get_byte(&VAR_0); while (VAR_6--) { *VAR_2 = VAR_5; VAR_2 += VAR_4; } } } }