ram_addr_t migration_bitmap_find_and_reset_dirty(RAMBlock *rb,

                                                 ram_addr_t start)

{

    unsigned long base = rb->offset >> TARGET_PAGE_BITS;

    unsigned long nr = base + (start >> TARGET_PAGE_BITS);

    uint64_t rb_size = rb->used_length;

    unsigned long size = base + (rb_size >> TARGET_PAGE_BITS);

    unsigned long *bitmap;



    unsigned long next;



    bitmap = atomic_rcu_read(&migration_bitmap);

    if (ram_bulk_stage && nr > base) {

        next = nr + 1;

    } else {

        next = find_next_bit(bitmap, size, nr);

    }



    if (next < size) {

        clear_bit(next, bitmap);

        migration_dirty_pages--;

    }

    return (next - base) << TARGET_PAGE_BITS;

}

ram_addr_t migration_bitmap_find_and_reset_dirty(RAMBlock *rb,

                                                 ram_addr_t start)

{

    unsigned long base = rb->offset >> TARGET_PAGE_BITS;

    unsigned long nr = base + (start >> TARGET_PAGE_BITS);

    uint64_t rb_size = rb->used_length;

    unsigned long size = base + (rb_size >> TARGET_PAGE_BITS);

    unsigned long *bitmap;



    unsigned long next;



    bitmap = atomic_rcu_read(&migration_bitmap);

    if (ram_bulk_stage && nr > base) {

        next = nr + 1;

    } else {

        next = find_next_bit(bitmap, size, nr);

    }



    if (next < size) {

        clear_bit(next, bitmap);

        migration_dirty_pages--;

    }

    return (next - base) << TARGET_PAGE_BITS;

}

    bitmap = atomic_rcu_read(&migration_bitmap);     bitmap = atomic_rcu_read(&migration_bitmap);
ram_addr_t FUNC_0(RAMBlock *rb,

                                                 ram_addr_t start)

{

    unsigned long VAR_0 = rb->offset >> TARGET_PAGE_BITS;

    unsigned long VAR_1 = VAR_0 + (start >> TARGET_PAGE_BITS);

    uint64_t rb_size = rb->used_length;

    unsigned long VAR_2 = VAR_0 + (rb_size >> TARGET_PAGE_BITS);

    unsigned long *VAR_3;



    unsigned long VAR_4;



    VAR_3 = atomic_rcu_read(&migration_bitmap);

    if (ram_bulk_stage && VAR_1 > VAR_0) {

        VAR_4 = VAR_1 + 1;

    } else {

        VAR_4 = find_next_bit(VAR_3, VAR_2, VAR_1);

    }



    if (VAR_4 < VAR_2) {

        clear_bit(VAR_4, VAR_3);

        migration_dirty_pages--;

    }

    return (VAR_4 - VAR_0) << TARGET_PAGE_BITS;

}

ram_addr_t FUNC_0(RAMBlock *rb,
ram_addr_t start)
{ unsigned long VAR_0 = rb->offset >> TARGET_PAGE_BITS; unsigned long VAR_1 = VAR_0 + (start >> TARGET_PAGE_BITS); uint64_t rb_size = rb->used_length; unsigned long VAR_2 = VAR_0 + (rb_size >> TARGET_PAGE_BITS); unsigned long *VAR_3; unsigned long VAR_4; VAR_3 = atomic_rcu_read(&migration_bitmap); if (ram_bulk_stage && VAR_1 > VAR_0) { VAR_4 = VAR_1 + 1; } else { VAR_4 = find_next_bit(VAR_3, VAR_2, VAR_1); } if (VAR_4 < VAR_2) { clear_bit(VAR_4, VAR_3); migration_dirty_pages--; } return (VAR_4 - VAR_0) << TARGET_PAGE_BITS; }