static void portio_list_add_1(PortioList *piolist,

                              const MemoryRegionPortio *pio_init,

                              unsigned count, unsigned start,

                              unsigned off_low, unsigned off_high)

{

    MemoryRegionPortio *pio;

    MemoryRegionOps *ops;

    MemoryRegion *region, *alias;

    unsigned i;



    /* Copy the sub-list and null-terminate it.  */

    pio = g_new(MemoryRegionPortio, count + 1);

    memcpy(pio, pio_init, sizeof(MemoryRegionPortio) * count);

    memset(pio + count, 0, sizeof(MemoryRegionPortio));



    /* Adjust the offsets to all be zero-based for the region.  */

    for (i = 0; i < count; ++i) {

        pio[i].offset -= off_low;

    }



    ops = g_new0(MemoryRegionOps, 1);

    ops->old_portio = pio;



    region = g_new(MemoryRegion, 1);

    alias = g_new(MemoryRegion, 1);

    /*

     * Use an alias so that the callback is called with an absolute address,

     * rather than an offset relative to to start + off_low.

     */

    memory_region_init_io(region, ops, piolist->opaque, piolist->name,

                          INT64_MAX);

    memory_region_init_alias(alias, piolist->name,

                             region, start + off_low, off_high - off_low);

    memory_region_add_subregion(piolist->address_space,

                                start + off_low, alias);

    piolist->regions[piolist->nr] = region;

    piolist->aliases[piolist->nr] = alias;

    ++piolist->nr;

}

static void portio_list_add_1(PortioList *piolist,

                              const MemoryRegionPortio *pio_init,

                              unsigned count, unsigned start,

                              unsigned off_low, unsigned off_high)

{

    MemoryRegionPortio *pio;

    MemoryRegionOps *ops;

    MemoryRegion *region, *alias;

    unsigned i;



    

    pio = g_new(MemoryRegionPortio, count + 1);

    memcpy(pio, pio_init, sizeof(MemoryRegionPortio) * count);

    memset(pio + count, 0, sizeof(MemoryRegionPortio));



    

    for (i = 0; i < count; ++i) {

        pio[i].offset -= off_low;

    }



    ops = g_new0(MemoryRegionOps, 1);

    ops->old_portio = pio;



    region = g_new(MemoryRegion, 1);

    alias = g_new(MemoryRegion, 1);

    







    memory_region_init_io(region, ops, piolist->opaque, piolist->name,

                          INT64_MAX);

    memory_region_init_alias(alias, piolist->name,

                             region, start + off_low, off_high - off_low);

    memory_region_add_subregion(piolist->address_space,

                                start + off_low, alias);

    piolist->regions[piolist->nr] = region;

    piolist->aliases[piolist->nr] = alias;

    ++piolist->nr;

}

static void FUNC_0(PortioList *VAR_0,

                              const MemoryRegionPortio *VAR_1,

                              unsigned VAR_2, unsigned VAR_3,

                              unsigned VAR_4, unsigned VAR_5)

{

    MemoryRegionPortio *pio;

    MemoryRegionOps *ops;

    MemoryRegion *region, *alias;

    unsigned VAR_6;



    

    pio = g_new(MemoryRegionPortio, VAR_2 + 1);

    memcpy(pio, VAR_1, sizeof(MemoryRegionPortio) * VAR_2);

    memset(pio + VAR_2, 0, sizeof(MemoryRegionPortio));



    

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

        pio[VAR_6].offset -= VAR_4;

    }



    ops = g_new0(MemoryRegionOps, 1);

    ops->old_portio = pio;



    region = g_new(MemoryRegion, 1);

    alias = g_new(MemoryRegion, 1);

    







    memory_region_init_io(region, ops, VAR_0->opaque, VAR_0->name,

                          INT64_MAX);

    memory_region_init_alias(alias, VAR_0->name,

                             region, VAR_3 + VAR_4, VAR_5 - VAR_4);

    memory_region_add_subregion(VAR_0->address_space,

                                VAR_3 + VAR_4, alias);

    VAR_0->regions[VAR_0->nr] = region;

    VAR_0->aliases[VAR_0->nr] = alias;

    ++VAR_0->nr;

}

static void FUNC_0(PortioList *VAR_0,
const MemoryRegionPortio *VAR_1,
unsigned VAR_2, unsigned VAR_3,
unsigned VAR_4, unsigned VAR_5)
{ MemoryRegionPortio *pio; MemoryRegionOps *ops; MemoryRegion *region, *alias; unsigned VAR_6; pio = g_new(MemoryRegionPortio, VAR_2 + 1); memcpy(pio, VAR_1, sizeof(MemoryRegionPortio) * VAR_2); memset(pio + VAR_2, 0, sizeof(MemoryRegionPortio)); for (VAR_6 = 0; VAR_6 < VAR_2; ++VAR_6) { pio[VAR_6].offset -= VAR_4; } ops = g_new0(MemoryRegionOps, 1); ops->old_portio = pio; region = g_new(MemoryRegion, 1); alias = g_new(MemoryRegion, 1); memory_region_init_io(region, ops, VAR_0->opaque, VAR_0->name,
INT64_MAX); memory_region_init_alias(alias, VAR_0->name,
region, VAR_3 + VAR_4, VAR_5 - VAR_4); memory_region_add_subregion(VAR_0->address_space,
VAR_3 + VAR_4, alias); VAR_0->regions[VAR_0->nr] = region; VAR_0->aliases[VAR_0->nr] = alias; ++VAR_0->nr; }