void portio_list_add(PortioList *piolist,

                     MemoryRegion *address_space,

                     uint32_t start)

{

    const MemoryRegionPortio *pio, *pio_start = piolist->ports;

    unsigned int off_low, off_high, off_last, count;



    piolist->address_space = address_space;



    /* Handle the first entry specially.  */

    off_last = off_low = pio_start->offset;

    off_high = off_low + pio_start->len;

    count = 1;



    for (pio = pio_start + 1; pio->size != 0; pio++, count++) {

        /* All entries must be sorted by offset.  */

        assert(pio->offset >= off_last);

        off_last = pio->offset;



        /* If we see a hole, break the region.  */

        if (off_last > off_high) {

            portio_list_add_1(piolist, pio_start, count, start, off_low,

                              off_high);

            /* ... and start collecting anew.  */

            pio_start = pio;

            off_low = off_last;

            off_high = off_low + pio->len;

            count = 0;

        } else if (off_last + pio->len > off_high) {

            off_high = off_last + pio->len;

        }

    }



    /* There will always be an open sub-list.  */

    portio_list_add_1(piolist, pio_start, count, start, off_low, off_high);

}

void portio_list_add(PortioList *piolist,

                     MemoryRegion *address_space,

                     uint32_t start)

{

    const MemoryRegionPortio *pio, *pio_start = piolist->ports;

    unsigned int off_low, off_high, off_last, count;



    piolist->address_space = address_space;



    

    off_last = off_low = pio_start->offset;

    off_high = off_low + pio_start->len;

    count = 1;



    for (pio = pio_start + 1; pio->size != 0; pio++, count++) {

        

        assert(pio->offset >= off_last);

        off_last = pio->offset;



        

        if (off_last > off_high) {

            portio_list_add_1(piolist, pio_start, count, start, off_low,

                              off_high);

            

            pio_start = pio;

            off_low = off_last;

            off_high = off_low + pio->len;

            count = 0;

        } else if (off_last + pio->len > off_high) {

            off_high = off_last + pio->len;

        }

    }



    

    portio_list_add_1(piolist, pio_start, count, start, off_low, off_high);

}

void FUNC_0(PortioList *VAR_0,

                     MemoryRegion *VAR_1,

                     uint32_t VAR_2)

{

    const MemoryRegionPortio *VAR_3, *pio_start = VAR_0->ports;

    unsigned int VAR_4, VAR_5, VAR_6, VAR_7;



    VAR_0->VAR_1 = VAR_1;



    

    VAR_6 = VAR_4 = pio_start->offset;

    VAR_5 = VAR_4 + pio_start->len;

    VAR_7 = 1;



    for (VAR_3 = pio_start + 1; VAR_3->size != 0; VAR_3++, VAR_7++) {

        

        assert(VAR_3->offset >= VAR_6);

        VAR_6 = VAR_3->offset;



        

        if (VAR_6 > VAR_5) {

            portio_list_add_1(VAR_0, pio_start, VAR_7, VAR_2, VAR_4,

                              VAR_5);

            

            pio_start = VAR_3;

            VAR_4 = VAR_6;

            VAR_5 = VAR_4 + VAR_3->len;

            VAR_7 = 0;

        } else if (VAR_6 + VAR_3->len > VAR_5) {

            VAR_5 = VAR_6 + VAR_3->len;

        }

    }



    

    portio_list_add_1(VAR_0, pio_start, VAR_7, VAR_2, VAR_4, VAR_5);

}

void FUNC_0(PortioList *VAR_0,
MemoryRegion *VAR_1,
uint32_t VAR_2)
{ const MemoryRegionPortio *VAR_3, *pio_start = VAR_0->ports; unsigned int VAR_4, VAR_5, VAR_6, VAR_7; VAR_0->VAR_1 = VAR_1; VAR_6 = VAR_4 = pio_start->offset; VAR_5 = VAR_4 + pio_start->len; VAR_7 = 1; for (VAR_3 = pio_start + 1; VAR_3->size != 0; VAR_3++, VAR_7++) { assert(VAR_3->offset >= VAR_6); VAR_6 = VAR_3->offset; if (VAR_6 > VAR_5) { portio_list_add_1(VAR_0, pio_start, VAR_7, VAR_2, VAR_4,
VAR_5); pio_start = VAR_3; VAR_4 = VAR_6; VAR_5 = VAR_4 + VAR_3->len; VAR_7 = 0; } else if (VAR_6 + VAR_3->len > VAR_5) { VAR_5 = VAR_6 + VAR_3->len; } } portio_list_add_1(VAR_0, pio_start, VAR_7, VAR_2, VAR_4, VAR_5); }