static int do_multi(int multi, int size_num)
{
    int n;
    int fd[2];
    int *fds;
    static char sep[] = ":";
    fds = app_malloc(sizeof(*fds) * multi, "fd buffer for do_multi");
    for (n = 0; n < multi; ++n) {
        if (pipe(fd) == -1) {
            BIO_printf(bio_err, "pipe failure\n");
            exit(1);
        }
        fflush(stdout);
        (void)BIO_flush(bio_err);
        if (fork()) {
            close(fd[1]);
            fds[n] = fd[0];
        } else {
            close(fd[0]);
            close(1);
            if (dup(fd[1]) == -1) {
                BIO_printf(bio_err, "dup failed\n");
                exit(1);
            }
            close(fd[1]);
            mr = 1;
            usertime = 0;
            OPENSSL_free(fds);
            return 0;
        }
        printf("Forked child %d\n", n);
    }
    for (n = 0; n < multi; ++n) {
        FILE *f;
        char buf[1024];
        char *p;
        f = fdopen(fds[n], "r");
        while (fgets(buf, sizeof(buf), f)) {
            p = strchr(buf, '\n');
            if (p)
                *p = '\0';
            if (buf[0] != '+') {
                BIO_printf(bio_err,
                           "Don't understand line '%s' from child %d\n", buf,
                           n);
                continue;
            }
            printf("Got: %s from %d\n", buf, n);
            if (strncmp(buf, "+F:", 3) == 0) {
                int alg;
                int j;
                p = buf + 3;
                alg = atoi(sstrsep(&p, sep));
                sstrsep(&p, sep);
                for (j = 0; j < size_num; ++j)
                    results[alg][j] += atof(sstrsep(&p, sep));
            } else if (strncmp(buf, "+F2:", 4) == 0) {
                int k;
                double d;
                p = buf + 4;
                k = atoi(sstrsep(&p, sep));
                sstrsep(&p, sep);
                d = atof(sstrsep(&p, sep));
                rsa_results[k][0] += d;
                d = atof(sstrsep(&p, sep));
                rsa_results[k][1] += d;
            }
# ifndef OPENSSL_NO_DSA
            else if (strncmp(buf, "+F3:", 4) == 0) {
                int k;
                double d;
                p = buf + 4;
                k = atoi(sstrsep(&p, sep));
                sstrsep(&p, sep);
                d = atof(sstrsep(&p, sep));
                dsa_results[k][0] += d;
                d = atof(sstrsep(&p, sep));
                dsa_results[k][1] += d;
            }
# endif
# ifndef OPENSSL_NO_EC
            else if (strncmp(buf, "+F4:", 4) == 0) {
                int k;
                double d;
                p = buf + 4;
                k = atoi(sstrsep(&p, sep));
                sstrsep(&p, sep);
                d = atof(sstrsep(&p, sep));
                ecdsa_results[k][0] += d;
                d = atof(sstrsep(&p, sep));
                ecdsa_results[k][1] += d;
            } else if (strncmp(buf, "+F5:", 4) == 0) {
                int k;
                double d;
                p = buf + 4;
                k = atoi(sstrsep(&p, sep));
                sstrsep(&p, sep);
                d = atof(sstrsep(&p, sep));
                ecdh_results[k][0] += d;
            } else if (strncmp(buf, "+F6:", 4) == 0) {
                int k;
                double d;
                p = buf + 4;
                k = atoi(sstrsep(&p, sep));
                sstrsep(&p, sep);
                d = atof(sstrsep(&p, sep));
                eddsa_results[k][0] += d;
                d = atof(sstrsep(&p, sep));
                eddsa_results[k][1] += d;
            }
# endif
            else if (strncmp(buf, "+H:", 3) == 0) {
                ;
            } else
                BIO_printf(bio_err, "Unknown type '%s' from child %d\n", buf,
                           n);
        }
        fclose(f);
    }
    OPENSSL_free(fds);
    return 1;
}
['static int do_multi(int multi, int size_num)\n{\n    int n;\n    int fd[2];\n    int *fds;\n    static char sep[] = ":";\n    fds = app_malloc(sizeof(*fds) * multi, "fd buffer for do_multi");\n    for (n = 0; n < multi; ++n) {\n        if (pipe(fd) == -1) {\n            BIO_printf(bio_err, "pipe failure\\n");\n            exit(1);\n        }\n        fflush(stdout);\n        (void)BIO_flush(bio_err);\n        if (fork()) {\n            close(fd[1]);\n            fds[n] = fd[0];\n        } else {\n            close(fd[0]);\n            close(1);\n            if (dup(fd[1]) == -1) {\n                BIO_printf(bio_err, "dup failed\\n");\n                exit(1);\n            }\n            close(fd[1]);\n            mr = 1;\n            usertime = 0;\n            OPENSSL_free(fds);\n            return 0;\n        }\n        printf("Forked child %d\\n", n);\n    }\n    for (n = 0; n < multi; ++n) {\n        FILE *f;\n        char buf[1024];\n        char *p;\n        f = fdopen(fds[n], "r");\n        while (fgets(buf, sizeof(buf), f)) {\n            p = strchr(buf, \'\\n\');\n            if (p)\n                *p = \'\\0\';\n            if (buf[0] != \'+\') {\n                BIO_printf(bio_err,\n                           "Don\'t understand line \'%s\' from child %d\\n", buf,\n                           n);\n                continue;\n            }\n            printf("Got: %s from %d\\n", buf, n);\n            if (strncmp(buf, "+F:", 3) == 0) {\n                int alg;\n                int j;\n                p = buf + 3;\n                alg = atoi(sstrsep(&p, sep));\n                sstrsep(&p, sep);\n                for (j = 0; j < size_num; ++j)\n                    results[alg][j] += atof(sstrsep(&p, sep));\n            } else if (strncmp(buf, "+F2:", 4) == 0) {\n                int k;\n                double d;\n                p = buf + 4;\n                k = atoi(sstrsep(&p, sep));\n                sstrsep(&p, sep);\n                d = atof(sstrsep(&p, sep));\n                rsa_results[k][0] += d;\n                d = atof(sstrsep(&p, sep));\n                rsa_results[k][1] += d;\n            }\n# ifndef OPENSSL_NO_DSA\n            else if (strncmp(buf, "+F3:", 4) == 0) {\n                int k;\n                double d;\n                p = buf + 4;\n                k = atoi(sstrsep(&p, sep));\n                sstrsep(&p, sep);\n                d = atof(sstrsep(&p, sep));\n                dsa_results[k][0] += d;\n                d = atof(sstrsep(&p, sep));\n                dsa_results[k][1] += d;\n            }\n# endif\n# ifndef OPENSSL_NO_EC\n            else if (strncmp(buf, "+F4:", 4) == 0) {\n                int k;\n                double d;\n                p = buf + 4;\n                k = atoi(sstrsep(&p, sep));\n                sstrsep(&p, sep);\n                d = atof(sstrsep(&p, sep));\n                ecdsa_results[k][0] += d;\n                d = atof(sstrsep(&p, sep));\n                ecdsa_results[k][1] += d;\n            } else if (strncmp(buf, "+F5:", 4) == 0) {\n                int k;\n                double d;\n                p = buf + 4;\n                k = atoi(sstrsep(&p, sep));\n                sstrsep(&p, sep);\n                d = atof(sstrsep(&p, sep));\n                ecdh_results[k][0] += d;\n            } else if (strncmp(buf, "+F6:", 4) == 0) {\n                int k;\n                double d;\n                p = buf + 4;\n                k = atoi(sstrsep(&p, sep));\n                sstrsep(&p, sep);\n                d = atof(sstrsep(&p, sep));\n                eddsa_results[k][0] += d;\n                d = atof(sstrsep(&p, sep));\n                eddsa_results[k][1] += d;\n            }\n# endif\n            else if (strncmp(buf, "+H:", 3) == 0) {\n                ;\n            } else\n                BIO_printf(bio_err, "Unknown type \'%s\' from child %d\\n", buf,\n                           n);\n        }\n        fclose(f);\n    }\n    OPENSSL_free(fds);\n    return 1;\n}', 'void* app_malloc(int sz, const char *what)\n{\n    void *vp = OPENSSL_malloc(sz);\n    return vp;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    return c_CRYPTO_malloc(num, file, line);\n}', 'long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)\n{\n    long ret;\n    if (b == NULL)\n        return 0;\n    if ((b->method == NULL) || (b->method->ctrl == NULL)) {\n        BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD);\n        return -2;\n    }\n    if (b->callback != NULL || b->callback_ex != NULL) {\n        ret = bio_call_callback(b, BIO_CB_CTRL, parg, 0, cmd, larg, 1L, NULL);\n        if (ret <= 0)\n            return ret;\n    }\n    ret = b->method->ctrl(b, cmd, larg, parg);\n    if (b->callback != NULL || b->callback_ex != NULL)\n        ret = bio_call_callback(b, BIO_CB_CTRL | BIO_CB_RETURN, parg, 0, cmd,\n                                larg, ret, NULL);\n    return ret;\n}']