static int alloc_f(BlockDriverState *bs, int argc, char **argv)

{

    int64_t offset, sector_num;

    int nb_sectors, remaining;

    char s1[64];

    int num, sum_alloc;

    int ret;



    offset = cvtnum(argv[1]);

    if (offset < 0) {

        printf("non-numeric offset argument -- %s\n", argv[1]);


    } else if (offset & 0x1ff) {

        printf("offset %" PRId64 " is not sector aligned\n",

               offset);





    if (argc == 3) {

        nb_sectors = cvtnum(argv[2]);

        if (nb_sectors < 0) {

            printf("non-numeric length argument -- %s\n", argv[2]);



    } else {

        nb_sectors = 1;




    remaining = nb_sectors;

    sum_alloc = 0;

    sector_num = offset >> 9;

    while (remaining) {

        ret = bdrv_is_allocated(bs, sector_num, remaining, &num);





        sector_num += num;

        remaining -= num;

        if (ret) {

            sum_alloc += num;


        if (num == 0) {

            nb_sectors -= remaining;

            remaining = 0;





    cvtstr(offset, s1, sizeof(s1));



    printf("%d/%d sectors allocated at offset %s\n",

           sum_alloc, nb_sectors, s1);


static int alloc_f(BlockDriverState *bs, int argc, char **argv)

{

    int64_t offset, sector_num;

    int nb_sectors, remaining;

    char s1[64];

    int num, sum_alloc;

    int ret;



    offset = cvtnum(argv[1]);

    if (offset < 0) {

        printf("non-numeric offset argument -- %s\n", argv[1]);


    } else if (offset & 0x1ff) {

        printf("offset %" PRId64 " is not sector aligned\n",

               offset);





    if (argc == 3) {

        nb_sectors = cvtnum(argv[2]);

        if (nb_sectors < 0) {

            printf("non-numeric length argument -- %s\n", argv[2]);



    } else {

        nb_sectors = 1;




    remaining = nb_sectors;

    sum_alloc = 0;

    sector_num = offset >> 9;

    while (remaining) {

        ret = bdrv_is_allocated(bs, sector_num, remaining, &num);





        sector_num += num;

        remaining -= num;

        if (ret) {

            sum_alloc += num;


        if (num == 0) {

            nb_sectors -= remaining;

            remaining = 0;





    cvtstr(offset, s1, sizeof(s1));



    printf("%d/%d sectors allocated at offset %s\n",

           sum_alloc, nb_sectors, s1);


static int FUNC_0(BlockDriverState *VAR_0, int VAR_1, char **VAR_2)

{

    int64_t offset, sector_num;

    int VAR_3, VAR_4;

    char VAR_5[64];

    int VAR_6, VAR_7;

    int VAR_8;



    offset = cvtnum(VAR_2[1]);

    if (offset < 0) {

        printf("non-numeric offset argument -- %s\n", VAR_2[1]);


    } else if (offset & 0x1ff) {

        printf("offset %" PRId64 " is not sector aligned\n",

               offset);





    if (VAR_1 == 3) {

        VAR_3 = cvtnum(VAR_2[2]);

        if (VAR_3 < 0) {

            printf("non-numeric length argument -- %s\n", VAR_2[2]);



    } else {

        VAR_3 = 1;




    VAR_4 = VAR_3;

    VAR_7 = 0;

    sector_num = offset >> 9;

    while (VAR_4) {

        VAR_8 = bdrv_is_allocated(VAR_0, sector_num, VAR_4, &VAR_6);





        sector_num += VAR_6;

        VAR_4 -= VAR_6;

        if (VAR_8) {

            VAR_7 += VAR_6;


        if (VAR_6 == 0) {

            VAR_3 -= VAR_4;

            VAR_4 = 0;





    cvtstr(offset, VAR_5, sizeof(VAR_5));



    printf("%d/%d sectors allocated at offset %s\n",

           VAR_7, VAR_3, VAR_5);


static int FUNC_0(BlockDriverState *VAR_0, int VAR_1, char **VAR_2)
{ int64_t offset, sector_num; int VAR_3, VAR_4; char VAR_5[64]; int VAR_6, VAR_7; int VAR_8; offset = cvtnum(VAR_2[1]); if (offset < 0) { printf("non-numeric offset argument -- %s\n", VAR_2[1]); } else if (offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned\n",
offset); if (VAR_1 == 3) { VAR_3 = cvtnum(VAR_2[2]); if (VAR_3 < 0) { printf("non-numeric length argument -- %s\n", VAR_2[2]); } else { VAR_3 = 1; VAR_4 = VAR_3; VAR_7 = 0; sector_num = offset >> 9; while (VAR_4) { VAR_8 = bdrv_is_allocated(VAR_0, sector_num, VAR_4, &VAR_6); sector_num += VAR_6; VAR_4 -= VAR_6; if (VAR_8) { VAR_7 += VAR_6; if (VAR_6 == 0) { VAR_3 -= VAR_4; VAR_4 = 0; cvtstr(offset, VAR_5, sizeof(VAR_5)); printf("%d/%d sectors allocated at offset %s\n",
VAR_7, VAR_3, VAR_5);