void CRYPTO_free(void *str, const char *file, int line)
{
    if (free_impl != NULL && free_impl != &CRYPTO_free) {
        free_impl(str, file, line);
        return;
    }
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
    if (call_malloc_debug) {
        CRYPTO_mem_debug_free(str, 0, file, line);
        free(str);
        CRYPTO_mem_debug_free(str, 1, file, line);
    } else {
        free(str);
    }
#else
    free(str);
#endif
}
['ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it)\n{\n    BIO *asnin;\n    STACK_OF(MIME_HEADER) *headers = NULL;\n    STACK_OF(BIO) *parts = NULL;\n    MIME_HEADER *hdr;\n    MIME_PARAM *prm;\n    ASN1_VALUE *val;\n    int ret;\n    if (bcont)\n        *bcont = NULL;\n    if ((headers = mime_parse_hdr(bio)) == NULL) {\n        ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_MIME_PARSE_ERROR);\n        return NULL;\n    }\n    if ((hdr = mime_hdr_find(headers, "content-type")) == NULL\n        || hdr->value == NULL) {\n        sk_MIME_HEADER_pop_free(headers, mime_hdr_free);\n        ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_CONTENT_TYPE);\n        return NULL;\n    }\n    if (strcmp(hdr->value, "multipart/signed") == 0) {\n        prm = mime_param_find(hdr, "boundary");\n        if (!prm || !prm->param_value) {\n            sk_MIME_HEADER_pop_free(headers, mime_hdr_free);\n            ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_MULTIPART_BOUNDARY);\n            return NULL;\n        }\n        ret = multi_split(bio, prm->param_value, &parts);\n        sk_MIME_HEADER_pop_free(headers, mime_hdr_free);\n        if (!ret || (sk_BIO_num(parts) != 2)) {\n            ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_MULTIPART_BODY_FAILURE);\n            sk_BIO_pop_free(parts, BIO_vfree);\n            return NULL;\n        }\n        asnin = sk_BIO_value(parts, 1);\n        if ((headers = mime_parse_hdr(asnin)) == NULL) {\n            ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_MIME_SIG_PARSE_ERROR);\n            sk_BIO_pop_free(parts, BIO_vfree);\n            return NULL;\n        }\n        if ((hdr = mime_hdr_find(headers, "content-type")) == NULL\n            || hdr->value == NULL) {\n            sk_MIME_HEADER_pop_free(headers, mime_hdr_free);\n            ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_SIG_CONTENT_TYPE);\n            return NULL;\n        }\n        if (strcmp(hdr->value, "application/x-pkcs7-signature") &&\n            strcmp(hdr->value, "application/pkcs7-signature")) {\n            ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_SIG_INVALID_MIME_TYPE);\n            ERR_add_error_data(2, "type: ", hdr->value);\n            sk_MIME_HEADER_pop_free(headers, mime_hdr_free);\n            sk_BIO_pop_free(parts, BIO_vfree);\n            return NULL;\n        }\n        sk_MIME_HEADER_pop_free(headers, mime_hdr_free);\n        if ((val = b64_read_asn1(asnin, it)) == NULL) {\n            ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_ASN1_SIG_PARSE_ERROR);\n            sk_BIO_pop_free(parts, BIO_vfree);\n            return NULL;\n        }\n        if (bcont) {\n            *bcont = sk_BIO_value(parts, 0);\n            BIO_free(asnin);\n            sk_BIO_free(parts);\n        } else\n            sk_BIO_pop_free(parts, BIO_vfree);\n        return val;\n    }\n    if (strcmp(hdr->value, "application/x-pkcs7-mime") &&\n        strcmp(hdr->value, "application/pkcs7-mime")) {\n        ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_INVALID_MIME_TYPE);\n        ERR_add_error_data(2, "type: ", hdr->value);\n        sk_MIME_HEADER_pop_free(headers, mime_hdr_free);\n        return NULL;\n    }\n    sk_MIME_HEADER_pop_free(headers, mime_hdr_free);\n    if ((val = b64_read_asn1(bio, it)) == NULL) {\n        ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_ASN1_PARSE_ERROR);\n        return NULL;\n    }\n    return val;\n}', 'static int multi_split(BIO *bio, const char *bound, STACK_OF(BIO) **ret)\n{\n    char linebuf[MAX_SMLEN];\n    int len, blen;\n    int eol = 0, next_eol = 0;\n    BIO *bpart = NULL;\n    STACK_OF(BIO) *parts;\n    char state, part, first;\n    blen = strlen(bound);\n    part = 0;\n    state = 0;\n    first = 1;\n    parts = sk_BIO_new_null();\n    *ret = parts;\n    if (*ret == NULL)\n        return 0;\n    while ((len = BIO_gets(bio, linebuf, MAX_SMLEN)) > 0) {\n        state = mime_bound_check(linebuf, len, bound, blen);\n        if (state == 1) {\n            first = 1;\n            part++;\n        } else if (state == 2) {\n            if (!sk_BIO_push(parts, bpart)) {\n                BIO_free(bpart);\n                return 0;\n            }\n            return 1;\n        } else if (part) {\n            next_eol = strip_eol(linebuf, &len, 0);\n            if (first) {\n                first = 0;\n                if (bpart)\n                    if (!sk_BIO_push(parts, bpart)) {\n                        BIO_free(bpart);\n                        return 0;\n                    }\n                bpart = BIO_new(BIO_s_mem());\n                if (bpart == NULL)\n                    return 0;\n                BIO_set_mem_eof_return(bpart, 0);\n            } else if (eol)\n                BIO_write(bpart, "\\r\\n", 2);\n            eol = next_eol;\n            if (len)\n                BIO_write(bpart, linebuf, len);\n        }\n    }\n    BIO_free(bpart);\n    return 0;\n}', 'int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data)\n{\n    if (st == NULL)\n        return -1;\n    return OPENSSL_sk_insert(st, data, st->num);\n}', 'int OPENSSL_sk_insert(OPENSSL_STACK *st, const void *data, int loc)\n{\n    if (st == NULL || st->num < 0 || st->num == max_nodes)\n        return 0;\n    if (!sk_reserve(st, 1, 0))\n        return 0;\n    if ((loc >= st->num) || (loc < 0)) {\n        st->data[st->num] = data;\n    } else {\n        memmove(&st->data[loc + 1], &st->data[loc],\n                sizeof(st->data[0]) * (st->num - loc));\n        st->data[loc] = data;\n    }\n    st->num++;\n    st->sorted = 0;\n    return st->num;\n}', 'static int sk_reserve(OPENSSL_STACK *st, int n, int exact)\n{\n    const void **tmpdata;\n    int num_alloc;\n    if (n > max_nodes - st->num)\n        return 0;\n    num_alloc = st->num + n;\n    if (num_alloc < min_nodes)\n        num_alloc = min_nodes;\n    if (st->data == NULL) {\n        st->data = OPENSSL_zalloc(sizeof(void *) * num_alloc);\n        if (st->data == NULL)\n            return 0;\n        st->num_alloc = num_alloc;\n        return 1;\n    }\n    if (!exact) {\n        if (num_alloc <= st->num_alloc)\n            return 1;\n        num_alloc = compute_growth(num_alloc, st->num_alloc);\n        if (num_alloc == 0)\n            return 0;\n    } else if (num_alloc == st->num_alloc) {\n        return 1;\n    }\n    tmpdata = OPENSSL_realloc((void *)st->data, sizeof(void *) * num_alloc);\n    if (tmpdata == NULL)\n        return 0;\n    st->data = tmpdata;\n    st->num_alloc = num_alloc;\n    return 1;\n}', 'void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)\n{\n    if (realloc_impl != NULL && realloc_impl != &CRYPTO_realloc)\n        return realloc_impl(str, num, file, line);\n    FAILTEST();\n    if (str == NULL)\n        return CRYPTO_malloc(num, file, line);\n    if (num == 0) {\n        CRYPTO_free(str, file, line);\n        return NULL;\n    }\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        void *ret;\n        CRYPTO_mem_debug_realloc(str, NULL, num, 0, file, line);\n        ret = realloc(str, num);\n        CRYPTO_mem_debug_realloc(str, ret, num, 1, file, line);\n        return ret;\n    }\n#else\n    (void)(file); (void)(line);\n#endif\n    return realloc(str, num);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']