X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,
                                        X509_OBJECT *x)
{
    int idx, i;
    X509_OBJECT *obj;
    idx = sk_X509_OBJECT_find(h, x);
    if (idx == -1)
        return NULL;
    if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
        return sk_X509_OBJECT_value(h, idx);
    for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
        obj = sk_X509_OBJECT_value(h, i);
        if (x509_object_cmp
            ((const X509_OBJECT **)&obj, (const X509_OBJECT **)&x))
            return NULL;
        if (x->type == X509_LU_X509) {
            if (!X509_cmp(obj->data.x509, x->data.x509))
                return obj;
        } else if (x->type == X509_LU_CRL) {
            if (!X509_CRL_match(obj->data.crl, x->data.crl))
                return obj;
        } else
            return obj;
    }
    return NULL;
}
['X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,\n                                        X509_OBJECT *x)\n{\n    int idx, i;\n    X509_OBJECT *obj;\n    idx = sk_X509_OBJECT_find(h, x);\n    if (idx == -1)\n        return NULL;\n    if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))\n        return sk_X509_OBJECT_value(h, idx);\n    for (i = idx; i < sk_X509_OBJECT_num(h); i++) {\n        obj = sk_X509_OBJECT_value(h, i);\n        if (x509_object_cmp\n            ((const X509_OBJECT **)&obj, (const X509_OBJECT **)&x))\n            return NULL;\n        if (x->type == X509_LU_X509) {\n            if (!X509_cmp(obj->data.x509, x->data.x509))\n                return obj;\n        } else if (x->type == X509_LU_CRL) {\n            if (!X509_CRL_match(obj->data.crl, x->data.crl))\n                return obj;\n        } else\n            return obj;\n    }\n    return NULL;\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 *r;\n    int i;\n    if (st == NULL || st->num == 0)\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    if (!st->sorted) {\n        if (st->num > 1)\n            qsort(st->data, st->num, sizeof(void *), st->comp);\n        st->sorted = 1;\n    }\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    return r == NULL ? -1 : (int)((const void **)r - st->data);\n}', 'int OPENSSL_sk_num(const OPENSSL_STACK *st)\n{\n    return st == NULL ? -1 : 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 (void *)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    case X509_LU_NONE:\n        return 0;\n    }\n    return ret;\n}']