static abi_long do_socket(int domain, int type, int protocol)

{

    int target_type = type;

    int ret;



    ret = target_to_host_sock_type(&type);

    if (ret) {

        return ret;

    }



    if (domain == PF_NETLINK)

        return -TARGET_EAFNOSUPPORT;



    if (domain == AF_PACKET ||

        (domain == AF_INET && type == SOCK_PACKET)) {

        protocol = tswap16(protocol);

    }



    ret = get_errno(socket(domain, type, protocol));

    if (ret >= 0) {

        ret = sock_flags_fixup(ret, target_type);

        if (type == SOCK_PACKET) {

            /* Manage an obsolete case :

             * if socket type is SOCK_PACKET, bind by name

             */

            fd_trans_register(ret, &target_packet_trans);

        }

    }

    return ret;

}

static abi_long do_socket(int domain, int type, int protocol)

{

    int target_type = type;

    int ret;



    ret = target_to_host_sock_type(&type);

    if (ret) {

        return ret;

    }



    if (domain == PF_NETLINK)

        return -TARGET_EAFNOSUPPORT;



    if (domain == AF_PACKET ||

        (domain == AF_INET && type == SOCK_PACKET)) {

        protocol = tswap16(protocol);

    }



    ret = get_errno(socket(domain, type, protocol));

    if (ret >= 0) {

        ret = sock_flags_fixup(ret, target_type);

        if (type == SOCK_PACKET) {

            





            fd_trans_register(ret, &target_packet_trans);

        }

    }

    return ret;

}

static abi_long FUNC_0(int domain, int type, int protocol)

{

    int VAR_0 = type;

    int VAR_1;



    VAR_1 = target_to_host_sock_type(&type);

    if (VAR_1) {

        return VAR_1;

    }



    if (domain == PF_NETLINK)

        return -TARGET_EAFNOSUPPORT;



    if (domain == AF_PACKET ||

        (domain == AF_INET && type == SOCK_PACKET)) {

        protocol = tswap16(protocol);

    }



    VAR_1 = get_errno(socket(domain, type, protocol));

    if (VAR_1 >= 0) {

        VAR_1 = sock_flags_fixup(VAR_1, VAR_0);

        if (type == SOCK_PACKET) {

            





            fd_trans_register(VAR_1, &target_packet_trans);

        }

    }

    return VAR_1;

}

static abi_long FUNC_0(int domain, int type, int protocol)
{ int VAR_0 = type; int VAR_1; VAR_1 = target_to_host_sock_type(&type); if (VAR_1) { return VAR_1; } if (domain == PF_NETLINK)
return -TARGET_EAFNOSUPPORT; if (domain == AF_PACKET ||
(domain == AF_INET && type == SOCK_PACKET)) { protocol = tswap16(protocol); } VAR_1 = get_errno(socket(domain, type, protocol)); if (VAR_1 >= 0) { VAR_1 = sock_flags_fixup(VAR_1, VAR_0); if (type == SOCK_PACKET) { fd_trans_register(VAR_1, &target_packet_trans); } } return VAR_1; }