static void gic_complete_irq(gic_state * s, int cpu, int irq)

{

    int update = 0;

    int cm = 1 << cpu;

    DPRINTF("EOI %d\n", irq);

    if (s->running_irq[cpu] == 1023)

        return; /* No active IRQ.  */

    if (irq != 1023) {

        /* Mark level triggered interrupts as pending if they are still

           raised.  */

        if (!GIC_TEST_TRIGGER(irq) && GIC_TEST_ENABLED(irq, cm)

                && GIC_TEST_LEVEL(irq, cm) && (GIC_TARGET(irq) & cm) != 0) {

            DPRINTF("Set %d pending mask %x\n", irq, cm);

            GIC_SET_PENDING(irq, cm);

            update = 1;

        }

    }

    if (irq != s->running_irq[cpu]) {

        /* Complete an IRQ that is not currently running.  */

        int tmp = s->running_irq[cpu];

        while (s->last_active[tmp][cpu] != 1023) {

            if (s->last_active[tmp][cpu] == irq) {

                s->last_active[tmp][cpu] = s->last_active[irq][cpu];

                break;

            }

            tmp = s->last_active[tmp][cpu];

        }

        if (update) {

            gic_update(s);

        }

    } else {

        /* Complete the current running IRQ.  */

        gic_set_running_irq(s, cpu, s->last_active[s->running_irq[cpu]][cpu]);

    }

}

static void gic_complete_irq(gic_state * s, int cpu, int irq)

{

    int update = 0;

    int cm = 1 << cpu;

    DPRINTF("EOI %d\n", irq);

    if (s->running_irq[cpu] == 1023)

        return; 

    if (irq != 1023) {

        



        if (!GIC_TEST_TRIGGER(irq) && GIC_TEST_ENABLED(irq, cm)

                && GIC_TEST_LEVEL(irq, cm) && (GIC_TARGET(irq) & cm) != 0) {

            DPRINTF("Set %d pending mask %x\n", irq, cm);

            GIC_SET_PENDING(irq, cm);

            update = 1;

        }

    }

    if (irq != s->running_irq[cpu]) {

        

        int tmp = s->running_irq[cpu];

        while (s->last_active[tmp][cpu] != 1023) {

            if (s->last_active[tmp][cpu] == irq) {

                s->last_active[tmp][cpu] = s->last_active[irq][cpu];

                break;

            }

            tmp = s->last_active[tmp][cpu];

        }

        if (update) {

            gic_update(s);

        }

    } else {

        

        gic_set_running_irq(s, cpu, s->last_active[s->running_irq[cpu]][cpu]);

    }

}

    if (irq != 1023) {         if (!GIC_TEST_TRIGGER(irq) && GIC_TEST_ENABLED(irq, cm)                 && GIC_TEST_LEVEL(irq, cm) && (GIC_TARGET(irq) & cm) != 0) {             DPRINTF("Set %d pending mask %x\n", irq, cm);             GIC_SET_PENDING(irq, cm);             update = 1;
static void FUNC_0(gic_state * VAR_0, int VAR_1, int VAR_2)

{

    int VAR_3 = 0;

    int VAR_4 = 1 << VAR_1;

    DPRINTF("EOI %d\n", VAR_2);

    if (VAR_0->running_irq[VAR_1] == 1023)

        return; 

    if (VAR_2 != 1023) {

        



        if (!GIC_TEST_TRIGGER(VAR_2) && GIC_TEST_ENABLED(VAR_2, VAR_4)

                && GIC_TEST_LEVEL(VAR_2, VAR_4) && (GIC_TARGET(VAR_2) & VAR_4) != 0) {

            DPRINTF("Set %d pending mask %x\n", VAR_2, VAR_4);

            GIC_SET_PENDING(VAR_2, VAR_4);

            VAR_3 = 1;

        }

    }

    if (VAR_2 != VAR_0->running_irq[VAR_1]) {

        

        int VAR_5 = VAR_0->running_irq[VAR_1];

        while (VAR_0->last_active[VAR_5][VAR_1] != 1023) {

            if (VAR_0->last_active[VAR_5][VAR_1] == VAR_2) {

                VAR_0->last_active[VAR_5][VAR_1] = VAR_0->last_active[VAR_2][VAR_1];

                break;

            }

            VAR_5 = VAR_0->last_active[VAR_5][VAR_1];

        }

        if (VAR_3) {

            gic_update(VAR_0);

        }

    } else {

        

        gic_set_running_irq(VAR_0, VAR_1, VAR_0->last_active[VAR_0->running_irq[VAR_1]][VAR_1]);

    }

}

static void FUNC_0(gic_state * VAR_0, int VAR_1, int VAR_2)
{ int VAR_3 = 0; int VAR_4 = 1 << VAR_1; DPRINTF("EOI %d\n", VAR_2); if (VAR_0->running_irq[VAR_1] == 1023)
return; if (VAR_2 != 1023) { if (!GIC_TEST_TRIGGER(VAR_2) && GIC_TEST_ENABLED(VAR_2, VAR_4)
&& GIC_TEST_LEVEL(VAR_2, VAR_4) && (GIC_TARGET(VAR_2) & VAR_4) != 0) { DPRINTF("Set %d pending mask %x\n", VAR_2, VAR_4); GIC_SET_PENDING(VAR_2, VAR_4); VAR_3 = 1; } } if (VAR_2 != VAR_0->running_irq[VAR_1]) { int VAR_5 = VAR_0->running_irq[VAR_1]; while (VAR_0->last_active[VAR_5][VAR_1] != 1023) { if (VAR_0->last_active[VAR_5][VAR_1] == VAR_2) { VAR_0->last_active[VAR_5][VAR_1] = VAR_0->last_active[VAR_2][VAR_1]; break; } VAR_5 = VAR_0->last_active[VAR_5][VAR_1]; } if (VAR_3) { gic_update(VAR_0); } } else { gic_set_running_irq(VAR_0, VAR_1, VAR_0->last_active[VAR_0->running_irq[VAR_1]][VAR_1]); } }