static int discard_f(BlockBackend *blk, int argc, char **argv)

{

    struct timeval t1, t2;

    int Cflag = 0, qflag = 0;

    int c, ret;

    int64_t offset, count;



    while ((c = getopt(argc, argv, "Cq")) != -1) {

        switch (c) {

        case 'C':

            Cflag = 1;

            break;

        case 'q':

            qflag = 1;

            break;

        default:

            return qemuio_command_usage(&discard_cmd);

        }

    }



    if (optind != argc - 2) {

        return qemuio_command_usage(&discard_cmd);

    }



    offset = cvtnum(argv[optind]);

    if (offset < 0) {

        print_cvtnum_err(offset, argv[optind]);

        return 0;

    }



    optind++;

    count = cvtnum(argv[optind]);

    if (count < 0) {

        print_cvtnum_err(count, argv[optind]);

        return 0;

    } else if (count >> BDRV_SECTOR_BITS > INT_MAX) {

        printf("length cannot exceed %"PRIu64", given %s\n",

               (uint64_t)INT_MAX << BDRV_SECTOR_BITS,

               argv[optind]);

        return 0;

    }



    gettimeofday(&t1, NULL);

    ret = blk_discard(blk, offset >> BDRV_SECTOR_BITS,

                      count >> BDRV_SECTOR_BITS);

    gettimeofday(&t2, NULL);



    if (ret < 0) {

        printf("discard failed: %s\n", strerror(-ret));

        goto out;

    }



    /* Finally, report back -- -C gives a parsable format */

    if (!qflag) {

        t2 = tsub(t2, t1);

        print_report("discard", &t2, offset, count, count, 1, Cflag);

    }



out:

    return 0;

}

static int discard_f(BlockBackend *blk, int argc, char **argv)

{

    struct timeval t1, t2;

    int Cflag = 0, qflag = 0;

    int c, ret;

    int64_t offset, count;



    while ((c = getopt(argc, argv, "Cq")) != -1) {

        switch (c) {

        case 'C':

            Cflag = 1;

            break;

        case 'q':

            qflag = 1;

            break;

        default:

            return qemuio_command_usage(&discard_cmd);

        }

    }



    if (optind != argc - 2) {

        return qemuio_command_usage(&discard_cmd);

    }



    offset = cvtnum(argv[optind]);

    if (offset < 0) {

        print_cvtnum_err(offset, argv[optind]);

        return 0;

    }



    optind++;

    count = cvtnum(argv[optind]);

    if (count < 0) {

        print_cvtnum_err(count, argv[optind]);

        return 0;

    } else if (count >> BDRV_SECTOR_BITS > INT_MAX) {

        printf("length cannot exceed %"PRIu64", given %s\n",

               (uint64_t)INT_MAX << BDRV_SECTOR_BITS,

               argv[optind]);

        return 0;

    }



    gettimeofday(&t1, NULL);

    ret = blk_discard(blk, offset >> BDRV_SECTOR_BITS,

                      count >> BDRV_SECTOR_BITS);

    gettimeofday(&t2, NULL);



    if (ret < 0) {

        printf("discard failed: %s\n", strerror(-ret));

        goto out;

    }



    

    if (!qflag) {

        t2 = tsub(t2, t1);

        print_report("discard", &t2, offset, count, count, 1, Cflag);

    }



out:

    return 0;

}

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

{

    struct timeval VAR_3, VAR_4;

    int VAR_5 = 0, VAR_6 = 0;

    int VAR_7, VAR_8;

    int64_t offset, count;



    while ((VAR_7 = getopt(VAR_1, VAR_2, "Cq")) != -1) {

        switch (VAR_7) {

        case 'C':

            VAR_5 = 1;

            break;

        case 'q':

            VAR_6 = 1;

            break;

        default:

            return qemuio_command_usage(&discard_cmd);

        }

    }



    if (optind != VAR_1 - 2) {

        return qemuio_command_usage(&discard_cmd);

    }



    offset = cvtnum(VAR_2[optind]);

    if (offset < 0) {

        print_cvtnum_err(offset, VAR_2[optind]);

        return 0;

    }



    optind++;

    count = cvtnum(VAR_2[optind]);

    if (count < 0) {

        print_cvtnum_err(count, VAR_2[optind]);

        return 0;

    } else if (count >> BDRV_SECTOR_BITS > INT_MAX) {

        printf("length cannot exceed %"PRIu64", given %s\n",

               (uint64_t)INT_MAX << BDRV_SECTOR_BITS,

               VAR_2[optind]);

        return 0;

    }



    gettimeofday(&VAR_3, NULL);

    VAR_8 = blk_discard(VAR_0, offset >> BDRV_SECTOR_BITS,

                      count >> BDRV_SECTOR_BITS);

    gettimeofday(&VAR_4, NULL);



    if (VAR_8 < 0) {

        printf("discard failed: %s\n", strerror(-VAR_8));

        goto out;

    }



    

    if (!VAR_6) {

        VAR_4 = tsub(VAR_4, VAR_3);

        print_report("discard", &VAR_4, offset, count, count, 1, VAR_5);

    }



out:

    return 0;

}

static int FUNC_0(BlockBackend *VAR_0, int VAR_1, char **VAR_2)
{ struct timeval VAR_3, VAR_4; int VAR_5 = 0, VAR_6 = 0; int VAR_7, VAR_8; int64_t offset, count; while ((VAR_7 = getopt(VAR_1, VAR_2, "Cq")) != -1) { switch (VAR_7) { case 'C':
VAR_5 = 1; break; case 'q':
VAR_6 = 1; break; default:
return qemuio_command_usage(&discard_cmd); } } if (optind != VAR_1 - 2) { return qemuio_command_usage(&discard_cmd); } offset = cvtnum(VAR_2[optind]); if (offset < 0) { print_cvtnum_err(offset, VAR_2[optind]); return 0; } optind++; count = cvtnum(VAR_2[optind]); if (count < 0) { print_cvtnum_err(count, VAR_2[optind]); return 0; } else if (count >> BDRV_SECTOR_BITS > INT_MAX) { printf("length cannot exceed %"PRIu64", given %s\n",
(uint64_t)INT_MAX << BDRV_SECTOR_BITS,
VAR_2[optind]); return 0; } gettimeofday(&VAR_3, NULL); VAR_8 = blk_discard(VAR_0, offset >> BDRV_SECTOR_BITS,
count >> BDRV_SECTOR_BITS); gettimeofday(&VAR_4, NULL); if (VAR_8 < 0) { printf("discard failed: %s\n", strerror(-VAR_8)); goto out; } if (!VAR_6) { VAR_4 = tsub(VAR_4, VAR_3); print_report("discard", &VAR_4, offset, count, count, 1, VAR_5); } out:
return 0; }