int xics_alloc_block(XICSState *icp, int src, int num, bool lsi, bool align)

{

    int i, first = -1;

    ICSState *ics = &icp->ics[src];



    assert(src == 0);

    /*

     * MSIMesage::data is used for storing VIRQ so

     * it has to be aligned to num to support multiple

     * MSI vectors. MSI-X is not affected by this.

     * The hint is used for the first IRQ, the rest should

     * be allocated continuously.

     */

    if (align) {

        assert((num == 1) || (num == 2) || (num == 4) ||

               (num == 8) || (num == 16) || (num == 32));

        first = ics_find_free_block(ics, num, num);

    } else {

        first = ics_find_free_block(ics, num, 1);

    }



    if (first >= 0) {

        for (i = first; i < first + num; ++i) {

            ics_set_irq_type(ics, i, lsi);

        }

    }

    first += ics->offset;



    trace_xics_alloc_block(src, first, num, lsi, align);



    return first;

}

int xics_alloc_block(XICSState *icp, int src, int num, bool lsi, bool align)

{

    int i, first = -1;

    ICSState *ics = &icp->ics[src];



    assert(src == 0);

    













    if (align) {

        assert((num == 1) || (num == 2) || (num == 4) ||

               (num == 8) || (num == 16) || (num == 32));

        first = ics_find_free_block(ics, num, num);

    } else {

        first = ics_find_free_block(ics, num, 1);

    }



    if (first >= 0) {

        for (i = first; i < first + num; ++i) {

            ics_set_irq_type(ics, i, lsi);

        }

    }

    first += ics->offset;



    trace_xics_alloc_block(src, first, num, lsi, align);



    return first;

}

int xics_alloc_block(XICSState *icp, int src, int num, bool lsi, bool align)
int FUNC_0(XICSState *VAR_0, int VAR_1, int VAR_2, bool VAR_3, bool VAR_4)

{

    int VAR_5, VAR_6 = -1;

    ICSState *ics = &VAR_0->ics[VAR_1];



    assert(VAR_1 == 0);

    













    if (VAR_4) {

        assert((VAR_2 == 1) || (VAR_2 == 2) || (VAR_2 == 4) ||

               (VAR_2 == 8) || (VAR_2 == 16) || (VAR_2 == 32));

        VAR_6 = ics_find_free_block(ics, VAR_2, VAR_2);

    } else {

        VAR_6 = ics_find_free_block(ics, VAR_2, 1);

    }



    if (VAR_6 >= 0) {

        for (VAR_5 = VAR_6; VAR_5 < VAR_6 + VAR_2; ++VAR_5) {

            ics_set_irq_type(ics, VAR_5, VAR_3);

        }

    }

    VAR_6 += ics->offset;



    trace_xics_alloc_block(VAR_1, VAR_6, VAR_2, VAR_3, VAR_4);



    return VAR_6;

}

int FUNC_0(XICSState *VAR_0, int VAR_1, int VAR_2, bool VAR_3, bool VAR_4)
{ int VAR_5, VAR_6 = -1; ICSState *ics = &VAR_0->ics[VAR_1]; assert(VAR_1 == 0); if (VAR_4) { assert((VAR_2 == 1) || (VAR_2 == 2) || (VAR_2 == 4) ||
(VAR_2 == 8) || (VAR_2 == 16) || (VAR_2 == 32)); VAR_6 = ics_find_free_block(ics, VAR_2, VAR_2); } else { VAR_6 = ics_find_free_block(ics, VAR_2, 1); } if (VAR_6 >= 0) { for (VAR_5 = VAR_6; VAR_5 < VAR_6 + VAR_2; ++VAR_5) { ics_set_irq_type(ics, VAR_5, VAR_3); } } VAR_6 += ics->offset; trace_xics_alloc_block(VAR_1, VAR_6, VAR_2, VAR_3, VAR_4); return VAR_6; }