static void usb_host_speed_compat(USBHostDevice *s)

{

    USBDevice *udev = USB_DEVICE(s);

    struct libusb_config_descriptor *conf;

    const struct libusb_interface_descriptor *intf;

    const struct libusb_endpoint_descriptor *endp;

#ifdef HAVE_STREAMS

    struct libusb_ss_endpoint_companion_descriptor *endp_ss_comp;

#endif

    bool compat_high = true;

    bool compat_full = true;

    uint8_t type;

    int rc, c, i, a, e;



    for (c = 0;; c++) {

        rc = libusb_get_config_descriptor(s->dev, c, &conf);

        if (rc != 0) {

            break;

        }

        for (i = 0; i < conf->bNumInterfaces; i++) {

            for (a = 0; a < conf->interface[i].num_altsetting; a++) {

                intf = &conf->interface[i].altsetting[a];

                for (e = 0; e < intf->bNumEndpoints; e++) {

                    endp = &intf->endpoint[e];

                    type = endp->bmAttributes & 0x3;

                    switch (type) {

                    case 0x01: /* ISO */

                        compat_full = false;

                        compat_high = false;

                        break;

                    case 0x02: /* BULK */

#ifdef HAVE_STREAMS

                        rc = libusb_get_ss_endpoint_companion_descriptor

                            (ctx, endp, &endp_ss_comp);

                        if (rc == LIBUSB_SUCCESS) {

                            libusb_free_ss_endpoint_companion_descriptor

                                (endp_ss_comp);

                            compat_full = false;

                            compat_high = false;

                        }

#endif

                        break;

                    case 0x03: /* INTERRUPT */

                        if (endp->wMaxPacketSize > 64) {

                            compat_full = false;

                        }

                        if (endp->wMaxPacketSize > 1024) {

                            compat_high = false;

                        }

                        break;

                    }

                }

            }

        }

        libusb_free_config_descriptor(conf);

    }



    udev->speedmask = (1 << udev->speed);

    if (udev->speed == USB_SPEED_SUPER && compat_high) {

        udev->speedmask |= USB_SPEED_MASK_HIGH;

    }

    if (udev->speed == USB_SPEED_SUPER && compat_full) {

        udev->speedmask |= USB_SPEED_MASK_FULL;

    }

    if (udev->speed == USB_SPEED_HIGH && compat_full) {

        udev->speedmask |= USB_SPEED_MASK_FULL;

    }

}

static void usb_host_speed_compat(USBHostDevice *s)

{

    USBDevice *udev = USB_DEVICE(s);

    struct libusb_config_descriptor *conf;

    const struct libusb_interface_descriptor *intf;

    const struct libusb_endpoint_descriptor *endp;

#ifdef HAVE_STREAMS

    struct libusb_ss_endpoint_companion_descriptor *endp_ss_comp;

#endif

    bool compat_high = true;

    bool compat_full = true;

    uint8_t type;

    int rc, c, i, a, e;



    for (c = 0;; c++) {

        rc = libusb_get_config_descriptor(s->dev, c, &conf);

        if (rc != 0) {

            break;

        }

        for (i = 0; i < conf->bNumInterfaces; i++) {

            for (a = 0; a < conf->interface[i].num_altsetting; a++) {

                intf = &conf->interface[i].altsetting[a];

                for (e = 0; e < intf->bNumEndpoints; e++) {

                    endp = &intf->endpoint[e];

                    type = endp->bmAttributes & 0x3;

                    switch (type) {

                    case 0x01: 

                        compat_full = false;

                        compat_high = false;

                        break;

                    case 0x02: 

#ifdef HAVE_STREAMS

                        rc = libusb_get_ss_endpoint_companion_descriptor

                            (ctx, endp, &endp_ss_comp);

                        if (rc == LIBUSB_SUCCESS) {

                            libusb_free_ss_endpoint_companion_descriptor

                                (endp_ss_comp);

                            compat_full = false;

                            compat_high = false;

                        }

#endif

                        break;

                    case 0x03: 

                        if (endp->wMaxPacketSize > 64) {

                            compat_full = false;

                        }

                        if (endp->wMaxPacketSize > 1024) {

                            compat_high = false;

                        }

                        break;

                    }

                }

            }

        }

        libusb_free_config_descriptor(conf);

    }



    udev->speedmask = (1 << udev->speed);

    if (udev->speed == USB_SPEED_SUPER && compat_high) {

        udev->speedmask |= USB_SPEED_MASK_HIGH;

    }

    if (udev->speed == USB_SPEED_SUPER && compat_full) {

        udev->speedmask |= USB_SPEED_MASK_FULL;

    }

    if (udev->speed == USB_SPEED_HIGH && compat_full) {

        udev->speedmask |= USB_SPEED_MASK_FULL;

    }

}

static void FUNC_0(USBHostDevice *VAR_0)

{

    USBDevice *udev = USB_DEVICE(VAR_0);

    struct libusb_config_descriptor *VAR_1;

    const struct libusb_interface_descriptor *VAR_2;

    const struct libusb_endpoint_descriptor *VAR_3;

#ifdef HAVE_STREAMS

    struct libusb_ss_endpoint_companion_descriptor *endp_ss_comp;

#endif

    bool compat_high = true;

    bool compat_full = true;

    uint8_t type;

    int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;



    for (VAR_5 = 0;; VAR_5++) {

        VAR_4 = libusb_get_config_descriptor(VAR_0->dev, VAR_5, &VAR_1);

        if (VAR_4 != 0) {

            break;

        }

        for (VAR_6 = 0; VAR_6 < VAR_1->bNumInterfaces; VAR_6++) {

            for (VAR_7 = 0; VAR_7 < VAR_1->interface[VAR_6].num_altsetting; VAR_7++) {

                VAR_2 = &VAR_1->interface[VAR_6].altsetting[VAR_7];

                for (VAR_8 = 0; VAR_8 < VAR_2->bNumEndpoints; VAR_8++) {

                    VAR_3 = &VAR_2->endpoint[VAR_8];

                    type = VAR_3->bmAttributes & 0x3;

                    switch (type) {

                    case 0x01: 

                        compat_full = false;

                        compat_high = false;

                        break;

                    case 0x02: 

#ifdef HAVE_STREAMS

                        VAR_4 = libusb_get_ss_endpoint_companion_descriptor

                            (ctx, VAR_3, &endp_ss_comp);

                        if (VAR_4 == LIBUSB_SUCCESS) {

                            libusb_free_ss_endpoint_companion_descriptor

                                (endp_ss_comp);

                            compat_full = false;

                            compat_high = false;

                        }

#endif

                        break;

                    case 0x03: 

                        if (VAR_3->wMaxPacketSize > 64) {

                            compat_full = false;

                        }

                        if (VAR_3->wMaxPacketSize > 1024) {

                            compat_high = false;

                        }

                        break;

                    }

                }

            }

        }

        libusb_free_config_descriptor(VAR_1);

    }



    udev->speedmask = (1 << udev->speed);

    if (udev->speed == USB_SPEED_SUPER && compat_high) {

        udev->speedmask |= USB_SPEED_MASK_HIGH;

    }

    if (udev->speed == USB_SPEED_SUPER && compat_full) {

        udev->speedmask |= USB_SPEED_MASK_FULL;

    }

    if (udev->speed == USB_SPEED_HIGH && compat_full) {

        udev->speedmask |= USB_SPEED_MASK_FULL;

    }

}

static void FUNC_0(USBHostDevice *VAR_0)
{ USBDevice *udev = USB_DEVICE(VAR_0); struct libusb_config_descriptor *VAR_1; const struct libusb_interface_descriptor *VAR_2; const struct libusb_endpoint_descriptor *VAR_3; #ifdef HAVE_STREAMS
struct libusb_ss_endpoint_companion_descriptor *endp_ss_comp; #endif
bool compat_high = true; bool compat_full = true; uint8_t type; int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8; for (VAR_5 = 0;; VAR_5++) { VAR_4 = libusb_get_config_descriptor(VAR_0->dev, VAR_5, &VAR_1); if (VAR_4 != 0) { break; } for (VAR_6 = 0; VAR_6 < VAR_1->bNumInterfaces; VAR_6++) { for (VAR_7 = 0; VAR_7 < VAR_1->interface[VAR_6].num_altsetting; VAR_7++) { VAR_2 = &VAR_1->interface[VAR_6].altsetting[VAR_7]; for (VAR_8 = 0; VAR_8 < VAR_2->bNumEndpoints; VAR_8++) { VAR_3 = &VAR_2->endpoint[VAR_8]; type = VAR_3->bmAttributes & 0x3; switch (type) { case 0x01:
compat_full = false; compat_high = false; break; case 0x02:
#ifdef HAVE_STREAMS
VAR_4 = libusb_get_ss_endpoint_companion_descriptor
(ctx, VAR_3, &endp_ss_comp); if (VAR_4 == LIBUSB_SUCCESS) { libusb_free_ss_endpoint_companion_descriptor
(endp_ss_comp); compat_full = false; compat_high = false; } #endif
break; case 0x03:
if (VAR_3->wMaxPacketSize > 64) { compat_full = false; } if (VAR_3->wMaxPacketSize > 1024) { compat_high = false; } break; } } } } libusb_free_config_descriptor(VAR_1); } udev->speedmask = (1 << udev->speed); if (udev->speed == USB_SPEED_SUPER && compat_high) { udev->speedmask |= USB_SPEED_MASK_HIGH; } if (udev->speed == USB_SPEED_SUPER && compat_full) { udev->speedmask |= USB_SPEED_MASK_FULL; } if (udev->speed == USB_SPEED_HIGH && compat_full) { udev->speedmask |= USB_SPEED_MASK_FULL; } }