static int inet_connect_addr(struct addrinfo *addr, bool block,

                             bool *in_progress)

{

    int sock, rc;



    if (in_progress) {

        *in_progress = false;

    }



    sock = qemu_socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);

    if (sock < 0) {

        fprintf(stderr, "%s: socket(%s): %s\n", __func__,

                inet_strfamily(addr->ai_family), strerror(errno));

        return -1;

    }

    setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));

    if (!block) {

        socket_set_nonblock(sock);

    }

    /* connect to peer */

    do {

        rc = 0;

        if (connect(sock, addr->ai_addr, addr->ai_addrlen) < 0) {

            rc = -socket_error();

        }

    } while (rc == -EINTR);



    if (!block && QEMU_SOCKET_RC_INPROGRESS(rc)) {

        if (in_progress) {

            *in_progress = true;

        }

    } else if (rc < 0) {

        closesocket(sock);

        return -1;

    }

    return sock;

}

static int inet_connect_addr(struct addrinfo *addr, bool block,

                             bool *in_progress)

{

    int sock, rc;



    if (in_progress) {

        *in_progress = false;

    }



    sock = qemu_socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);

    if (sock < 0) {

        fprintf(stderr, "%s: socket(%s): %s\n", __func__,

                inet_strfamily(addr->ai_family), strerror(errno));

        return -1;

    }

    setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));

    if (!block) {

        socket_set_nonblock(sock);

    }

    

    do {

        rc = 0;

        if (connect(sock, addr->ai_addr, addr->ai_addrlen) < 0) {

            rc = -socket_error();

        }

    } while (rc == -EINTR);



    if (!block && QEMU_SOCKET_RC_INPROGRESS(rc)) {

        if (in_progress) {

            *in_progress = true;

        }

    } else if (rc < 0) {

        closesocket(sock);

        return -1;

    }

    return sock;

}

    do {     if (in_progress) { static int inet_connect_addr(struct addrinfo *addr, bool block,                              bool *in_progress)     int sock, rc;     if (in_progress) {         *in_progress = false;     if (!block) {     if (!block && QEMU_SOCKET_RC_INPROGRESS(rc)) {         if (in_progress) {             *in_progress = true;     if (in_progress) {         *in_progress = false;
static int FUNC_0(struct addrinfo *VAR_0, bool VAR_1,

                             bool *VAR_2)

{

    int VAR_3, VAR_4;



    if (VAR_2) {

        *VAR_2 = false;

    }



    VAR_3 = qemu_socket(VAR_0->ai_family, VAR_0->ai_socktype, VAR_0->ai_protocol);

    if (VAR_3 < 0) {

        fprintf(stderr, "%s: socket(%s): %s\n", __func__,

                inet_strfamily(VAR_0->ai_family), strerror(errno));

        return -1;

    }

    setsockopt(VAR_3, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));

    if (!VAR_1) {

        socket_set_nonblock(VAR_3);

    }

    

    do {

        VAR_4 = 0;

        if (connect(VAR_3, VAR_0->ai_addr, VAR_0->ai_addrlen) < 0) {

            VAR_4 = -socket_error();

        }

    } while (VAR_4 == -EINTR);



    if (!VAR_1 && QEMU_SOCKET_RC_INPROGRESS(VAR_4)) {

        if (VAR_2) {

            *VAR_2 = true;

        }

    } else if (VAR_4 < 0) {

        closesocket(VAR_3);

        return -1;

    }

    return VAR_3;

}

static int FUNC_0(struct addrinfo *VAR_0, bool VAR_1,
bool *VAR_2)
{ int VAR_3, VAR_4; if (VAR_2) { *VAR_2 = false; } VAR_3 = qemu_socket(VAR_0->ai_family, VAR_0->ai_socktype, VAR_0->ai_protocol); if (VAR_3 < 0) { fprintf(stderr, "%s: socket(%s): %s\n", __func__,
inet_strfamily(VAR_0->ai_family), strerror(errno)); return -1; } setsockopt(VAR_3, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); if (!VAR_1) { socket_set_nonblock(VAR_3); } do { VAR_4 = 0; if (connect(VAR_3, VAR_0->ai_addr, VAR_0->ai_addrlen) < 0) { VAR_4 = -socket_error(); } } while (VAR_4 == -EINTR); if (!VAR_1 && QEMU_SOCKET_RC_INPROGRESS(VAR_4)) { if (VAR_2) { *VAR_2 = true; } } else if (VAR_4 < 0) { closesocket(VAR_3); return -1; } return VAR_3; }