static int check_bind(const char *hostname, bool *has_proto)

{

    int fd = -1;

    struct addrinfo ai, *res = NULL;

    int rc;

    int ret = -1;



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

    ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;

    ai.ai_family = AF_UNSPEC;

    ai.ai_socktype = SOCK_STREAM;



    /* lookup */

    rc = getaddrinfo(hostname, NULL, &ai, &res);

    if (rc != 0) {

        if (rc == EAI_ADDRFAMILY ||

            rc == EAI_FAMILY) {

            *has_proto = false;

            goto done;

        }

        goto cleanup;

    }



    fd = qemu_socket(res->ai_family, res->ai_socktype, res->ai_protocol);

    if (fd < 0) {

        goto cleanup;

    }



    if (bind(fd, res->ai_addr, res->ai_addrlen) < 0) {

        if (errno == EADDRNOTAVAIL) {

            *has_proto = false;

            goto done;

        }

        goto cleanup;

    }



    *has_proto = true;

 done:

    ret = 0;



 cleanup:

    if (fd != -1) {

        close(fd);

    }

    if (res) {

        freeaddrinfo(res);

    }

    return ret;

}

static int check_bind(const char *hostname, bool *has_proto)

{

    int fd = -1;

    struct addrinfo ai, *res = NULL;

    int rc;

    int ret = -1;



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

    ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;

    ai.ai_family = AF_UNSPEC;

    ai.ai_socktype = SOCK_STREAM;



    

    rc = getaddrinfo(hostname, NULL, &ai, &res);

    if (rc != 0) {

        if (rc == EAI_ADDRFAMILY ||

            rc == EAI_FAMILY) {

            *has_proto = false;

            goto done;

        }

        goto cleanup;

    }



    fd = qemu_socket(res->ai_family, res->ai_socktype, res->ai_protocol);

    if (fd < 0) {

        goto cleanup;

    }



    if (bind(fd, res->ai_addr, res->ai_addrlen) < 0) {

        if (errno == EADDRNOTAVAIL) {

            *has_proto = false;

            goto done;

        }

        goto cleanup;

    }



    *has_proto = true;

 done:

    ret = 0;



 cleanup:

    if (fd != -1) {

        close(fd);

    }

    if (res) {

        freeaddrinfo(res);

    }

    return ret;

}

    ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;     ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;
static int FUNC_0(const char *VAR_0, bool *VAR_1)

{

    int VAR_2 = -1;

    struct addrinfo VAR_3, *VAR_4 = NULL;

    int VAR_5;

    int VAR_6 = -1;



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

    VAR_3.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;

    VAR_3.ai_family = AF_UNSPEC;

    VAR_3.ai_socktype = SOCK_STREAM;



    

    VAR_5 = getaddrinfo(VAR_0, NULL, &VAR_3, &VAR_4);

    if (VAR_5 != 0) {

        if (VAR_5 == EAI_ADDRFAMILY ||

            VAR_5 == EAI_FAMILY) {

            *VAR_1 = false;

            goto done;

        }

        goto cleanup;

    }



    VAR_2 = qemu_socket(VAR_4->ai_family, VAR_4->ai_socktype, VAR_4->ai_protocol);

    if (VAR_2 < 0) {

        goto cleanup;

    }



    if (bind(VAR_2, VAR_4->ai_addr, VAR_4->ai_addrlen) < 0) {

        if (errno == EADDRNOTAVAIL) {

            *VAR_1 = false;

            goto done;

        }

        goto cleanup;

    }



    *VAR_1 = true;

 done:

    VAR_6 = 0;



 cleanup:

    if (VAR_2 != -1) {

        close(VAR_2);

    }

    if (VAR_4) {

        freeaddrinfo(VAR_4);

    }

    return VAR_6;

}

static int FUNC_0(const char *VAR_0, bool *VAR_1)
{ int VAR_2 = -1; struct addrinfo VAR_3, *VAR_4 = NULL; int VAR_5; int VAR_6 = -1; memset(&VAR_3, 0, sizeof(VAR_3)); VAR_3.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG; VAR_3.ai_family = AF_UNSPEC; VAR_3.ai_socktype = SOCK_STREAM; VAR_5 = getaddrinfo(VAR_0, NULL, &VAR_3, &VAR_4); if (VAR_5 != 0) { if (VAR_5 == EAI_ADDRFAMILY ||
VAR_5 == EAI_FAMILY) { *VAR_1 = false; goto done; } goto cleanup; } VAR_2 = qemu_socket(VAR_4->ai_family, VAR_4->ai_socktype, VAR_4->ai_protocol); if (VAR_2 < 0) { goto cleanup; } if (bind(VAR_2, VAR_4->ai_addr, VAR_4->ai_addrlen) < 0) { if (errno == EADDRNOTAVAIL) { *VAR_1 = false; goto done; } goto cleanup; } *VAR_1 = true; done:
VAR_6 = 0; cleanup:
if (VAR_2 != -1) { close(VAR_2); } if (VAR_4) { freeaddrinfo(VAR_4); } return VAR_6; }