static void test_fail_bignum_common(const char *prefix, const char *file,
                                    int line, const char *type,
                                    const char *left, const char *right,
                                    const char *op,
                                    const BIGNUM *bn1, const BIGNUM *bn2)
{
    const int indent = subtest_level();
    const size_t bytes = bn_bytes;
    char b1[MAX_STRING_WIDTH + 1], b2[MAX_STRING_WIDTH + 1];
    char *p, bdiff[MAX_STRING_WIDTH + 1];
    size_t l1, l2, n1, n2, i, len;
    unsigned int cnt, diff, real_diff;
    unsigned char *m1 = NULL, *m2 = NULL;
    int lz1 = 1, lz2 = 1;
    unsigned char buffer[MEM_BUFFER_SIZE * 2], *bufp = buffer;
    l1 = bn1 == NULL ? 0 : (BN_num_bytes(bn1) + (BN_is_negative(bn1) ? 1 : 0));
    l2 = bn2 == NULL ? 0 : (BN_num_bytes(bn2) + (BN_is_negative(bn2) ? 1 : 0));
    if (l1 == 0 && l2 == 0) {
        if ((bn1 == NULL) == (bn2 == NULL)) {
            test_bignum_header_line();
            test_bignum_zero_print(bn1, ' ');
        } else {
            test_diff_header(left, right);
            test_bignum_header_line();
            test_bignum_zero_print(bn1, '-');
            test_bignum_zero_print(bn2, '+');
        }
        goto fin;
    }
    if (l1 != l2 || bn1 == NULL || bn2 == NULL || BN_cmp(bn1, bn2) != 0)
        test_diff_header(left, right);
    test_bignum_header_line();
    len = ((l1 > l2 ? l1 : l2) + bytes - 1) / bytes * bytes;
    if (len > MEM_BUFFER_SIZE && (bufp = OPENSSL_malloc(len * 2)) == NULL) {
        bufp = buffer;
        len = MEM_BUFFER_SIZE;
        test_printf_stderr("%*s# WARNING: these BIGNUMs have been truncated",
                           indent, "");
    }
    if (bn1 != NULL) {
        m1 = bufp;
        BN_bn2binpad(bn1, m1, len);
    }
    if (bn2 != NULL) {
        m2 = bufp + len;
        BN_bn2binpad(bn2, m2, len);
    }
    while (len > 0) {
        cnt = 8 * (len - bytes);
        n1 = convert_bn_memory(m1, bytes, b1, &lz1, bn1);
        n2 = convert_bn_memory(m2, bytes, b2, &lz2, bn2);
        diff = real_diff = 0;
        i = 0;
        p = bdiff;
        for (i=0; b1[i] != '\0'; i++)
            if (b1[i] == b2[i] || b1[i] == ' ' || b2[i] == ' ') {
                *p++ = ' ';
                diff |= b1[i] != b2[i];
            } else {
                *p++ = '^';
                real_diff = diff = 1;
            }
        *p++ = '\0';
        if (!diff) {
            test_printf_stderr("%*s#  %s:% 5d\n", indent, "",
                               n2 > n1 ? b2 : b1, cnt);
        } else {
            if (cnt == 0 && bn1 == NULL)
                test_printf_stderr("%*s# -%s\n", indent, "", b1);
            else if (cnt == 0 || n1 > 0)
                test_printf_stderr("%*s# -%s:% 5d\n", indent, "", b1, cnt);
            if (cnt == 0 && bn2 == NULL)
                test_printf_stderr("%*s# +%s\n", indent, "", b2);
            else if (cnt == 0 || n2 > 0)
                test_printf_stderr("%*s# +%s:% 5d\n", indent, "", b2, cnt);
            if (real_diff && (cnt == 0 || (n1 > 0 && n2 > 0))
                    && bn1 != NULL && bn2 != NULL)
                test_printf_stderr("%*s#  %s\n", indent, "", bdiff);
        }
        if (m1 != NULL)
            m1 += bytes;
        if (m2 != NULL)
            m2 += bytes;
        len -= bytes;
    }
fin:
    test_printf_stderr("\n");
    test_flush_stderr();
    if (bufp != buffer)
        OPENSSL_free(bufp);
}
['static void test_fail_bignum_common(const char *prefix, const char *file,\n                                    int line, const char *type,\n                                    const char *left, const char *right,\n                                    const char *op,\n                                    const BIGNUM *bn1, const BIGNUM *bn2)\n{\n    const int indent = subtest_level();\n    const size_t bytes = bn_bytes;\n    char b1[MAX_STRING_WIDTH + 1], b2[MAX_STRING_WIDTH + 1];\n    char *p, bdiff[MAX_STRING_WIDTH + 1];\n    size_t l1, l2, n1, n2, i, len;\n    unsigned int cnt, diff, real_diff;\n    unsigned char *m1 = NULL, *m2 = NULL;\n    int lz1 = 1, lz2 = 1;\n    unsigned char buffer[MEM_BUFFER_SIZE * 2], *bufp = buffer;\n    l1 = bn1 == NULL ? 0 : (BN_num_bytes(bn1) + (BN_is_negative(bn1) ? 1 : 0));\n    l2 = bn2 == NULL ? 0 : (BN_num_bytes(bn2) + (BN_is_negative(bn2) ? 1 : 0));\n    if (l1 == 0 && l2 == 0) {\n        if ((bn1 == NULL) == (bn2 == NULL)) {\n            test_bignum_header_line();\n            test_bignum_zero_print(bn1, \' \');\n        } else {\n            test_diff_header(left, right);\n            test_bignum_header_line();\n            test_bignum_zero_print(bn1, \'-\');\n            test_bignum_zero_print(bn2, \'+\');\n        }\n        goto fin;\n    }\n    if (l1 != l2 || bn1 == NULL || bn2 == NULL || BN_cmp(bn1, bn2) != 0)\n        test_diff_header(left, right);\n    test_bignum_header_line();\n    len = ((l1 > l2 ? l1 : l2) + bytes - 1) / bytes * bytes;\n    if (len > MEM_BUFFER_SIZE && (bufp = OPENSSL_malloc(len * 2)) == NULL) {\n        bufp = buffer;\n        len = MEM_BUFFER_SIZE;\n        test_printf_stderr("%*s# WARNING: these BIGNUMs have been truncated",\n                           indent, "");\n    }\n    if (bn1 != NULL) {\n        m1 = bufp;\n        BN_bn2binpad(bn1, m1, len);\n    }\n    if (bn2 != NULL) {\n        m2 = bufp + len;\n        BN_bn2binpad(bn2, m2, len);\n    }\n    while (len > 0) {\n        cnt = 8 * (len - bytes);\n        n1 = convert_bn_memory(m1, bytes, b1, &lz1, bn1);\n        n2 = convert_bn_memory(m2, bytes, b2, &lz2, bn2);\n        diff = real_diff = 0;\n        i = 0;\n        p = bdiff;\n        for (i=0; b1[i] != \'\\0\'; i++)\n            if (b1[i] == b2[i] || b1[i] == \' \' || b2[i] == \' \') {\n                *p++ = \' \';\n                diff |= b1[i] != b2[i];\n            } else {\n                *p++ = \'^\';\n                real_diff = diff = 1;\n            }\n        *p++ = \'\\0\';\n        if (!diff) {\n            test_printf_stderr("%*s#  %s:% 5d\\n", indent, "",\n                               n2 > n1 ? b2 : b1, cnt);\n        } else {\n            if (cnt == 0 && bn1 == NULL)\n                test_printf_stderr("%*s# -%s\\n", indent, "", b1);\n            else if (cnt == 0 || n1 > 0)\n                test_printf_stderr("%*s# -%s:% 5d\\n", indent, "", b1, cnt);\n            if (cnt == 0 && bn2 == NULL)\n                test_printf_stderr("%*s# +%s\\n", indent, "", b2);\n            else if (cnt == 0 || n2 > 0)\n                test_printf_stderr("%*s# +%s:% 5d\\n", indent, "", b2, cnt);\n            if (real_diff && (cnt == 0 || (n1 > 0 && n2 > 0))\n                    && bn1 != NULL && bn2 != NULL)\n                test_printf_stderr("%*s#  %s\\n", indent, "", bdiff);\n        }\n        if (m1 != NULL)\n            m1 += bytes;\n        if (m2 != NULL)\n            m2 += bytes;\n        len -= bytes;\n    }\nfin:\n    test_printf_stderr("\\n");\n    test_flush_stderr();\n    if (bufp != buffer)\n        OPENSSL_free(bufp);\n}']