static void listener_add_address_space(MemoryListener *listener,

                                       AddressSpace *as)

{

    FlatView *view;

    FlatRange *fr;



    if (listener->address_space_filter

        && listener->address_space_filter != as) {

        return;

    }



    if (global_dirty_log) {

        if (listener->log_global_start) {

            listener->log_global_start(listener);

        }

    }



    view = as->current_map;

    FOR_EACH_FLAT_RANGE(fr, view) {

        MemoryRegionSection section = {

            .mr = fr->mr,

            .address_space = as,

            .offset_within_region = fr->offset_in_region,

            .size = fr->addr.size,

            .offset_within_address_space = int128_get64(fr->addr.start),

            .readonly = fr->readonly,

        };

        if (listener->region_add) {

            listener->region_add(listener, &section);

        }

    }

}

static void listener_add_address_space(MemoryListener *listener,

                                       AddressSpace *as)

{

    FlatView *view;

    FlatRange *fr;



    if (listener->address_space_filter

        && listener->address_space_filter != as) {

        return;

    }



    if (global_dirty_log) {

        if (listener->log_global_start) {

            listener->log_global_start(listener);

        }

    }



    view = as->current_map;

    FOR_EACH_FLAT_RANGE(fr, view) {

        MemoryRegionSection section = {

            .mr = fr->mr,

            .address_space = as,

            .offset_within_region = fr->offset_in_region,

            .size = fr->addr.size,

            .offset_within_address_space = int128_get64(fr->addr.start),

            .readonly = fr->readonly,

        };

        if (listener->region_add) {

            listener->region_add(listener, &section);

        }

    }

}

static void FUNC_0(MemoryListener *VAR_0,

                                       AddressSpace *VAR_1)

{

    FlatView *view;

    FlatRange *fr;



    if (VAR_0->address_space_filter

        && VAR_0->address_space_filter != VAR_1) {

        return;

    }



    if (global_dirty_log) {

        if (VAR_0->log_global_start) {

            VAR_0->log_global_start(VAR_0);

        }

    }



    view = VAR_1->current_map;

    FOR_EACH_FLAT_RANGE(fr, view) {

        MemoryRegionSection section = {

            .mr = fr->mr,

            .address_space = VAR_1,

            .offset_within_region = fr->offset_in_region,

            .size = fr->addr.size,

            .offset_within_address_space = int128_get64(fr->addr.start),

            .readonly = fr->readonly,

        };

        if (VAR_0->region_add) {

            VAR_0->region_add(VAR_0, &section);

        }

    }

}

static void FUNC_0(MemoryListener *VAR_0,
AddressSpace *VAR_1)
{ FlatView *view; FlatRange *fr; if (VAR_0->address_space_filter
&& VAR_0->address_space_filter != VAR_1) { return; } if (global_dirty_log) { if (VAR_0->log_global_start) { VAR_0->log_global_start(VAR_0); } } view = VAR_1->current_map; FOR_EACH_FLAT_RANGE(fr, view) { MemoryRegionSection section = { .mr = fr->mr,
.address_space = VAR_1,
.offset_within_region = fr->offset_in_region,
.size = fr->addr.size,
.offset_within_address_space = int128_get64(fr->addr.start),
.readonly = fr->readonly,
}; if (VAR_0->region_add) { VAR_0->region_add(VAR_0, &section); } } }