int X509_check_trust(X509 *x, int id, int flags)
{
    X509_TRUST *pt;
    int idx;
    if (id == 0) {
        int rv;
        rv = obj_trust(NID_anyExtendedKeyUsage, x, 0);
        if (rv != X509_TRUST_UNTRUSTED)
            return rv;
        return trust_compat(NULL, x, 0);
    }
    idx = X509_TRUST_get_by_id(id);
    if (idx == -1)
        return default_trust(id, x, flags);
    pt = X509_TRUST_get0(idx);
    return pt->check_trust(pt, x, flags);
}
['int X509_check_trust(X509 *x, int id, int flags)\n{\n    X509_TRUST *pt;\n    int idx;\n    if (id == 0) {\n        int rv;\n        rv = obj_trust(NID_anyExtendedKeyUsage, x, 0);\n        if (rv != X509_TRUST_UNTRUSTED)\n            return rv;\n        return trust_compat(NULL, x, 0);\n    }\n    idx = X509_TRUST_get_by_id(id);\n    if (idx == -1)\n        return default_trust(id, x, flags);\n    pt = X509_TRUST_get0(idx);\n    return pt->check_trust(pt, x, flags);\n}', 'int X509_TRUST_get_by_id(int id)\n{\n    X509_TRUST tmp;\n    int idx;\n    if ((id >= X509_TRUST_MIN) && (id <= X509_TRUST_MAX))\n        return id - X509_TRUST_MIN;\n    tmp.trust = id;\n    if (!trtable)\n        return -1;\n    idx = sk_X509_TRUST_find(trtable, &tmp);\n    if (idx == -1)\n        return -1;\n    return idx + X509_TRUST_COUNT;\n}', 'int sk_find(_STACK *st, void *data)\n{\n    return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);\n}', 'static int internal_find(_STACK *st, void *data, 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    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}', 'X509_TRUST *X509_TRUST_get0(int idx)\n{\n    if (idx < 0)\n        return NULL;\n    if (idx < (int)X509_TRUST_COUNT)\n        return trstandard + idx;\n    return sk_X509_TRUST_value(trtable, idx - X509_TRUST_COUNT);\n}', 'void *sk_value(const _STACK *st, int i)\n{\n    if (!st || (i < 0) || (i >= st->num))\n        return NULL;\n    return st->data[i];\n}']