static int do_sendv_recvv(int sockfd, struct iovec *iov, int len, int offset,

                          int do_sendv)

{

    int ret, diff, iovlen;

    struct iovec *last_iov;



    /* last_iov is inclusive, so count from one.  */

    iovlen = 1;

    last_iov = iov;

    len += offset;



    while (last_iov->iov_len < len) {

        len -= last_iov->iov_len;



        last_iov++;

        iovlen++;

    }



    diff = last_iov->iov_len - len;

    last_iov->iov_len -= diff;



    while (iov->iov_len <= offset) {

        offset -= iov->iov_len;



        iov++;

        iovlen--;

    }



    iov->iov_base = (char *) iov->iov_base + offset;

    iov->iov_len -= offset;



    {

#if defined CONFIG_IOVEC && defined CONFIG_POSIX

        struct msghdr msg;

        memset(&msg, 0, sizeof(msg));

        msg.msg_iov = iov;

        msg.msg_iovlen = iovlen;



        do {

            if (do_sendv) {

                ret = sendmsg(sockfd, &msg, 0);

            } else {

                ret = recvmsg(sockfd, &msg, 0);

            }

        } while (ret == -1 && errno == EINTR);

#else

        struct iovec *p = iov;

        ret = 0;

        while (iovlen > 0) {

            int rc;

            if (do_sendv) {

                rc = send(sockfd, p->iov_base, p->iov_len, 0);

            } else {

                rc = qemu_recv(sockfd, p->iov_base, p->iov_len, 0);

            }

            if (rc == -1) {

                if (errno == EINTR) {

                    continue;

                }

                if (ret == 0) {

                    ret = -1;

                }

                break;

            }

            if (rc == 0) {

                break;

            }

            ret += rc;

            iovlen--, p++;

        }

#endif

    }



    /* Undo the changes above */

    iov->iov_base = (char *) iov->iov_base - offset;

    iov->iov_len += offset;

    last_iov->iov_len += diff;

    return ret;

}

static int do_sendv_recvv(int sockfd, struct iovec *iov, int len, int offset,

                          int do_sendv)

{

    int ret, diff, iovlen;

    struct iovec *last_iov;



    

    iovlen = 1;

    last_iov = iov;

    len += offset;



    while (last_iov->iov_len < len) {

        len -= last_iov->iov_len;



        last_iov++;

        iovlen++;

    }



    diff = last_iov->iov_len - len;

    last_iov->iov_len -= diff;



    while (iov->iov_len <= offset) {

        offset -= iov->iov_len;



        iov++;

        iovlen--;

    }



    iov->iov_base = (char *) iov->iov_base + offset;

    iov->iov_len -= offset;



    {

#if defined CONFIG_IOVEC && defined CONFIG_POSIX

        struct msghdr msg;

        memset(&msg, 0, sizeof(msg));

        msg.msg_iov = iov;

        msg.msg_iovlen = iovlen;



        do {

            if (do_sendv) {

                ret = sendmsg(sockfd, &msg, 0);

            } else {

                ret = recvmsg(sockfd, &msg, 0);

            }

        } while (ret == -1 && errno == EINTR);

#else

        struct iovec *p = iov;

        ret = 0;

        while (iovlen > 0) {

            int rc;

            if (do_sendv) {

                rc = send(sockfd, p->iov_base, p->iov_len, 0);

            } else {

                rc = qemu_recv(sockfd, p->iov_base, p->iov_len, 0);

            }

            if (rc == -1) {

                if (errno == EINTR) {

                    continue;

                }

                if (ret == 0) {

                    ret = -1;

                }

                break;

            }

            if (rc == 0) {

                break;

            }

            ret += rc;

            iovlen--, p++;

        }

#endif

    }



    

    iov->iov_base = (char *) iov->iov_base - offset;

    iov->iov_len += offset;

    last_iov->iov_len += diff;

    return ret;

}

static int do_sendv_recvv(int sockfd, struct iovec *iov, int len, int offset,     int ret, diff, iovlen;     len += offset;     while (last_iov->iov_len < len) {         len -= last_iov->iov_len;     diff = last_iov->iov_len - len;
static int FUNC_0(int VAR_0, struct iovec *VAR_1, int VAR_2, int VAR_3,

                          int VAR_4)

{

    int VAR_5, VAR_6, VAR_7;

    struct iovec *VAR_8;



    

    VAR_7 = 1;

    VAR_8 = VAR_1;

    VAR_2 += VAR_3;



    while (VAR_8->iov_len < VAR_2) {

        VAR_2 -= VAR_8->iov_len;



        VAR_8++;

        VAR_7++;

    }



    VAR_6 = VAR_8->iov_len - VAR_2;

    VAR_8->iov_len -= VAR_6;



    while (VAR_1->iov_len <= VAR_3) {

        VAR_3 -= VAR_1->iov_len;



        VAR_1++;

        VAR_7--;

    }



    VAR_1->iov_base = (char *) VAR_1->iov_base + VAR_3;

    VAR_1->iov_len -= VAR_3;



    {

#if defined CONFIG_IOVEC && defined CONFIG_POSIX

        struct msghdr msg;

        memset(&msg, 0, sizeof(msg));

        msg.msg_iov = VAR_1;

        msg.msg_iovlen = VAR_7;



        do {

            if (VAR_4) {

                VAR_5 = sendmsg(VAR_0, &msg, 0);

            } else {

                VAR_5 = recvmsg(VAR_0, &msg, 0);

            }

        } while (VAR_5 == -1 && errno == EINTR);

#else

        struct iovec *VAR_9 = VAR_1;

        VAR_5 = 0;

        while (VAR_7 > 0) {

            int VAR_10;

            if (VAR_4) {

                VAR_10 = send(VAR_0, VAR_9->iov_base, VAR_9->iov_len, 0);

            } else {

                VAR_10 = qemu_recv(VAR_0, VAR_9->iov_base, VAR_9->iov_len, 0);

            }

            if (VAR_10 == -1) {

                if (errno == EINTR) {

                    continue;

                }

                if (VAR_5 == 0) {

                    VAR_5 = -1;

                }

                break;

            }

            if (VAR_10 == 0) {

                break;

            }

            VAR_5 += VAR_10;

            VAR_7--, VAR_9++;

        }

#endif

    }



    

    VAR_1->iov_base = (char *) VAR_1->iov_base - VAR_3;

    VAR_1->iov_len += VAR_3;

    VAR_8->iov_len += VAR_6;

    return VAR_5;

}

static int FUNC_0(int VAR_0, struct iovec *VAR_1, int VAR_2, int VAR_3,
int VAR_4)
{ int VAR_5, VAR_6, VAR_7; struct iovec *VAR_8; VAR_7 = 1; VAR_8 = VAR_1; VAR_2 += VAR_3; while (VAR_8->iov_len < VAR_2) { VAR_2 -= VAR_8->iov_len; VAR_8++; VAR_7++; } VAR_6 = VAR_8->iov_len - VAR_2; VAR_8->iov_len -= VAR_6; while (VAR_1->iov_len <= VAR_3) { VAR_3 -= VAR_1->iov_len; VAR_1++; VAR_7--; } VAR_1->iov_base = (char *) VAR_1->iov_base + VAR_3; VAR_1->iov_len -= VAR_3; { #if defined CONFIG_IOVEC && defined CONFIG_POSIX
struct msghdr msg; memset(&msg, 0, sizeof(msg)); msg.msg_iov = VAR_1; msg.msg_iovlen = VAR_7; do { if (VAR_4) { VAR_5 = sendmsg(VAR_0, &msg, 0); } else { VAR_5 = recvmsg(VAR_0, &msg, 0); } } while (VAR_5 == -1 && errno == EINTR); #else
struct iovec *VAR_9 = VAR_1; VAR_5 = 0; while (VAR_7 > 0) { int VAR_10; if (VAR_4) { VAR_10 = send(VAR_0, VAR_9->iov_base, VAR_9->iov_len, 0); } else { VAR_10 = qemu_recv(VAR_0, VAR_9->iov_base, VAR_9->iov_len, 0); } if (VAR_10 == -1) { if (errno == EINTR) { continue; } if (VAR_5 == 0) { VAR_5 = -1; } break; } if (VAR_10 == 0) { break; } VAR_5 += VAR_10; VAR_7--, VAR_9++; } #endif
} VAR_1->iov_base = (char *) VAR_1->iov_base - VAR_3; VAR_1->iov_len += VAR_3; VAR_8->iov_len += VAR_6; return VAR_5; }