static int dmg_read(BlockDriverState *bs, int64_t sector_num,

                    uint8_t *buf, int nb_sectors)

{

    BDRVDMGState *s = bs->opaque;

    int i;



    for(i=0;i<nb_sectors;i++) {

	uint32_t sector_offset_in_chunk;

	if(dmg_read_chunk(bs, sector_num+i) != 0)

	    return -1;

	sector_offset_in_chunk = sector_num+i-s->sectors[s->current_chunk];

	memcpy(buf+i*512,s->uncompressed_chunk+sector_offset_in_chunk*512,512);

    }

    return 0;

}

static int dmg_read(BlockDriverState *bs, int64_t sector_num,

                    uint8_t *buf, int nb_sectors)

{

    BDRVDMGState *s = bs->opaque;

    int i;



    for(i=0;i<nb_sectors;i++) {

	uint32_t sector_offset_in_chunk;

	if(dmg_read_chunk(bs, sector_num+i) != 0)

	    return -1;

	sector_offset_in_chunk = sector_num+i-s->sectors[s->current_chunk];

	memcpy(buf+i*512,s->uncompressed_chunk+sector_offset_in_chunk*512,512);

    }

    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,

                    uint8_t *VAR_2, int VAR_3)

{

    BDRVDMGState *s = VAR_0->opaque;

    int VAR_4;



    for(VAR_4=0;VAR_4<VAR_3;VAR_4++) {

	uint32_t sector_offset_in_chunk;

	if(dmg_read_chunk(VAR_0, VAR_1+VAR_4) != 0)

	    return -1;

	sector_offset_in_chunk = VAR_1+VAR_4-s->sectors[s->current_chunk];

	memcpy(VAR_2+VAR_4*512,s->uncompressed_chunk+sector_offset_in_chunk*512,512);

    }

    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
uint8_t *VAR_2, int VAR_3)
{ BDRVDMGState *s = VAR_0->opaque; int VAR_4; for(VAR_4=0;VAR_4<VAR_3;VAR_4++) { uint32_t sector_offset_in_chunk; if(dmg_read_chunk(VAR_0, VAR_1+VAR_4) != 0)
return -1; sector_offset_in_chunk = VAR_1+VAR_4-s->sectors[s->current_chunk]; memcpy(VAR_2+VAR_4*512,s->uncompressed_chunk+sector_offset_in_chunk*512,512); } return 0; }