static int cow_is_allocated(BlockDriverState *bs, int64_t sector_num,

        int nb_sectors, int *num_same)

{

    int changed;



    if (nb_sectors == 0) {

	*num_same = nb_sectors;

	return 0;

    }



    changed = is_bit_set(bs, sector_num);

    if (changed < 0) {

        return 0; /* XXX: how to return I/O errors? */

    }



    for (*num_same = 1; *num_same < nb_sectors; (*num_same)++) {

	if (is_bit_set(bs, sector_num + *num_same) != changed)

	    break;

    }



    return changed;

}

static int cow_is_allocated(BlockDriverState *bs, int64_t sector_num,

        int nb_sectors, int *num_same)

{

    int changed;



    if (nb_sectors == 0) {

	*num_same = nb_sectors;

	return 0;

    }



    changed = is_bit_set(bs, sector_num);

    if (changed < 0) {

        return 0; 

    }



    for (*num_same = 1; *num_same < nb_sectors; (*num_same)++) {

	if (is_bit_set(bs, sector_num + *num_same) != changed)

	    break;

    }



    return changed;

}

static int cow_is_allocated(BlockDriverState *bs, int64_t sector_num,         int nb_sectors, int *num_same)
static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,

        int VAR_2, int *VAR_3)

{

    int VAR_4;



    if (VAR_2 == 0) {

	*VAR_3 = VAR_2;

	return 0;

    }



    VAR_4 = is_bit_set(VAR_0, VAR_1);

    if (VAR_4 < 0) {

        return 0; 

    }



    for (*VAR_3 = 1; *VAR_3 < VAR_2; (*VAR_3)++) {

	if (is_bit_set(VAR_0, VAR_1 + *VAR_3) != VAR_4)

	    break;

    }



    return VAR_4;

}

static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
int VAR_2, int *VAR_3)
{ int VAR_4; if (VAR_2 == 0) { *VAR_3 = VAR_2; return 0; } VAR_4 = is_bit_set(VAR_0, VAR_1); if (VAR_4 < 0) { return 0; } for (*VAR_3 = 1; *VAR_3 < VAR_2; (*VAR_3)++) { if (is_bit_set(VAR_0, VAR_1 + *VAR_3) != VAR_4)
break; } return VAR_4; }