void monitor_flush(Monitor *mon)

{

    int rc;

    size_t len;

    const char *buf;



    if (mon->skip_flush) {

        return;

    }



    buf = qstring_get_str(mon->outbuf);

    len = qstring_get_length(mon->outbuf);



    if (len && !mon->mux_out) {

        rc = qemu_chr_fe_write(mon->chr, (const uint8_t *) buf, len);

        if (rc == len) {

            /* all flushed */

            QDECREF(mon->outbuf);

            mon->outbuf = qstring_new();

            return;

        }

        if (rc > 0) {

            /* partinal write */

            QString *tmp = qstring_from_str(buf + rc);

            QDECREF(mon->outbuf);

            mon->outbuf = tmp;

        }

        if (mon->watch == 0) {

            mon->watch = qemu_chr_fe_add_watch(mon->chr, G_IO_OUT,

                                               monitor_unblocked, mon);

        }

    }

}

void monitor_flush(Monitor *mon)

{

    int rc;

    size_t len;

    const char *buf;



    if (mon->skip_flush) {

        return;

    }



    buf = qstring_get_str(mon->outbuf);

    len = qstring_get_length(mon->outbuf);



    if (len && !mon->mux_out) {

        rc = qemu_chr_fe_write(mon->chr, (const uint8_t *) buf, len);

        if (rc == len) {

            

            QDECREF(mon->outbuf);

            mon->outbuf = qstring_new();

            return;

        }

        if (rc > 0) {

            

            QString *tmp = qstring_from_str(buf + rc);

            QDECREF(mon->outbuf);

            mon->outbuf = tmp;

        }

        if (mon->watch == 0) {

            mon->watch = qemu_chr_fe_add_watch(mon->chr, G_IO_OUT,

                                               monitor_unblocked, mon);

        }

    }

}

        if (rc == len) {
void FUNC_0(Monitor *VAR_0)

{

    int VAR_1;

    size_t len;

    const char *VAR_2;



    if (VAR_0->skip_flush) {

        return;

    }



    VAR_2 = qstring_get_str(VAR_0->outbuf);

    len = qstring_get_length(VAR_0->outbuf);



    if (len && !VAR_0->mux_out) {

        VAR_1 = qemu_chr_fe_write(VAR_0->chr, (const uint8_t *) VAR_2, len);

        if (VAR_1 == len) {

            

            QDECREF(VAR_0->outbuf);

            VAR_0->outbuf = qstring_new();

            return;

        }

        if (VAR_1 > 0) {

            

            QString *tmp = qstring_from_str(VAR_2 + VAR_1);

            QDECREF(VAR_0->outbuf);

            VAR_0->outbuf = tmp;

        }

        if (VAR_0->watch == 0) {

            VAR_0->watch = qemu_chr_fe_add_watch(VAR_0->chr, G_IO_OUT,

                                               monitor_unblocked, VAR_0);

        }

    }

}

void FUNC_0(Monitor *VAR_0)
{ int VAR_1; size_t len; const char *VAR_2; if (VAR_0->skip_flush) { return; } VAR_2 = qstring_get_str(VAR_0->outbuf); len = qstring_get_length(VAR_0->outbuf); if (len && !VAR_0->mux_out) { VAR_1 = qemu_chr_fe_write(VAR_0->chr, (const uint8_t *) VAR_2, len); if (VAR_1 == len) { QDECREF(VAR_0->outbuf); VAR_0->outbuf = qstring_new(); return; } if (VAR_1 > 0) { QString *tmp = qstring_from_str(VAR_2 + VAR_1); QDECREF(VAR_0->outbuf); VAR_0->outbuf = tmp; } if (VAR_0->watch == 0) { VAR_0->watch = qemu_chr_fe_add_watch(VAR_0->chr, G_IO_OUT,
monitor_unblocked, VAR_0); } } }