static void memory_region_iorange_write(IORange *iorange,

                                        uint64_t offset,

                                        unsigned width,

                                        uint64_t data)

{

    MemoryRegionIORange *mrio

        = container_of(iorange, MemoryRegionIORange, iorange);

    MemoryRegion *mr = mrio->mr;



    offset += mrio->offset;

    if (mr->ops->old_portio) {

        const MemoryRegionPortio *mrp = find_portio(mr, offset - mrio->offset,

                                                    width, true);



        if (mrp) {

            mrp->write(mr->opaque, offset, data);

        } else if (width == 2) {

            mrp = find_portio(mr, offset - mrio->offset, 1, true);

            assert(mrp);

            mrp->write(mr->opaque, offset, data & 0xff);

            mrp->write(mr->opaque, offset + 1, data >> 8);

        }

        return;

    }

    access_with_adjusted_size(offset, &data, width,

                              mr->ops->impl.min_access_size,

                              mr->ops->impl.max_access_size,

                              memory_region_write_accessor, mr);

}

static void memory_region_iorange_write(IORange *iorange,

                                        uint64_t offset,

                                        unsigned width,

                                        uint64_t data)

{

    MemoryRegionIORange *mrio

        = container_of(iorange, MemoryRegionIORange, iorange);

    MemoryRegion *mr = mrio->mr;



    offset += mrio->offset;

    if (mr->ops->old_portio) {

        const MemoryRegionPortio *mrp = find_portio(mr, offset - mrio->offset,

                                                    width, true);



        if (mrp) {

            mrp->write(mr->opaque, offset, data);

        } else if (width == 2) {

            mrp = find_portio(mr, offset - mrio->offset, 1, true);

            assert(mrp);

            mrp->write(mr->opaque, offset, data & 0xff);

            mrp->write(mr->opaque, offset + 1, data >> 8);

        }

        return;

    }

    access_with_adjusted_size(offset, &data, width,

                              mr->ops->impl.min_access_size,

                              mr->ops->impl.max_access_size,

                              memory_region_write_accessor, mr);

}

static void FUNC_0(IORange *VAR_0,

                                        uint64_t VAR_1,

                                        unsigned VAR_2,

                                        uint64_t VAR_3)

{

    MemoryRegionIORange *mrio

        = container_of(VAR_0, MemoryRegionIORange, VAR_0);

    MemoryRegion *mr = mrio->mr;



    VAR_1 += mrio->VAR_1;

    if (mr->ops->old_portio) {

        const MemoryRegionPortio *VAR_4 = find_portio(mr, VAR_1 - mrio->VAR_1,

                                                    VAR_2, true);



        if (VAR_4) {

            VAR_4->write(mr->opaque, VAR_1, VAR_3);

        } else if (VAR_2 == 2) {

            VAR_4 = find_portio(mr, VAR_1 - mrio->VAR_1, 1, true);

            assert(VAR_4);

            VAR_4->write(mr->opaque, VAR_1, VAR_3 & 0xff);

            VAR_4->write(mr->opaque, VAR_1 + 1, VAR_3 >> 8);

        }

        return;

    }

    access_with_adjusted_size(VAR_1, &VAR_3, VAR_2,

                              mr->ops->impl.min_access_size,

                              mr->ops->impl.max_access_size,

                              memory_region_write_accessor, mr);

}

static void FUNC_0(IORange *VAR_0,
uint64_t VAR_1,
unsigned VAR_2,
uint64_t VAR_3)
{ MemoryRegionIORange *mrio
= container_of(VAR_0, MemoryRegionIORange, VAR_0); MemoryRegion *mr = mrio->mr; VAR_1 += mrio->VAR_1; if (mr->ops->old_portio) { const MemoryRegionPortio *VAR_4 = find_portio(mr, VAR_1 - mrio->VAR_1,
VAR_2, true); if (VAR_4) { VAR_4->write(mr->opaque, VAR_1, VAR_3); } else if (VAR_2 == 2) { VAR_4 = find_portio(mr, VAR_1 - mrio->VAR_1, 1, true); assert(VAR_4); VAR_4->write(mr->opaque, VAR_1, VAR_3 & 0xff); VAR_4->write(mr->opaque, VAR_1 + 1, VAR_3 >> 8); } return; } access_with_adjusted_size(VAR_1, &VAR_3, VAR_2,
mr->ops->impl.min_access_size,
mr->ops->impl.max_access_size,
memory_region_write_accessor, mr); }