static int tight_compress_data(VncState *vs, int stream_id, size_t bytes,

                               int level, int strategy)

{

    z_streamp zstream = &vs->tight.stream[stream_id];

    int previous_out;



    if (bytes < VNC_TIGHT_MIN_TO_COMPRESS) {

        vnc_write(vs, vs->tight.tight.buffer, vs->tight.tight.offset);

        return bytes;

    }



    if (tight_init_stream(vs, stream_id, level, strategy)) {

        return -1;

    }



    /* reserve memory in output buffer */

    buffer_reserve(&vs->tight.zlib, bytes + 64);



    /* set pointers */

    zstream->next_in = vs->tight.tight.buffer;

    zstream->avail_in = vs->tight.tight.offset;

    zstream->next_out = vs->tight.zlib.buffer + vs->tight.zlib.offset;

    zstream->avail_out = vs->tight.zlib.capacity - vs->tight.zlib.offset;

    zstream->data_type = Z_BINARY;

    previous_out = zstream->total_out;



    /* start encoding */

    if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) {

        fprintf(stderr, "VNC: error during tight compression\n");

        return -1;

    }



    vs->tight.zlib.offset = vs->tight.zlib.capacity - zstream->avail_out;

    bytes = zstream->total_out - previous_out;



    tight_send_compact_size(vs, bytes);

    vnc_write(vs, vs->tight.zlib.buffer, bytes);



    buffer_reset(&vs->tight.zlib);



    return bytes;

}

static int tight_compress_data(VncState *vs, int stream_id, size_t bytes,

                               int level, int strategy)

{

    z_streamp zstream = &vs->tight.stream[stream_id];

    int previous_out;



    if (bytes < VNC_TIGHT_MIN_TO_COMPRESS) {

        vnc_write(vs, vs->tight.tight.buffer, vs->tight.tight.offset);

        return bytes;

    }



    if (tight_init_stream(vs, stream_id, level, strategy)) {

        return -1;

    }



    

    buffer_reserve(&vs->tight.zlib, bytes + 64);



    

    zstream->next_in = vs->tight.tight.buffer;

    zstream->avail_in = vs->tight.tight.offset;

    zstream->next_out = vs->tight.zlib.buffer + vs->tight.zlib.offset;

    zstream->avail_out = vs->tight.zlib.capacity - vs->tight.zlib.offset;

    zstream->data_type = Z_BINARY;

    previous_out = zstream->total_out;



    

    if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) {

        fprintf(stderr, "VNC: error during tight compression\n");

        return -1;

    }



    vs->tight.zlib.offset = vs->tight.zlib.capacity - zstream->avail_out;

    bytes = zstream->total_out - previous_out;



    tight_send_compact_size(vs, bytes);

    vnc_write(vs, vs->tight.zlib.buffer, bytes);



    buffer_reset(&vs->tight.zlib);



    return bytes;

}

    previous_out = zstream->total_out;     bytes = zstream->total_out - previous_out;     previous_out = zstream->total_out;
static int FUNC_0(VncState *VAR_0, int VAR_1, size_t VAR_2,

                               int VAR_3, int VAR_4)

{

    z_streamp zstream = &VAR_0->tight.stream[VAR_1];

    int VAR_5;



    if (VAR_2 < VNC_TIGHT_MIN_TO_COMPRESS) {

        vnc_write(VAR_0, VAR_0->tight.tight.buffer, VAR_0->tight.tight.offset);

        return VAR_2;

    }



    if (tight_init_stream(VAR_0, VAR_1, VAR_3, VAR_4)) {

        return -1;

    }



    

    buffer_reserve(&VAR_0->tight.zlib, VAR_2 + 64);



    

    zstream->next_in = VAR_0->tight.tight.buffer;

    zstream->avail_in = VAR_0->tight.tight.offset;

    zstream->next_out = VAR_0->tight.zlib.buffer + VAR_0->tight.zlib.offset;

    zstream->avail_out = VAR_0->tight.zlib.capacity - VAR_0->tight.zlib.offset;

    zstream->data_type = Z_BINARY;

    VAR_5 = zstream->total_out;



    

    if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) {

        fprintf(stderr, "VNC: error during tight compression\n");

        return -1;

    }



    VAR_0->tight.zlib.offset = VAR_0->tight.zlib.capacity - zstream->avail_out;

    VAR_2 = zstream->total_out - VAR_5;



    tight_send_compact_size(VAR_0, VAR_2);

    vnc_write(VAR_0, VAR_0->tight.zlib.buffer, VAR_2);



    buffer_reset(&VAR_0->tight.zlib);



    return VAR_2;

}

static int FUNC_0(VncState *VAR_0, int VAR_1, size_t VAR_2,
int VAR_3, int VAR_4)
{ z_streamp zstream = &VAR_0->tight.stream[VAR_1]; int VAR_5; if (VAR_2 < VNC_TIGHT_MIN_TO_COMPRESS) { vnc_write(VAR_0, VAR_0->tight.tight.buffer, VAR_0->tight.tight.offset); return VAR_2; } if (tight_init_stream(VAR_0, VAR_1, VAR_3, VAR_4)) { return -1; } buffer_reserve(&VAR_0->tight.zlib, VAR_2 + 64); zstream->next_in = VAR_0->tight.tight.buffer; zstream->avail_in = VAR_0->tight.tight.offset; zstream->next_out = VAR_0->tight.zlib.buffer + VAR_0->tight.zlib.offset; zstream->avail_out = VAR_0->tight.zlib.capacity - VAR_0->tight.zlib.offset; zstream->data_type = Z_BINARY; VAR_5 = zstream->total_out; if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) { fprintf(stderr, "VNC: error during tight compression\n"); return -1; } VAR_0->tight.zlib.offset = VAR_0->tight.zlib.capacity - zstream->avail_out; VAR_2 = zstream->total_out - VAR_5; tight_send_compact_size(VAR_0, VAR_2); vnc_write(VAR_0, VAR_0->tight.zlib.buffer, VAR_2); buffer_reset(&VAR_0->tight.zlib); return VAR_2; }