static int copy_sectors(BlockDriverState *bs, uint64_t start_sect,

                        uint64_t cluster_offset, int n_start, int n_end)

{

    BDRVQcowState *s = bs->opaque;

    int n, ret;



    n = n_end - n_start;

    if (n <= 0)

        return 0;

    ret = qcow_read(bs, start_sect + n_start, s->cluster_data, n);

    if (ret < 0)

        return ret;

    if (s->crypt_method) {

        qcow2_encrypt_sectors(s, start_sect + n_start,

                        s->cluster_data,

                        s->cluster_data, n, 1,

                        &s->aes_encrypt_key);

    }

    ret = bdrv_write(s->hd, (cluster_offset >> 9) + n_start,

                     s->cluster_data, n);

    if (ret < 0)

        return ret;

    return 0;

}

static int copy_sectors(BlockDriverState *bs, uint64_t start_sect,

                        uint64_t cluster_offset, int n_start, int n_end)

{

    BDRVQcowState *s = bs->opaque;

    int n, ret;



    n = n_end - n_start;

    if (n <= 0)

        return 0;

    ret = qcow_read(bs, start_sect + n_start, s->cluster_data, n);

    if (ret < 0)

        return ret;

    if (s->crypt_method) {

        qcow2_encrypt_sectors(s, start_sect + n_start,

                        s->cluster_data,

                        s->cluster_data, n, 1,

                        &s->aes_encrypt_key);

    }

    ret = bdrv_write(s->hd, (cluster_offset >> 9) + n_start,

                     s->cluster_data, n);

    if (ret < 0)

        return ret;

    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,

                        uint64_t VAR_2, int VAR_3, int VAR_4)

{

    BDRVQcowState *s = VAR_0->opaque;

    int VAR_5, VAR_6;



    VAR_5 = VAR_4 - VAR_3;

    if (VAR_5 <= 0)

        return 0;

    VAR_6 = qcow_read(VAR_0, VAR_1 + VAR_3, s->cluster_data, VAR_5);

    if (VAR_6 < 0)

        return VAR_6;

    if (s->crypt_method) {

        qcow2_encrypt_sectors(s, VAR_1 + VAR_3,

                        s->cluster_data,

                        s->cluster_data, VAR_5, 1,

                        &s->aes_encrypt_key);

    }

    VAR_6 = bdrv_write(s->hd, (VAR_2 >> 9) + VAR_3,

                     s->cluster_data, VAR_5);

    if (VAR_6 < 0)

        return VAR_6;

    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,
uint64_t VAR_2, int VAR_3, int VAR_4)
{ BDRVQcowState *s = VAR_0->opaque; int VAR_5, VAR_6; VAR_5 = VAR_4 - VAR_3; if (VAR_5 <= 0)
return 0; VAR_6 = qcow_read(VAR_0, VAR_1 + VAR_3, s->cluster_data, VAR_5); if (VAR_6 < 0)
return VAR_6; if (s->crypt_method) { qcow2_encrypt_sectors(s, VAR_1 + VAR_3,
s->cluster_data,
s->cluster_data, VAR_5, 1,
&s->aes_encrypt_key); } VAR_6 = bdrv_write(s->hd, (VAR_2 >> 9) + VAR_3,
s->cluster_data, VAR_5); if (VAR_6 < 0)
return VAR_6; return 0; }