static int multiwrite_f(int argc, char **argv)

{

    struct timeval t1, t2;

    int Cflag = 0, qflag = 0;

    int c, cnt;

    char **buf;

    int64_t offset, first_offset = 0;

    /* Some compilers get confused and warn if this is not initialized.  */

    int total = 0;

    int nr_iov;

    int nr_reqs;

    int pattern = 0xcd;

    QEMUIOVector *qiovs;

    int i;

    BlockRequest *reqs;



    while ((c = getopt(argc, argv, "CqP:")) != EOF) {

        switch (c) {

        case 'C':

            Cflag = 1;

            break;

        case 'q':

            qflag = 1;

            break;

        case 'P':

            pattern = parse_pattern(optarg);

            if (pattern < 0) {

                return 0;

            }

            break;

        default:

            return command_usage(&writev_cmd);

        }

    }



    if (optind > argc - 2) {

        return command_usage(&writev_cmd);

    }



    nr_reqs = 1;

    for (i = optind; i < argc; i++) {

        if (!strcmp(argv[i], ";")) {

            nr_reqs++;

        }

    }



    reqs = g_malloc0(nr_reqs * sizeof(*reqs));

    buf = g_malloc0(nr_reqs * sizeof(*buf));

    qiovs = g_malloc(nr_reqs * sizeof(*qiovs));



    for (i = 0; i < nr_reqs; i++) {

        int j;



        /* Read the offset of the request */

        offset = cvtnum(argv[optind]);

        if (offset < 0) {

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

            return 0;

        }

        optind++;



        if (offset & 0x1ff) {

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

                   (long long)offset);

            return 0;

        }



        if (i == 0) {

            first_offset = offset;

        }



        /* Read lengths for qiov entries */

        for (j = optind; j < argc; j++) {

            if (!strcmp(argv[j], ";")) {

                break;

            }

        }



        nr_iov = j - optind;



        /* Build request */

        buf[i] = create_iovec(&qiovs[i], &argv[optind], nr_iov, pattern);

        if (buf[i] == NULL) {

            goto out;

        }



        reqs[i].qiov = &qiovs[i];

        reqs[i].sector = offset >> 9;

        reqs[i].nb_sectors = reqs[i].qiov->size >> 9;



        optind = j + 1;



        pattern++;

    }



    gettimeofday(&t1, NULL);

    cnt = do_aio_multiwrite(reqs, nr_reqs, &total);

    gettimeofday(&t2, NULL);



    if (cnt < 0) {

        printf("aio_multiwrite failed: %s\n", strerror(-cnt));

        goto out;

    }



    if (qflag) {

        goto out;

    }



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

    t2 = tsub(t2, t1);

    print_report("wrote", &t2, first_offset, total, total, cnt, Cflag);

out:

    for (i = 0; i < nr_reqs; i++) {

        qemu_io_free(buf[i]);

        if (reqs[i].qiov != NULL) {

            qemu_iovec_destroy(&qiovs[i]);

        }

    }

    g_free(buf);

    g_free(reqs);

    g_free(qiovs);

    return 0;

}

static int multiwrite_f(int argc, char **argv)

{

    struct timeval t1, t2;

    int Cflag = 0, qflag = 0;

    int c, cnt;

    char **buf;

    int64_t offset, first_offset = 0;

    

    int total = 0;

    int nr_iov;

    int nr_reqs;

    int pattern = 0xcd;

    QEMUIOVector *qiovs;

    int i;

    BlockRequest *reqs;



    while ((c = getopt(argc, argv, "CqP:")) != EOF) {

        switch (c) {

        case 'C':

            Cflag = 1;

            break;

        case 'q':

            qflag = 1;

            break;

        case 'P':

            pattern = parse_pattern(optarg);

            if (pattern < 0) {

                return 0;

            }

            break;

        default:

            return command_usage(&writev_cmd);

        }

    }



    if (optind > argc - 2) {

        return command_usage(&writev_cmd);

    }



    nr_reqs = 1;

    for (i = optind; i < argc; i++) {

        if (!strcmp(argv[i], ";")) {

            nr_reqs++;

        }

    }



    reqs = g_malloc0(nr_reqs * sizeof(*reqs));

    buf = g_malloc0(nr_reqs * sizeof(*buf));

    qiovs = g_malloc(nr_reqs * sizeof(*qiovs));



    for (i = 0; i < nr_reqs; i++) {

        int j;



        

        offset = cvtnum(argv[optind]);

        if (offset < 0) {

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

            return 0;

        }

        optind++;



        if (offset & 0x1ff) {

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

                   (long long)offset);

            return 0;

        }



        if (i == 0) {

            first_offset = offset;

        }



        

        for (j = optind; j < argc; j++) {

            if (!strcmp(argv[j], ";")) {

                break;

            }

        }



        nr_iov = j - optind;



        

        buf[i] = create_iovec(&qiovs[i], &argv[optind], nr_iov, pattern);

        if (buf[i] == NULL) {

            goto out;

        }



        reqs[i].qiov = &qiovs[i];

        reqs[i].sector = offset >> 9;

        reqs[i].nb_sectors = reqs[i].qiov->size >> 9;



        optind = j + 1;



        pattern++;

    }



    gettimeofday(&t1, NULL);

    cnt = do_aio_multiwrite(reqs, nr_reqs, &total);

    gettimeofday(&t2, NULL);



    if (cnt < 0) {

        printf("aio_multiwrite failed: %s\n", strerror(-cnt));

        goto out;

    }



    if (qflag) {

        goto out;

    }



    

    t2 = tsub(t2, t1);

    print_report("wrote", &t2, first_offset, total, total, cnt, Cflag);

out:

    for (i = 0; i < nr_reqs; i++) {

        qemu_io_free(buf[i]);

        if (reqs[i].qiov != NULL) {

            qemu_iovec_destroy(&qiovs[i]);

        }

    }

    g_free(buf);

    g_free(reqs);

    g_free(qiovs);

    return 0;

}

    for (i = 0; i < nr_reqs; i++) {             return 0;             return 0;
static int FUNC_0(int VAR_0, char **VAR_1)

{

    struct timeval VAR_2, VAR_3;

    int VAR_4 = 0, VAR_5 = 0;

    int VAR_6, VAR_7;

    char **VAR_8;

    int64_t offset, first_offset = 0;

    

    int VAR_9 = 0;

    int VAR_10;

    int VAR_11;

    int VAR_12 = 0xcd;

    QEMUIOVector *qiovs;

    int VAR_13;

    BlockRequest *reqs;



    while ((VAR_6 = getopt(VAR_0, VAR_1, "CqP:")) != EOF) {

        switch (VAR_6) {

        case 'C':

            VAR_4 = 1;

            break;

        case 'q':

            VAR_5 = 1;

            break;

        case 'P':

            VAR_12 = parse_pattern(optarg);

            if (VAR_12 < 0) {

                return 0;

            }

            break;

        default:

            return command_usage(&writev_cmd);

        }

    }



    if (optind > VAR_0 - 2) {

        return command_usage(&writev_cmd);

    }



    VAR_11 = 1;

    for (VAR_13 = optind; VAR_13 < VAR_0; VAR_13++) {

        if (!strcmp(VAR_1[VAR_13], ";")) {

            VAR_11++;

        }

    }



    reqs = g_malloc0(VAR_11 * sizeof(*reqs));

    VAR_8 = g_malloc0(VAR_11 * sizeof(*VAR_8));

    qiovs = g_malloc(VAR_11 * sizeof(*qiovs));



    for (VAR_13 = 0; VAR_13 < VAR_11; VAR_13++) {

        int VAR_14;



        

        offset = cvtnum(VAR_1[optind]);

        if (offset < 0) {

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

            return 0;

        }

        optind++;



        if (offset & 0x1ff) {

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

                   (long long)offset);

            return 0;

        }



        if (VAR_13 == 0) {

            first_offset = offset;

        }



        

        for (VAR_14 = optind; VAR_14 < VAR_0; VAR_14++) {

            if (!strcmp(VAR_1[VAR_14], ";")) {

                break;

            }

        }



        VAR_10 = VAR_14 - optind;



        

        VAR_8[VAR_13] = create_iovec(&qiovs[VAR_13], &VAR_1[optind], VAR_10, VAR_12);

        if (VAR_8[VAR_13] == NULL) {

            goto out;

        }



        reqs[VAR_13].qiov = &qiovs[VAR_13];

        reqs[VAR_13].sector = offset >> 9;

        reqs[VAR_13].nb_sectors = reqs[VAR_13].qiov->size >> 9;



        optind = VAR_14 + 1;



        VAR_12++;

    }



    gettimeofday(&VAR_2, NULL);

    VAR_7 = do_aio_multiwrite(reqs, VAR_11, &VAR_9);

    gettimeofday(&VAR_3, NULL);



    if (VAR_7 < 0) {

        printf("aio_multiwrite failed: %s\n", strerror(-VAR_7));

        goto out;

    }



    if (VAR_5) {

        goto out;

    }



    

    VAR_3 = tsub(VAR_3, VAR_2);

    print_report("wrote", &VAR_3, first_offset, VAR_9, VAR_9, VAR_7, VAR_4);

out:

    for (VAR_13 = 0; VAR_13 < VAR_11; VAR_13++) {

        qemu_io_free(VAR_8[VAR_13]);

        if (reqs[VAR_13].qiov != NULL) {

            qemu_iovec_destroy(&qiovs[VAR_13]);

        }

    }

    g_free(VAR_8);

    g_free(reqs);

    g_free(qiovs);

    return 0;

}

static int FUNC_0(int VAR_0, char **VAR_1)
{ struct timeval VAR_2, VAR_3; int VAR_4 = 0, VAR_5 = 0; int VAR_6, VAR_7; char **VAR_8; int64_t offset, first_offset = 0; int VAR_9 = 0; int VAR_10; int VAR_11; int VAR_12 = 0xcd; QEMUIOVector *qiovs; int VAR_13; BlockRequest *reqs; while ((VAR_6 = getopt(VAR_0, VAR_1, "CqP:")) != EOF) { switch (VAR_6) { case 'C':
VAR_4 = 1; break; case 'q':
VAR_5 = 1; break; case 'P':
VAR_12 = parse_pattern(optarg); if (VAR_12 < 0) { return 0; } break; default:
return command_usage(&writev_cmd); } } if (optind > VAR_0 - 2) { return command_usage(&writev_cmd); } VAR_11 = 1; for (VAR_13 = optind; VAR_13 < VAR_0; VAR_13++) { if (!strcmp(VAR_1[VAR_13], ";")) { VAR_11++; } } reqs = g_malloc0(VAR_11 * sizeof(*reqs)); VAR_8 = g_malloc0(VAR_11 * sizeof(*VAR_8)); qiovs = g_malloc(VAR_11 * sizeof(*qiovs)); for (VAR_13 = 0; VAR_13 < VAR_11; VAR_13++) { int VAR_14; offset = cvtnum(VAR_1[optind]); if (offset < 0) { printf("non-numeric offset argument -- %s\n", VAR_1[optind]); return 0; } optind++; if (offset & 0x1ff) { printf("offset %lld is not sector aligned\n",
(long long)offset); return 0; } if (VAR_13 == 0) { first_offset = offset; } for (VAR_14 = optind; VAR_14 < VAR_0; VAR_14++) { if (!strcmp(VAR_1[VAR_14], ";")) { break; } } VAR_10 = VAR_14 - optind; VAR_8[VAR_13] = create_iovec(&qiovs[VAR_13], &VAR_1[optind], VAR_10, VAR_12); if (VAR_8[VAR_13] == NULL) { goto out; } reqs[VAR_13].qiov = &qiovs[VAR_13]; reqs[VAR_13].sector = offset >> 9; reqs[VAR_13].nb_sectors = reqs[VAR_13].qiov->size >> 9; optind = VAR_14 + 1; VAR_12++; } gettimeofday(&VAR_2, NULL); VAR_7 = do_aio_multiwrite(reqs, VAR_11, &VAR_9); gettimeofday(&VAR_3, NULL); if (VAR_7 < 0) { printf("aio_multiwrite failed: %s\n", strerror(-VAR_7)); goto out; } if (VAR_5) { goto out; } VAR_3 = tsub(VAR_3, VAR_2); print_report("wrote", &VAR_3, first_offset, VAR_9, VAR_9, VAR_7, VAR_4); out:
for (VAR_13 = 0; VAR_13 < VAR_11; VAR_13++) { qemu_io_free(VAR_8[VAR_13]); if (reqs[VAR_13].qiov != NULL) { qemu_iovec_destroy(&qiovs[VAR_13]); } } g_free(VAR_8); g_free(reqs); g_free(qiovs); return 0; }