static void nvic_recompute_state(NVICState *s)

{

    int i;

    int pend_prio = NVIC_NOEXC_PRIO;

    int active_prio = NVIC_NOEXC_PRIO;

    int pend_irq = 0;



    for (i = 1; i < s->num_irq; i++) {

        VecInfo *vec = &s->vectors[i];



        if (vec->enabled && vec->pending && vec->prio < pend_prio) {

            pend_prio = vec->prio;

            pend_irq = i;

        }

        if (vec->active && vec->prio < active_prio) {

            active_prio = vec->prio;

        }

    }



    if (active_prio > 0) {

        active_prio &= nvic_gprio_mask(s);

    }



    s->vectpending = pend_irq;

    s->exception_prio = active_prio;



    trace_nvic_recompute_state(s->vectpending, s->exception_prio);

}

static void nvic_recompute_state(NVICState *s)

{

    int i;

    int pend_prio = NVIC_NOEXC_PRIO;

    int active_prio = NVIC_NOEXC_PRIO;

    int pend_irq = 0;



    for (i = 1; i < s->num_irq; i++) {

        VecInfo *vec = &s->vectors[i];



        if (vec->enabled && vec->pending && vec->prio < pend_prio) {

            pend_prio = vec->prio;

            pend_irq = i;

        }

        if (vec->active && vec->prio < active_prio) {

            active_prio = vec->prio;

        }

    }



    if (active_prio > 0) {

        active_prio &= nvic_gprio_mask(s);

    }



    s->vectpending = pend_irq;

    s->exception_prio = active_prio;



    trace_nvic_recompute_state(s->vectpending, s->exception_prio);

}

static void FUNC_0(NVICState *VAR_0)

{

    int VAR_1;

    int VAR_2 = NVIC_NOEXC_PRIO;

    int VAR_3 = NVIC_NOEXC_PRIO;

    int VAR_4 = 0;



    for (VAR_1 = 1; VAR_1 < VAR_0->num_irq; VAR_1++) {

        VecInfo *vec = &VAR_0->vectors[VAR_1];



        if (vec->enabled && vec->pending && vec->prio < VAR_2) {

            VAR_2 = vec->prio;

            VAR_4 = VAR_1;

        }

        if (vec->active && vec->prio < VAR_3) {

            VAR_3 = vec->prio;

        }

    }



    if (VAR_3 > 0) {

        VAR_3 &= nvic_gprio_mask(VAR_0);

    }



    VAR_0->vectpending = VAR_4;

    VAR_0->exception_prio = VAR_3;



    trace_nvic_recompute_state(VAR_0->vectpending, VAR_0->exception_prio);

}

static void FUNC_0(NVICState *VAR_0)
{ int VAR_1; int VAR_2 = NVIC_NOEXC_PRIO; int VAR_3 = NVIC_NOEXC_PRIO; int VAR_4 = 0; for (VAR_1 = 1; VAR_1 < VAR_0->num_irq; VAR_1++) { VecInfo *vec = &VAR_0->vectors[VAR_1]; if (vec->enabled && vec->pending && vec->prio < VAR_2) { VAR_2 = vec->prio; VAR_4 = VAR_1; } if (vec->active && vec->prio < VAR_3) { VAR_3 = vec->prio; } } if (VAR_3 > 0) { VAR_3 &= nvic_gprio_mask(VAR_0); } VAR_0->vectpending = VAR_4; VAR_0->exception_prio = VAR_3; trace_nvic_recompute_state(VAR_0->vectpending, VAR_0->exception_prio); }