static int vmdk_is_allocated(BlockDriverState *bs, int64_t sector_num,

                             int nb_sectors, int *pnum)

{

    BDRVVmdkState *s = bs->opaque;

    int64_t index_in_cluster, n, ret;

    uint64_t offset;

    VmdkExtent *extent;



    extent = find_extent(s, sector_num, NULL);

    if (!extent) {

        return 0;

    }

    ret = get_cluster_offset(bs, extent, NULL,

                            sector_num * 512, 0, &offset);

    /* get_cluster_offset returning 0 means success */

    ret = !ret;



    index_in_cluster = sector_num % extent->cluster_sectors;

    n = extent->cluster_sectors - index_in_cluster;

    if (n > nb_sectors) {

        n = nb_sectors;

    }

    *pnum = n;

    return ret;

}

static int vmdk_is_allocated(BlockDriverState *bs, int64_t sector_num,

                             int nb_sectors, int *pnum)

{

    BDRVVmdkState *s = bs->opaque;

    int64_t index_in_cluster, n, ret;

    uint64_t offset;

    VmdkExtent *extent;



    extent = find_extent(s, sector_num, NULL);

    if (!extent) {

        return 0;

    }

    ret = get_cluster_offset(bs, extent, NULL,

                            sector_num * 512, 0, &offset);

    

    ret = !ret;



    index_in_cluster = sector_num % extent->cluster_sectors;

    n = extent->cluster_sectors - index_in_cluster;

    if (n > nb_sectors) {

        n = nb_sectors;

    }

    *pnum = n;

    return ret;

}

static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,

                             int VAR_2, int *VAR_3)

{

    BDRVVmdkState *s = VAR_0->opaque;

    int64_t index_in_cluster, n, ret;

    uint64_t offset;

    VmdkExtent *extent;



    extent = find_extent(s, VAR_1, NULL);

    if (!extent) {

        return 0;

    }

    ret = get_cluster_offset(VAR_0, extent, NULL,

                            VAR_1 * 512, 0, &offset);

    

    ret = !ret;



    index_in_cluster = VAR_1 % extent->cluster_sectors;

    n = extent->cluster_sectors - index_in_cluster;

    if (n > VAR_2) {

        n = VAR_2;

    }

    *VAR_3 = n;

    return ret;

}

static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,
int VAR_2, int *VAR_3)
{ BDRVVmdkState *s = VAR_0->opaque; int64_t index_in_cluster, n, ret; uint64_t offset; VmdkExtent *extent; extent = find_extent(s, VAR_1, NULL); if (!extent) { return 0; } ret = get_cluster_offset(VAR_0, extent, NULL,
VAR_1 * 512, 0, &offset); ret = !ret; index_in_cluster = VAR_1 % extent->cluster_sectors; n = extent->cluster_sectors - index_in_cluster; if (n > VAR_2) { n = VAR_2; } *VAR_3 = n; return ret; }