static void set_dirty_bitmap(BlockDriverState *bs, int64_t sector_num,

                             int nb_sectors, int dirty)

{

    int64_t start, end;

    unsigned long val, idx, bit;



    start = sector_num / BDRV_SECTORS_PER_DIRTY_CHUNK;

    end = (sector_num + nb_sectors - 1) / BDRV_SECTORS_PER_DIRTY_CHUNK;



    for (; start <= end; start++) {

        idx = start / (sizeof(unsigned long) * 8);

        bit = start % (sizeof(unsigned long) * 8);

        val = bs->dirty_bitmap[idx];

        if (dirty) {

            val |= 1 << bit;

        } else {

            val &= ~(1 << bit);

        }

        bs->dirty_bitmap[idx] = val;

    }

}

static void set_dirty_bitmap(BlockDriverState *bs, int64_t sector_num,

                             int nb_sectors, int dirty)

{

    int64_t start, end;

    unsigned long val, idx, bit;



    start = sector_num / BDRV_SECTORS_PER_DIRTY_CHUNK;

    end = (sector_num + nb_sectors - 1) / BDRV_SECTORS_PER_DIRTY_CHUNK;



    for (; start <= end; start++) {

        idx = start / (sizeof(unsigned long) * 8);

        bit = start % (sizeof(unsigned long) * 8);

        val = bs->dirty_bitmap[idx];

        if (dirty) {

            val |= 1 << bit;

        } else {

            val &= ~(1 << bit);

        }

        bs->dirty_bitmap[idx] = val;

    }

}

static void FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,

                             int VAR_2, int VAR_3)

{

    int64_t start, end;

    unsigned long VAR_4, VAR_5, VAR_6;



    start = VAR_1 / BDRV_SECTORS_PER_DIRTY_CHUNK;

    end = (VAR_1 + VAR_2 - 1) / BDRV_SECTORS_PER_DIRTY_CHUNK;



    for (; start <= end; start++) {

        VAR_5 = start / (sizeof(unsigned long) * 8);

        VAR_6 = start % (sizeof(unsigned long) * 8);

        VAR_4 = VAR_0->dirty_bitmap[VAR_5];

        if (VAR_3) {

            VAR_4 |= 1 << VAR_6;

        } else {

            VAR_4 &= ~(1 << VAR_6);

        }

        VAR_0->dirty_bitmap[VAR_5] = VAR_4;

    }

}

static void FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
int VAR_2, int VAR_3)
{ int64_t start, end; unsigned long VAR_4, VAR_5, VAR_6; start = VAR_1 / BDRV_SECTORS_PER_DIRTY_CHUNK; end = (VAR_1 + VAR_2 - 1) / BDRV_SECTORS_PER_DIRTY_CHUNK; for (; start <= end; start++) { VAR_5 = start / (sizeof(unsigned long) * 8); VAR_6 = start % (sizeof(unsigned long) * 8); VAR_4 = VAR_0->dirty_bitmap[VAR_5]; if (VAR_3) { VAR_4 |= 1 << VAR_6; } else { VAR_4 &= ~(1 << VAR_6); } VAR_0->dirty_bitmap[VAR_5] = VAR_4; } }