static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['int RSA_X931_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e,\n                             BN_GENCB *cb)\n{\n    int ok = 0;\n    BIGNUM *Xp = NULL, *Xq = NULL;\n    BN_CTX *ctx = NULL;\n    ctx = BN_CTX_new();\n    if (ctx == NULL)\n        goto error;\n    BN_CTX_start(ctx);\n    Xp = BN_CTX_get(ctx);\n    Xq = BN_CTX_get(ctx);\n    if (Xq == NULL)\n        goto error;\n    if (!BN_X931_generate_Xpq(Xp, Xq, bits, ctx))\n        goto error;\n    rsa->p = BN_new();\n    rsa->q = BN_new();\n    if (rsa->p == NULL || rsa->q == NULL)\n        goto error;\n    if (!BN_X931_generate_prime_ex(rsa->p, NULL, NULL, NULL, NULL, Xp,\n                                   e, ctx, cb))\n        goto error;\n    if (!BN_X931_generate_prime_ex(rsa->q, NULL, NULL, NULL, NULL, Xq,\n                                   e, ctx, cb))\n        goto error;\n    if (!RSA_X931_derive_ex(rsa, NULL, NULL, NULL, NULL,\n                            NULL, NULL, NULL, NULL, NULL, NULL, e, cb))\n        goto error;\n    ok = 1;\n error:\n    if (ctx)\n        BN_CTX_end(ctx);\n    BN_CTX_free(ctx);\n    if (ok)\n        return 1;\n    return 0;\n}', 'void BN_CTX_start(BN_CTX *ctx)\n{\n    CTXDBG_ENTRY("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_EXIT(ctx);\n}', 'int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx)\n{\n    BIGNUM *t;\n    int i;\n    if ((nbits < 1024) || (nbits & 0xff))\n        return 0;\n    nbits >>= 1;\n    if (!BN_rand(Xp, nbits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ANY))\n        goto err;\n    BN_CTX_start(ctx);\n    t = BN_CTX_get(ctx);\n    if (t == NULL)\n        goto err;\n    for (i = 0; i < 1000; i++) {\n        if (!BN_rand(Xq, nbits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ANY))\n            goto err;\n        BN_sub(t, Xp, Xq);\n        if (BN_num_bits(t) > (nbits - 100))\n            break;\n    }\n    BN_CTX_end(ctx);\n    if (i < 1000)\n        return 1;\n    return 0;\n err:\n    BN_CTX_end(ctx);\n    return 0;\n}', 'void BN_CTX_end(BN_CTX *ctx)\n{\n    CTXDBG_ENTRY("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_EXIT(ctx);\n}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']