int bdrv_read(BlockDriverState *bs, int64_t sector_num,

              uint8_t *buf, int nb_sectors)

{

    BlockDriver *drv = bs->drv;



    if (!drv)

        return -ENOMEDIUM;





    if (drv->bdrv_pread) {

        int ret, len;

        len = nb_sectors * 512;

        ret = drv->bdrv_pread(bs, sector_num * 512, buf, len);

        if (ret < 0)

            return ret;

        else if (ret != len)

            return -EINVAL;

        else {

	    bs->rd_bytes += (unsigned) len;

	    bs->rd_ops ++;

            return 0;

	}

    } else {

        return drv->bdrv_read(bs, sector_num, buf, nb_sectors);

    }

}
int bdrv_read(BlockDriverState *bs, int64_t sector_num,

              uint8_t *buf, int nb_sectors)

{

    BlockDriver *drv = bs->drv;



    if (!drv)

        return -ENOMEDIUM;





    if (drv->bdrv_pread) {

        int ret, len;

        len = nb_sectors * 512;

        ret = drv->bdrv_pread(bs, sector_num * 512, buf, len);

        if (ret < 0)

            return ret;

        else if (ret != len)

            return -EINVAL;

        else {

	    bs->rd_bytes += (unsigned) len;

	    bs->rd_ops ++;

            return 0;

	}

    } else {

        return drv->bdrv_read(bs, sector_num, buf, nb_sectors);

    }

}
int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,

              uint8_t *VAR_2, int VAR_3)

{

    BlockDriver *drv = VAR_0->drv;



    if (!drv)

        return -ENOMEDIUM;





    if (drv->bdrv_pread) {

        int VAR_4, VAR_5;

        VAR_5 = VAR_3 * 512;

        VAR_4 = drv->bdrv_pread(VAR_0, VAR_1 * 512, VAR_2, VAR_5);

        if (VAR_4 < 0)

            return VAR_4;

        else if (VAR_4 != VAR_5)

            return -EINVAL;

        else {

	    VAR_0->rd_bytes += (unsigned) VAR_5;

	    VAR_0->rd_ops ++;

            return 0;

	}

    } else {

        return drv->FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3);

    }

}
int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
uint8_t *VAR_2, int VAR_3)
{ BlockDriver *drv = VAR_0->drv; if (!drv)
return -ENOMEDIUM; if (drv->bdrv_pread) { int VAR_4, VAR_5; VAR_5 = VAR_3 * 512; VAR_4 = drv->bdrv_pread(VAR_0, VAR_1 * 512, VAR_2, VAR_5); if (VAR_4 < 0)
return VAR_4; else if (VAR_4 != VAR_5)
return -EINVAL; else { VAR_0->rd_bytes += (unsigned) VAR_5; VAR_0->rd_ops ++; return 0; } } else { return drv->FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3); } }