static int vnc_update_client(VncState *vs, int has_dirty)

{

    if (vs->need_update && vs->csock != -1) {

        VncDisplay *vd = vs->vd;

        VncJob *job;

        int y;

        int width, height;

        int n = 0;





        if (vs->output.offset && !vs->audio_cap && !vs->force_update)

            /* kernel send buffers are full -> drop frames to throttle */

            return 0;



        if (!has_dirty && !vs->audio_cap && !vs->force_update)

            return 0;



        /*

         * Send screen updates to the vnc client using the server

         * surface and server dirty map.  guest surface updates

         * happening in parallel don't disturb us, the next pass will

         * send them to the client.

         */

        job = vnc_job_new(vs);



        width = MIN(pixman_image_get_width(vd->server), vs->client_width);

        height = MIN(pixman_image_get_height(vd->server), vs->client_height);



        for (y = 0; y < height; y++) {

            int x;

            int last_x = -1;

            for (x = 0; x < width / 16; x++) {

                if (test_and_clear_bit(x, vs->dirty[y])) {

                    if (last_x == -1) {

                        last_x = x;

                    }

                } else {

                    if (last_x != -1) {

                        int h = find_and_clear_dirty_height(vs, y, last_x, x,

                                                            height);



                        n += vnc_job_add_rect(job, last_x * 16, y,

                                              (x - last_x) * 16, h);

                    }

                    last_x = -1;

                }

            }

            if (last_x != -1) {

                int h = find_and_clear_dirty_height(vs, y, last_x, x, height);

                n += vnc_job_add_rect(job, last_x * 16, y,

                                      (x - last_x) * 16, h);

            }

        }



        vnc_job_push(job);

        vs->force_update = 0;

        return n;

    }



    if (vs->csock == -1)

        vnc_disconnect_finish(vs);



    return 0;

}

static int vnc_update_client(VncState *vs, int has_dirty)

{

    if (vs->need_update && vs->csock != -1) {

        VncDisplay *vd = vs->vd;

        VncJob *job;

        int y;

        int width, height;

        int n = 0;





        if (vs->output.offset && !vs->audio_cap && !vs->force_update)

            

            return 0;



        if (!has_dirty && !vs->audio_cap && !vs->force_update)

            return 0;



        











        job = vnc_job_new(vs);



        width = MIN(pixman_image_get_width(vd->server), vs->client_width);

        height = MIN(pixman_image_get_height(vd->server), vs->client_height);



        for (y = 0; y < height; y++) {

            int x;

            int last_x = -1;

            for (x = 0; x < width / 16; x++) {

                if (test_and_clear_bit(x, vs->dirty[y])) {

                    if (last_x == -1) {

                        last_x = x;

                    }

                } else {

                    if (last_x != -1) {

                        int h = find_and_clear_dirty_height(vs, y, last_x, x,

                                                            height);



                        n += vnc_job_add_rect(job, last_x * 16, y,

                                              (x - last_x) * 16, h);

                    }

                    last_x = -1;

                }

            }

            if (last_x != -1) {

                int h = find_and_clear_dirty_height(vs, y, last_x, x, height);

                n += vnc_job_add_rect(job, last_x * 16, y,

                                      (x - last_x) * 16, h);

            }

        }



        vnc_job_push(job);

        vs->force_update = 0;

        return n;

    }



    if (vs->csock == -1)

        vnc_disconnect_finish(vs);



    return 0;

}

static int vnc_update_client(VncState *vs, int has_dirty)     if (vs->csock == -1)
static int FUNC_0(VncState *VAR_0, int VAR_1)

{

    if (VAR_0->need_update && VAR_0->csock != -1) {

        VncDisplay *vd = VAR_0->vd;

        VncJob *job;

        int VAR_2;

        int VAR_3, VAR_4;

        int VAR_5 = 0;





        if (VAR_0->output.offset && !VAR_0->audio_cap && !VAR_0->force_update)

            

            return 0;



        if (!VAR_1 && !VAR_0->audio_cap && !VAR_0->force_update)

            return 0;



        











        job = vnc_job_new(VAR_0);



        VAR_3 = MIN(pixman_image_get_width(vd->server), VAR_0->client_width);

        VAR_4 = MIN(pixman_image_get_height(vd->server), VAR_0->client_height);



        for (VAR_2 = 0; VAR_2 < VAR_4; VAR_2++) {

            int VAR_6;

            int VAR_7 = -1;

            for (VAR_6 = 0; VAR_6 < VAR_3 / 16; VAR_6++) {

                if (test_and_clear_bit(VAR_6, VAR_0->dirty[VAR_2])) {

                    if (VAR_7 == -1) {

                        VAR_7 = VAR_6;

                    }

                } else {

                    if (VAR_7 != -1) {

                        int VAR_9 = find_and_clear_dirty_height(VAR_0, VAR_2, VAR_7, VAR_6,

                                                            VAR_4);



                        VAR_5 += vnc_job_add_rect(job, VAR_7 * 16, VAR_2,

                                              (VAR_6 - VAR_7) * 16, VAR_9);

                    }

                    VAR_7 = -1;

                }

            }

            if (VAR_7 != -1) {

                int VAR_9 = find_and_clear_dirty_height(VAR_0, VAR_2, VAR_7, VAR_6, VAR_4);

                VAR_5 += vnc_job_add_rect(job, VAR_7 * 16, VAR_2,

                                      (VAR_6 - VAR_7) * 16, VAR_9);

            }

        }



        vnc_job_push(job);

        VAR_0->force_update = 0;

        return VAR_5;

    }



    if (VAR_0->csock == -1)

        vnc_disconnect_finish(VAR_0);



    return 0;

}

static int FUNC_0(VncState *VAR_0, int VAR_1)
{ if (VAR_0->need_update && VAR_0->csock != -1) { VncDisplay *vd = VAR_0->vd; VncJob *job; int VAR_2; int VAR_3, VAR_4; int VAR_5 = 0; if (VAR_0->output.offset && !VAR_0->audio_cap && !VAR_0->force_update)
return 0; if (!VAR_1 && !VAR_0->audio_cap && !VAR_0->force_update)
return 0; job = vnc_job_new(VAR_0); VAR_3 = MIN(pixman_image_get_width(vd->server), VAR_0->client_width); VAR_4 = MIN(pixman_image_get_height(vd->server), VAR_0->client_height); for (VAR_2 = 0; VAR_2 < VAR_4; VAR_2++) { int VAR_6; int VAR_7 = -1; for (VAR_6 = 0; VAR_6 < VAR_3 / 16; VAR_6++) { if (test_and_clear_bit(VAR_6, VAR_0->dirty[VAR_2])) { if (VAR_7 == -1) { VAR_7 = VAR_6; } } else { if (VAR_7 != -1) { int VAR_9 = find_and_clear_dirty_height(VAR_0, VAR_2, VAR_7, VAR_6,
VAR_4); VAR_5 += vnc_job_add_rect(job, VAR_7 * 16, VAR_2,
(VAR_6 - VAR_7) * 16, VAR_9); } VAR_7 = -1; } } if (VAR_7 != -1) { int VAR_9 = find_and_clear_dirty_height(VAR_0, VAR_2, VAR_7, VAR_6, VAR_4); VAR_5 += vnc_job_add_rect(job, VAR_7 * 16, VAR_2,
(VAR_6 - VAR_7) * 16, VAR_9); } } vnc_job_push(job); VAR_0->force_update = 0; return VAR_5; } if (VAR_0->csock == -1)
vnc_disconnect_finish(VAR_0); return 0; }