static int ehci_state_execute(EHCIQueue *q)

{

    EHCIPacket *p = QTAILQ_FIRST(&q->packets);

    int again = 0;



    assert(p != NULL);

    assert(p->qtdaddr == q->qtdaddr);



    if (ehci_qh_do_overlay(q) != 0) {

        return -1;

    }



    // TODO verify enough time remains in the uframe as in 4.4.1.1

    // TODO write back ptr to async list when done or out of time

    // TODO Windows does not seem to ever set the MULT field



    if (!q->async) {

        int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);

        if (!transactCtr) {

            ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);

            again = 1;

            goto out;

        }

    }



    if (q->async) {

        ehci_set_usbsts(q->ehci, USBSTS_REC);

    }



    p->usb_status = ehci_execute(p, "process");

    if (p->usb_status == USB_RET_PROCERR) {

        again = -1;

        goto out;

    }

    if (p->usb_status == USB_RET_ASYNC) {

        ehci_flush_qh(q);

        trace_usb_ehci_packet_action(p->queue, p, "async");

        p->async = EHCI_ASYNC_INFLIGHT;

        ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);

        again = (ehci_fill_queue(p) == USB_RET_PROCERR) ? -1 : 1;

        goto out;

    }



    ehci_set_state(q->ehci, q->async, EST_EXECUTING);

    again = 1;



out:

    return again;

}

static int ehci_state_execute(EHCIQueue *q)

{

    EHCIPacket *p = QTAILQ_FIRST(&q->packets);

    int again = 0;



    assert(p != NULL);

    assert(p->qtdaddr == q->qtdaddr);



    if (ehci_qh_do_overlay(q) != 0) {

        return -1;

    }



    

    

    



    if (!q->async) {

        int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);

        if (!transactCtr) {

            ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);

            again = 1;

            goto out;

        }

    }



    if (q->async) {

        ehci_set_usbsts(q->ehci, USBSTS_REC);

    }



    p->usb_status = ehci_execute(p, "process");

    if (p->usb_status == USB_RET_PROCERR) {

        again = -1;

        goto out;

    }

    if (p->usb_status == USB_RET_ASYNC) {

        ehci_flush_qh(q);

        trace_usb_ehci_packet_action(p->queue, p, "async");

        p->async = EHCI_ASYNC_INFLIGHT;

        ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);

        again = (ehci_fill_queue(p) == USB_RET_PROCERR) ? -1 : 1;

        goto out;

    }



    ehci_set_state(q->ehci, q->async, EST_EXECUTING);

    again = 1;



out:

    return again;

}

    if (!q->async) {         int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);         if (!transactCtr) {             ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);             again = 1;             goto out;         again = (ehci_fill_queue(p) == USB_RET_PROCERR) ? -1 : 1;     if (!q->async) {         int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);
static int FUNC_0(EHCIQueue *VAR_0)

{

    EHCIPacket *p = QTAILQ_FIRST(&VAR_0->packets);

    int VAR_1 = 0;



    assert(p != NULL);

    assert(p->qtdaddr == VAR_0->qtdaddr);



    if (ehci_qh_do_overlay(VAR_0) != 0) {

        return -1;

    }



    

    

    



    if (!VAR_0->async) {

        int VAR_2 = get_field(VAR_0->qh.epcap, QH_EPCAP_MULT);

        if (!VAR_2) {

            ehci_set_state(VAR_0->ehci, VAR_0->async, EST_HORIZONTALQH);

            VAR_1 = 1;

            goto out;

        }

    }



    if (VAR_0->async) {

        ehci_set_usbsts(VAR_0->ehci, USBSTS_REC);

    }



    p->usb_status = ehci_execute(p, "process");

    if (p->usb_status == USB_RET_PROCERR) {

        VAR_1 = -1;

        goto out;

    }

    if (p->usb_status == USB_RET_ASYNC) {

        ehci_flush_qh(VAR_0);

        trace_usb_ehci_packet_action(p->queue, p, "async");

        p->async = EHCI_ASYNC_INFLIGHT;

        ehci_set_state(VAR_0->ehci, VAR_0->async, EST_HORIZONTALQH);

        VAR_1 = (ehci_fill_queue(p) == USB_RET_PROCERR) ? -1 : 1;

        goto out;

    }



    ehci_set_state(VAR_0->ehci, VAR_0->async, EST_EXECUTING);

    VAR_1 = 1;



out:

    return VAR_1;

}

static int FUNC_0(EHCIQueue *VAR_0)
{ EHCIPacket *p = QTAILQ_FIRST(&VAR_0->packets); int VAR_1 = 0; assert(p != NULL); assert(p->qtdaddr == VAR_0->qtdaddr); if (ehci_qh_do_overlay(VAR_0) != 0) { return -1; } if (!VAR_0->async) { int VAR_2 = get_field(VAR_0->qh.epcap, QH_EPCAP_MULT); if (!VAR_2) { ehci_set_state(VAR_0->ehci, VAR_0->async, EST_HORIZONTALQH); VAR_1 = 1; goto out; } } if (VAR_0->async) { ehci_set_usbsts(VAR_0->ehci, USBSTS_REC); } p->usb_status = ehci_execute(p, "process"); if (p->usb_status == USB_RET_PROCERR) { VAR_1 = -1; goto out; } if (p->usb_status == USB_RET_ASYNC) { ehci_flush_qh(VAR_0); trace_usb_ehci_packet_action(p->queue, p, "async"); p->async = EHCI_ASYNC_INFLIGHT; ehci_set_state(VAR_0->ehci, VAR_0->async, EST_HORIZONTALQH); VAR_1 = (ehci_fill_queue(p) == USB_RET_PROCERR) ? -1 : 1; goto out; } ehci_set_state(VAR_0->ehci, VAR_0->async, EST_EXECUTING); VAR_1 = 1; out:
return VAR_1; }