static int ehci_state_executing(EHCIQueue *q)

{

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

    int again = 0;



    assert(p != NULL);

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



    ehci_execute_complete(q);

    if (p->usb_status == USB_RET_ASYNC) {

        goto out;

    }

    if (p->usb_status == USB_RET_PROCERR) {

        again = -1;

        goto out;

    }



    // 4.10.3

    if (!q->async) {

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

        transactCtr--;

        set_field(&q->qh.epcap, transactCtr, QH_EPCAP_MULT);

        // 4.10.3, bottom of page 82, should exit this state when transaction

        // counter decrements to 0

    }



    /* 4.10.5 */

    if (p->usb_status == USB_RET_NAK) {

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

    } else {

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

    }



    again = 1;



out:

    ehci_flush_qh(q);

    return again;

}

static int ehci_state_executing(EHCIQueue *q)

{

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

    int again = 0;



    assert(p != NULL);

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



    ehci_execute_complete(q);

    if (p->usb_status == USB_RET_ASYNC) {

        goto out;

    }

    if (p->usb_status == USB_RET_PROCERR) {

        again = -1;

        goto out;

    }



    

    if (!q->async) {

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

        transactCtr--;

        set_field(&q->qh.epcap, transactCtr, QH_EPCAP_MULT);

        , bottom of page 82, should exit this state when transaction

        

    }



    

    if (p->usb_status == USB_RET_NAK) {

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

    } else {

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

    }



    again = 1;



out:

    ehci_flush_qh(q);

    return again;

}

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);



    ehci_execute_complete(VAR_0);

    if (p->usb_status == USB_RET_ASYNC) {

        goto out;

    }

    if (p->usb_status == USB_RET_PROCERR) {

        VAR_1 = -1;

        goto out;

    }



    

    if (!VAR_0->async) {

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

        VAR_2--;

        set_field(&VAR_0->qh.epcap, VAR_2, QH_EPCAP_MULT);

        , bottom of page 82, should exit this state when transaction

        

    }



    

    if (p->usb_status == USB_RET_NAK) {

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

    } else {

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

    }



    VAR_1 = 1;



out:

    ehci_flush_qh(VAR_0);

    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); ehci_execute_complete(VAR_0); if (p->usb_status == USB_RET_ASYNC) { goto out; } if (p->usb_status == USB_RET_PROCERR) { VAR_1 = -1; goto out; } if (!VAR_0->async) { int VAR_2 = get_field(VAR_0->qh.epcap, QH_EPCAP_MULT); VAR_2--; set_field(&VAR_0->qh.epcap, VAR_2, QH_EPCAP_MULT); , bottom of page 82, should exit this state when transaction
} if (p->usb_status == USB_RET_NAK) { ehci_set_state(VAR_0->ehci, VAR_0->async, EST_HORIZONTALQH); } else { ehci_set_state(VAR_0->ehci, VAR_0->async, EST_WRITEBACK); } VAR_1 = 1; out:
ehci_flush_qh(VAR_0); return VAR_1; }