static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['int ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num,\n                                     EC_POINT *points[], BN_CTX *ctx)\n{\n    BN_CTX *new_ctx = NULL;\n    BIGNUM *tmp, *tmp_Z;\n    BIGNUM **prod_Z = NULL;\n    size_t i;\n    int ret = 0;\n    if (num == 0)\n        return 1;\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            return 0;\n    }\n    BN_CTX_start(ctx);\n    tmp = BN_CTX_get(ctx);\n    tmp_Z = BN_CTX_get(ctx);\n    if (tmp_Z == NULL)\n        goto err;\n    prod_Z = OPENSSL_malloc(num * sizeof(prod_Z[0]));\n    if (prod_Z == NULL)\n        goto err;\n    for (i = 0; i < num; i++) {\n        prod_Z[i] = BN_new();\n        if (prod_Z[i] == NULL)\n            goto err;\n    }\n    if (!BN_is_zero(points[0]->Z)) {\n        if (!BN_copy(prod_Z[0], points[0]->Z))\n            goto err;\n    } else {\n        if (group->meth->field_set_to_one != 0) {\n            if (!group->meth->field_set_to_one(group, prod_Z[0], ctx))\n                goto err;\n        } else {\n            if (!BN_one(prod_Z[0]))\n                goto err;\n        }\n    }\n    for (i = 1; i < num; i++) {\n        if (!BN_is_zero(points[i]->Z)) {\n            if (!group->\n                meth->field_mul(group, prod_Z[i], prod_Z[i - 1], points[i]->Z,\n                                ctx))\n                goto err;\n        } else {\n            if (!BN_copy(prod_Z[i], prod_Z[i - 1]))\n                goto err;\n        }\n    }\n    if (!group->meth->field_inv(group, tmp, prod_Z[num - 1], ctx)) {\n        ECerr(EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE, ERR_R_BN_LIB);\n        goto err;\n    }\n    if (group->meth->field_encode != 0) {\n        if (!group->meth->field_encode(group, tmp, tmp, ctx))\n            goto err;\n        if (!group->meth->field_encode(group, tmp, tmp, ctx))\n            goto err;\n    }\n    for (i = num - 1; i > 0; --i) {\n        if (!BN_is_zero(points[i]->Z)) {\n            if (!group->\n                meth->field_mul(group, tmp_Z, prod_Z[i - 1], tmp, ctx))\n                goto err;\n            if (!group->meth->field_mul(group, tmp, tmp, points[i]->Z, ctx))\n                goto err;\n            if (!BN_copy(points[i]->Z, tmp_Z))\n                goto err;\n        }\n    }\n    if (!BN_is_zero(points[0]->Z)) {\n        if (!BN_copy(points[0]->Z, tmp))\n            goto err;\n    }\n    for (i = 0; i < num; i++) {\n        EC_POINT *p = points[i];\n        if (!BN_is_zero(p->Z)) {\n            if (!group->meth->field_sqr(group, tmp, p->Z, ctx))\n                goto err;\n            if (!group->meth->field_mul(group, p->X, p->X, tmp, ctx))\n                goto err;\n            if (!group->meth->field_mul(group, tmp, tmp, p->Z, ctx))\n                goto err;\n            if (!group->meth->field_mul(group, p->Y, p->Y, tmp, ctx))\n                goto err;\n            if (group->meth->field_set_to_one != 0) {\n                if (!group->meth->field_set_to_one(group, p->Z, ctx))\n                    goto err;\n            } else {\n                if (!BN_one(p->Z))\n                    goto err;\n            }\n            p->Z_is_one = 1;\n        }\n    }\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    if (prod_Z != NULL) {\n        for (i = 0; i < num; i++) {\n            if (prod_Z[i] == NULL)\n                break;\n            BN_clear_free(prod_Z[i]);\n        }\n        OPENSSL_free(prod_Z);\n    }\n    return ret;\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}']