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

{

    struct timeval t1, t2;

    int Cflag = 0, qflag = 0, vflag = 0;

    int c, cnt;

    char *buf;

    int64_t offset;

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

    int total = 0;

    int nr_iov;

    QEMUIOVector qiov;

    int pattern = 0;

    int Pflag = 0;



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

        switch (c) {

        case 'C':

            Cflag = 1;

            break;

        case 'P':

            Pflag = 1;

            pattern = parse_pattern(optarg);

            if (pattern < 0) {

                return 0;

            }

            break;

        case 'q':

            qflag = 1;

            break;

        case 'v':

            vflag = 1;

            break;

        default:

            return command_usage(&readv_cmd);

        }

    }



    if (optind > argc - 2) {

        return command_usage(&readv_cmd);

    }





    offset = cvtnum(argv[optind]);

    if (offset < 0) {

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

        return 0;

    }

    optind++;



    if (offset & 0x1ff) {

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

               offset);

        return 0;

    }



    nr_iov = argc - optind;

    buf = create_iovec(&qiov, &argv[optind], nr_iov, 0xab);

    if (buf == NULL) {

        return 0;

    }



    gettimeofday(&t1, NULL);

    cnt = do_aio_readv(&qiov, offset, &total);

    gettimeofday(&t2, NULL);



    if (cnt < 0) {

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

        goto out;

    }



    if (Pflag) {

        void *cmp_buf = malloc(qiov.size);

        memset(cmp_buf, pattern, qiov.size);

        if (memcmp(buf, cmp_buf, qiov.size)) {

            printf("Pattern verification failed at offset %"

                   PRId64 ", %zd bytes\n", offset, qiov.size);

        }

        free(cmp_buf);

    }



    if (qflag) {

        goto out;

    }



    if (vflag) {

        dump_buffer(buf, offset, qiov.size);

    }



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

    t2 = tsub(t2, t1);

    print_report("read", &t2, offset, qiov.size, total, cnt, Cflag);



out:

    qemu_io_free(buf);

    return 0;

}

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

{

    struct timeval t1, t2;

    int Cflag = 0, qflag = 0, vflag = 0;

    int c, cnt;

    char *buf;

    int64_t offset;

    

    int total = 0;

    int nr_iov;

    QEMUIOVector qiov;

    int pattern = 0;

    int Pflag = 0;



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

        switch (c) {

        case 'C':

            Cflag = 1;

            break;

        case 'P':

            Pflag = 1;

            pattern = parse_pattern(optarg);

            if (pattern < 0) {

                return 0;

            }

            break;

        case 'q':

            qflag = 1;

            break;

        case 'v':

            vflag = 1;

            break;

        default:

            return command_usage(&readv_cmd);

        }

    }



    if (optind > argc - 2) {

        return command_usage(&readv_cmd);

    }





    offset = cvtnum(argv[optind]);

    if (offset < 0) {

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

        return 0;

    }

    optind++;



    if (offset & 0x1ff) {

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

               offset);

        return 0;

    }



    nr_iov = argc - optind;

    buf = create_iovec(&qiov, &argv[optind], nr_iov, 0xab);

    if (buf == NULL) {

        return 0;

    }



    gettimeofday(&t1, NULL);

    cnt = do_aio_readv(&qiov, offset, &total);

    gettimeofday(&t2, NULL);



    if (cnt < 0) {

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

        goto out;

    }



    if (Pflag) {

        void *cmp_buf = malloc(qiov.size);

        memset(cmp_buf, pattern, qiov.size);

        if (memcmp(buf, cmp_buf, qiov.size)) {

            printf("Pattern verification failed at offset %"

                   PRId64 ", %zd bytes\n", offset, qiov.size);

        }

        free(cmp_buf);

    }



    if (qflag) {

        goto out;

    }



    if (vflag) {

        dump_buffer(buf, offset, qiov.size);

    }



    

    t2 = tsub(t2, t1);

    print_report("read", &t2, offset, qiov.size, total, cnt, Cflag);



out:

    qemu_io_free(buf);

    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, VAR_6 = 0;

    int VAR_7, VAR_8;

    char *VAR_9;

    int64_t offset;

    

    int VAR_10 = 0;

    int VAR_11;

    QEMUIOVector qiov;

    int VAR_12 = 0;

    int VAR_13 = 0;



    while ((VAR_7 = getopt(VAR_0, VAR_1, "CP:qv")) != EOF) {

        switch (VAR_7) {

        case 'C':

            VAR_4 = 1;

            break;

        case 'P':

            VAR_13 = 1;

            VAR_12 = parse_pattern(optarg);

            if (VAR_12 < 0) {

                return 0;

            }

            break;

        case 'q':

            VAR_5 = 1;

            break;

        case 'v':

            VAR_6 = 1;

            break;

        default:

            return command_usage(&readv_cmd);

        }

    }



    if (optind > VAR_0 - 2) {

        return command_usage(&readv_cmd);

    }





    offset = cvtnum(VAR_1[optind]);

    if (offset < 0) {

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

        return 0;

    }

    optind++;



    if (offset & 0x1ff) {

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

               offset);

        return 0;

    }



    VAR_11 = VAR_0 - optind;

    VAR_9 = create_iovec(&qiov, &VAR_1[optind], VAR_11, 0xab);

    if (VAR_9 == NULL) {

        return 0;

    }



    gettimeofday(&VAR_2, NULL);

    VAR_8 = do_aio_readv(&qiov, offset, &VAR_10);

    gettimeofday(&VAR_3, NULL);



    if (VAR_8 < 0) {

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

        goto out;

    }



    if (VAR_13) {

        void *VAR_14 = malloc(qiov.size);

        memset(VAR_14, VAR_12, qiov.size);

        if (memcmp(VAR_9, VAR_14, qiov.size)) {

            printf("Pattern verification failed at offset %"

                   PRId64 ", %zd bytes\n", offset, qiov.size);

        }

        free(VAR_14);

    }



    if (VAR_5) {

        goto out;

    }



    if (VAR_6) {

        dump_buffer(VAR_9, offset, qiov.size);

    }



    

    VAR_3 = tsub(VAR_3, VAR_2);

    print_report("read", &VAR_3, offset, qiov.size, VAR_10, VAR_8, VAR_4);



out:

    qemu_io_free(VAR_9);

    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, VAR_6 = 0; int VAR_7, VAR_8; char *VAR_9; int64_t offset; int VAR_10 = 0; int VAR_11; QEMUIOVector qiov; int VAR_12 = 0; int VAR_13 = 0; while ((VAR_7 = getopt(VAR_0, VAR_1, "CP:qv")) != EOF) { switch (VAR_7) { case 'C':
VAR_4 = 1; break; case 'P':
VAR_13 = 1; VAR_12 = parse_pattern(optarg); if (VAR_12 < 0) { return 0; } break; case 'q':
VAR_5 = 1; break; case 'v':
VAR_6 = 1; break; default:
return command_usage(&readv_cmd); } } if (optind > VAR_0 - 2) { return command_usage(&readv_cmd); } offset = cvtnum(VAR_1[optind]); if (offset < 0) { printf("non-numeric length argument -- %s\n", VAR_1[optind]); return 0; } optind++; if (offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned\n",
offset); return 0; } VAR_11 = VAR_0 - optind; VAR_9 = create_iovec(&qiov, &VAR_1[optind], VAR_11, 0xab); if (VAR_9 == NULL) { return 0; } gettimeofday(&VAR_2, NULL); VAR_8 = do_aio_readv(&qiov, offset, &VAR_10); gettimeofday(&VAR_3, NULL); if (VAR_8 < 0) { printf("readv failed: %s\n", strerror(-VAR_8)); goto out; } if (VAR_13) { void *VAR_14 = malloc(qiov.size); memset(VAR_14, VAR_12, qiov.size); if (memcmp(VAR_9, VAR_14, qiov.size)) { printf("Pattern verification failed at offset %"
PRId64 ", %zd bytes\n", offset, qiov.size); } free(VAR_14); } if (VAR_5) { goto out; } if (VAR_6) { dump_buffer(VAR_9, offset, qiov.size); } VAR_3 = tsub(VAR_3, VAR_2); print_report("read", &VAR_3, offset, qiov.size, VAR_10, VAR_8, VAR_4); out:
qemu_io_free(VAR_9); return 0; }