static ASN1_INTEGER *x509_load_serial(const char *CAfile,
                                      const char *serialfile, int create)
{
    char *buf = NULL;
    ASN1_INTEGER *bs = NULL;
    BIGNUM *serial = NULL;
    if (serialfile == NULL) {
        const char *p = strrchr(CAfile, '.');
        size_t len = p != NULL ? (size_t)(p - CAfile) : strlen(CAfile);
        buf = app_malloc(len + sizeof(POSTFIX), "serial# buffer");
        memcpy(buf, CAfile, len);
        memcpy(buf + len, POSTFIX, sizeof(POSTFIX));
        serialfile = buf;
    }
    serial = load_serial(serialfile, create, NULL);
    if (serial == NULL)
        goto end;
    if (!BN_add_word(serial, 1)) {
        BIO_printf(bio_err, "add_word failure\n");
        goto end;
    }
    if (!save_serial(serialfile, NULL, serial, &bs))
        goto end;
 end:
    OPENSSL_free(buf);
    BN_free(serial);
    return bs;
}
['static ASN1_INTEGER *x509_load_serial(const char *CAfile,\n                                      const char *serialfile, int create)\n{\n    char *buf = NULL;\n    ASN1_INTEGER *bs = NULL;\n    BIGNUM *serial = NULL;\n    if (serialfile == NULL) {\n        const char *p = strrchr(CAfile, \'.\');\n        size_t len = p != NULL ? (size_t)(p - CAfile) : strlen(CAfile);\n        buf = app_malloc(len + sizeof(POSTFIX), "serial# buffer");\n        memcpy(buf, CAfile, len);\n        memcpy(buf + len, POSTFIX, sizeof(POSTFIX));\n        serialfile = buf;\n    }\n    serial = load_serial(serialfile, create, NULL);\n    if (serial == NULL)\n        goto end;\n    if (!BN_add_word(serial, 1)) {\n        BIO_printf(bio_err, "add_word failure\\n");\n        goto end;\n    }\n    if (!save_serial(serialfile, NULL, serial, &bs))\n        goto end;\n end:\n    OPENSSL_free(buf);\n    BN_free(serial);\n    return bs;\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    void *ret = NULL;\n    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    if (allow_customize) {\n        allow_customize = 0;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}']