static int vpc_read(BlockDriverState *bs, int64_t sector_num,

                    uint8_t *buf, int nb_sectors)

{

    BDRVVPCState *s = bs->opaque;

    int ret;

    int64_t offset;

    int64_t sectors, sectors_per_block;

    VHDFooter *footer = (VHDFooter *) s->footer_buf;



    if (cpu_to_be32(footer->type) == VHD_FIXED) {

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

    }

    while (nb_sectors > 0) {

        offset = get_sector_offset(bs, sector_num, 0);



        sectors_per_block = s->block_size >> BDRV_SECTOR_BITS;

        sectors = sectors_per_block - (sector_num % sectors_per_block);

        if (sectors > nb_sectors) {

            sectors = nb_sectors;

        }



        if (offset == -1) {

            memset(buf, 0, sectors * BDRV_SECTOR_SIZE);

        } else {

            ret = bdrv_pread(bs->file, offset, buf,

                sectors * BDRV_SECTOR_SIZE);

            if (ret != sectors * BDRV_SECTOR_SIZE) {

                return -1;

            }

        }



        nb_sectors -= sectors;

        sector_num += sectors;

        buf += sectors * BDRV_SECTOR_SIZE;

    }

    return 0;

}

static int vpc_read(BlockDriverState *bs, int64_t sector_num,

                    uint8_t *buf, int nb_sectors)

{

    BDRVVPCState *s = bs->opaque;

    int ret;

    int64_t offset;

    int64_t sectors, sectors_per_block;

    VHDFooter *footer = (VHDFooter *) s->footer_buf;



    if (cpu_to_be32(footer->type) == VHD_FIXED) {

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

    }

    while (nb_sectors > 0) {

        offset = get_sector_offset(bs, sector_num, 0);



        sectors_per_block = s->block_size >> BDRV_SECTOR_BITS;

        sectors = sectors_per_block - (sector_num % sectors_per_block);

        if (sectors > nb_sectors) {

            sectors = nb_sectors;

        }



        if (offset == -1) {

            memset(buf, 0, sectors * BDRV_SECTOR_SIZE);

        } else {

            ret = bdrv_pread(bs->file, offset, buf,

                sectors * BDRV_SECTOR_SIZE);

            if (ret != sectors * BDRV_SECTOR_SIZE) {

                return -1;

            }

        }



        nb_sectors -= sectors;

        sector_num += sectors;

        buf += sectors * BDRV_SECTOR_SIZE;

    }

    return 0;

}

    if (cpu_to_be32(footer->type) == VHD_FIXED) {     if (cpu_to_be32(footer->type) == VHD_FIXED) {     if (cpu_to_be32(footer->type) == VHD_FIXED) {
static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,

                    uint8_t *VAR_2, int VAR_3)

{

    BDRVVPCState *s = VAR_0->opaque;

    int VAR_4;

    int64_t offset;

    int64_t sectors, sectors_per_block;

    VHDFooter *footer = (VHDFooter *) s->footer_buf;



    if (cpu_to_be32(footer->type) == VHD_FIXED) {

        return bdrv_read(VAR_0->file, VAR_1, VAR_2, VAR_3);

    }

    while (VAR_3 > 0) {

        offset = get_sector_offset(VAR_0, VAR_1, 0);



        sectors_per_block = s->block_size >> BDRV_SECTOR_BITS;

        sectors = sectors_per_block - (VAR_1 % sectors_per_block);

        if (sectors > VAR_3) {

            sectors = VAR_3;

        }



        if (offset == -1) {

            memset(VAR_2, 0, sectors * BDRV_SECTOR_SIZE);

        } else {

            VAR_4 = bdrv_pread(VAR_0->file, offset, VAR_2,

                sectors * BDRV_SECTOR_SIZE);

            if (VAR_4 != sectors * BDRV_SECTOR_SIZE) {

                return -1;

            }

        }



        VAR_3 -= sectors;

        VAR_1 += sectors;

        VAR_2 += sectors * BDRV_SECTOR_SIZE;

    }

    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
uint8_t *VAR_2, int VAR_3)
{ BDRVVPCState *s = VAR_0->opaque; int VAR_4; int64_t offset; int64_t sectors, sectors_per_block; VHDFooter *footer = (VHDFooter *) s->footer_buf; if (cpu_to_be32(footer->type) == VHD_FIXED) { return bdrv_read(VAR_0->file, VAR_1, VAR_2, VAR_3); } while (VAR_3 > 0) { offset = get_sector_offset(VAR_0, VAR_1, 0); sectors_per_block = s->block_size >> BDRV_SECTOR_BITS; sectors = sectors_per_block - (VAR_1 % sectors_per_block); if (sectors > VAR_3) { sectors = VAR_3; } if (offset == -1) { memset(VAR_2, 0, sectors * BDRV_SECTOR_SIZE); } else { VAR_4 = bdrv_pread(VAR_0->file, offset, VAR_2,
sectors * BDRV_SECTOR_SIZE); if (VAR_4 != sectors * BDRV_SECTOR_SIZE) { return -1; } } VAR_3 -= sectors; VAR_1 += sectors; VAR_2 += sectors * BDRV_SECTOR_SIZE; } return 0; }