static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, int type,
                               X509_NAME *name, int *pnmatch)
{
    X509_OBJECT stmp;
    X509 x509_s;
    X509_CRL crl_s;
    int idx;
    stmp.type = type;
    switch (type) {
    case X509_LU_X509:
        stmp.data.x509 = &x509_s;
        x509_s.cert_info.subject = name;
        break;
    case X509_LU_CRL:
        stmp.data.crl = &crl_s;
        crl_s.crl.issuer = name;
        break;
    default:
        return -1;
    }
    idx = sk_X509_OBJECT_find(h, &stmp);
    if (idx >= 0 && pnmatch) {
        int tidx;
        const X509_OBJECT *tobj, *pstmp;
        *pnmatch = 1;
        pstmp = &stmp;
        for (tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++) {
            tobj = sk_X509_OBJECT_value(h, tidx);
            if (x509_object_cmp(&tobj, &pstmp))
                break;
            (*pnmatch)++;
        }
    }
    return idx;
}
['static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, int type,\n                               X509_NAME *name, int *pnmatch)\n{\n    X509_OBJECT stmp;\n    X509 x509_s;\n    X509_CRL crl_s;\n    int idx;\n    stmp.type = type;\n    switch (type) {\n    case X509_LU_X509:\n        stmp.data.x509 = &x509_s;\n        x509_s.cert_info.subject = name;\n        break;\n    case X509_LU_CRL:\n        stmp.data.crl = &crl_s;\n        crl_s.crl.issuer = name;\n        break;\n    default:\n        return -1;\n    }\n    idx = sk_X509_OBJECT_find(h, &stmp);\n    if (idx >= 0 && pnmatch) {\n        int tidx;\n        const X509_OBJECT *tobj, *pstmp;\n        *pnmatch = 1;\n        pstmp = &stmp;\n        for (tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++) {\n            tobj = sk_X509_OBJECT_value(h, tidx);\n            if (x509_object_cmp(&tobj, &pstmp))\n                break;\n            (*pnmatch)++;\n        }\n    }\n    return idx;\n}', 'int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)\n{\n    return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);\n}', 'static int internal_find(OPENSSL_STACK *st, const void *data,\n                         int ret_val_options)\n{\n    const void *const *r;\n    int i;\n    if (st == NULL)\n        return -1;\n    if (st->comp == NULL) {\n        for (i = 0; i < st->num; i++)\n            if (st->data[i] == data)\n                return (i);\n        return (-1);\n    }\n    OPENSSL_sk_sort(st);\n    if (data == NULL)\n        return (-1);\n    r = OBJ_bsearch_ex_(&data, st->data, st->num, sizeof(void *), st->comp,\n                        ret_val_options);\n    if (r == NULL)\n        return (-1);\n    return (int)((char **)r - st->data);\n}', 'int OPENSSL_sk_num(const OPENSSL_STACK *st)\n{\n    if (st == NULL)\n        return -1;\n    return st->num;\n}', 'void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)\n{\n    if (st == NULL || i < 0 || i >= st->num)\n        return NULL;\n    return st->data[i];\n}', 'static int x509_object_cmp(const X509_OBJECT *const *a,\n                           const X509_OBJECT *const *b)\n{\n    int ret;\n    ret = ((*a)->type - (*b)->type);\n    if (ret)\n        return ret;\n    switch ((*a)->type) {\n    case X509_LU_X509:\n        ret = X509_subject_name_cmp((*a)->data.x509, (*b)->data.x509);\n        break;\n    case X509_LU_CRL:\n        ret = X509_CRL_cmp((*a)->data.crl, (*b)->data.crl);\n        break;\n    default:\n        return 0;\n    }\n    return ret;\n}']