static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret)\n{\n    int ok = 0;\n    BIGNUM *tmp = NULL;\n    BN_CTX *ctx = NULL;\n    *ret = 0;\n    ctx = BN_CTX_new();\n    if (ctx == NULL)\n        goto err;\n    BN_CTX_start(ctx);\n    tmp = BN_CTX_get(ctx);\n    if (tmp == NULL || !BN_set_word(tmp, 1))\n        goto err;\n    if (BN_cmp(pub_key, tmp) <= 0)\n        *ret |= DH_CHECK_PUBKEY_TOO_SMALL;\n    if (BN_copy(tmp, dh->p) == NULL || !BN_sub_word(tmp, 1))\n        goto err;\n    if (BN_cmp(pub_key, tmp) >= 0)\n        *ret |= DH_CHECK_PUBKEY_TOO_LARGE;\n    if (dh->q != NULL) {\n        if (!BN_mod_exp(tmp, pub_key, dh->q, dh->p, ctx))\n            goto err;\n        if (!BN_is_one(tmp))\n            *ret |= DH_CHECK_PUBKEY_INVALID;\n    }\n    ok = 1;\n err:\n    if (ctx != NULL) {\n        BN_CTX_end(ctx);\n        BN_CTX_free(ctx);\n    }\n    return ok;\n}', 'void BN_CTX_start(BN_CTX *ctx)\n{\n    CTXDBG("ENTER BN_CTX_start()", ctx);\n    if (ctx->err_stack || ctx->too_many)\n        ctx->err_stack++;\n    else if (!BN_STACK_push(&ctx->stack, ctx->used)) {\n        BNerr(BN_F_BN_CTX_START, BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n        ctx->err_stack++;\n    }\n    CTXDBG("LEAVE BN_CTX_start()", ctx);\n}', 'void BN_CTX_end(BN_CTX *ctx)\n{\n    CTXDBG("ENTER BN_CTX_end()", ctx);\n    if (ctx->err_stack)\n        ctx->err_stack--;\n    else {\n        unsigned int fp = BN_STACK_pop(&ctx->stack);\n        if (fp < ctx->used)\n            BN_POOL_release(&ctx->pool, ctx->used - fp);\n        ctx->used = fp;\n        ctx->too_many = 0;\n    }\n    CTXDBG("LEAVE BN_CTX_end()", ctx);\n}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']