int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset,
    int nb_clusters)
{
    BDRVQcowState *s = bs->opaque;
    uint64_t cluster_index;
    uint64_t old_free_cluster_index;
    int i, refcount, ret;
    /* Check how many clusters there are free */
    cluster_index = offset >> s->cluster_bits;
    for(i = 0; i < nb_clusters; i++) {
        refcount = get_refcount(bs, cluster_index++);
        if (refcount < 0) {
            return refcount;
        } else if (refcount != 0) {
            break;
        }
    }
    /* And then allocate them */
    ret = update_refcount(bs, offset, i << s->cluster_bits, 1);
    if (ret < 0) {
        return ret;
    }
    return i;
}
int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset,
    int nb_clusters)
{
    BDRVQcowState *s = bs->opaque;
    uint64_t cluster_index;
    uint64_t old_free_cluster_index;
    int i, refcount, ret;
    
    cluster_index = offset >> s->cluster_bits;
    for(i = 0; i < nb_clusters; i++) {
        refcount = get_refcount(bs, cluster_index++);
        if (refcount < 0) {
            return refcount;
        } else if (refcount != 0) {
            break;
        }
    }
    
    ret = update_refcount(bs, offset, i << s->cluster_bits, 1);
    if (ret < 0) {
        return ret;
    }
    return i;
}
int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,
    int VAR_2)
{
    BDRVQcowState *s = VAR_0->opaque;
    uint64_t cluster_index;
    uint64_t old_free_cluster_index;
    int VAR_3, VAR_4, VAR_5;
    
    cluster_index = VAR_1 >> s->cluster_bits;
    for(VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {
        VAR_4 = get_refcount(VAR_0, cluster_index++);
        if (VAR_4 < 0) {
            return VAR_4;
        } else if (VAR_4 != 0) {
            break;
        }
    }
    
    VAR_5 = update_refcount(VAR_0, VAR_1, VAR_3 << s->cluster_bits, 1);
    if (VAR_5 < 0) {
        return VAR_5;
    }
    return VAR_3;
}
int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,
int VAR_2)
{ BDRVQcowState *s = VAR_0->opaque; uint64_t cluster_index; uint64_t old_free_cluster_index; int VAR_3, VAR_4, VAR_5; cluster_index = VAR_1 >> s->cluster_bits; for(VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) { VAR_4 = get_refcount(VAR_0, cluster_index++); if (VAR_4 < 0) { return VAR_4; } else if (VAR_4 != 0) { break; } } VAR_5 = update_refcount(VAR_0, VAR_1, VAR_3 << s->cluster_bits, 1); if (VAR_5 < 0) { return VAR_5; } return VAR_3; }