static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group,\n                                             EC_POINT *point,\n                                             const BIGNUM *x_, int y_bit,\n                                             BN_CTX *ctx)\n{\n    BN_CTX *new_ctx = NULL;\n    BIGNUM *tmp1, *tmp2, *x, *y;\n    int ret = 0;\n    ERR_clear_error();\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            return 0;\n    }\n    y_bit = (y_bit != 0);\n    BN_CTX_start(ctx);\n    tmp1 = BN_CTX_get(ctx);\n    tmp2 = BN_CTX_get(ctx);\n    x = BN_CTX_get(ctx);\n    y = BN_CTX_get(ctx);\n    if (y == NULL)\n        goto err;\n    if (!BN_nnmod(x, x_, group->field, ctx))\n        goto err;\n    if (group->meth->field_decode == 0) {\n        if (!group->meth->field_sqr(group, tmp2, x_, ctx))\n            goto err;\n        if (!group->meth->field_mul(group, tmp1, tmp2, x_, ctx))\n            goto err;\n    } else {\n        if (!BN_mod_sqr(tmp2, x_, group->field, ctx))\n            goto err;\n        if (!BN_mod_mul(tmp1, tmp2, x_, group->field, ctx))\n            goto err;\n    }\n    if (group->a_is_minus3) {\n        if (!BN_mod_lshift1_quick(tmp2, x, group->field))\n            goto err;\n        if (!BN_mod_add_quick(tmp2, tmp2, x, group->field))\n            goto err;\n        if (!BN_mod_sub_quick(tmp1, tmp1, tmp2, group->field))\n            goto err;\n    } else {\n        if (group->meth->field_decode) {\n            if (!group->meth->field_decode(group, tmp2, group->a, ctx))\n                goto err;\n            if (!BN_mod_mul(tmp2, tmp2, x, group->field, ctx))\n                goto err;\n        } else {\n            if (!group->meth->field_mul(group, tmp2, group->a, x, ctx))\n                goto err;\n        }\n        if (!BN_mod_add_quick(tmp1, tmp1, tmp2, group->field))\n            goto err;\n    }\n    if (group->meth->field_decode) {\n        if (!group->meth->field_decode(group, tmp2, group->b, ctx))\n            goto err;\n        if (!BN_mod_add_quick(tmp1, tmp1, tmp2, group->field))\n            goto err;\n    } else {\n        if (!BN_mod_add_quick(tmp1, tmp1, group->b, group->field))\n            goto err;\n    }\n    if (!BN_mod_sqrt(y, tmp1, group->field, ctx)) {\n        unsigned long err = ERR_peek_last_error();\n        if (ERR_GET_LIB(err) == ERR_LIB_BN\n            && ERR_GET_REASON(err) == BN_R_NOT_A_SQUARE) {\n            ERR_clear_error();\n            ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES,\n                  EC_R_INVALID_COMPRESSED_POINT);\n        } else\n            ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES,\n                  ERR_R_BN_LIB);\n        goto err;\n    }\n    if (y_bit != BN_is_odd(y)) {\n        if (BN_is_zero(y)) {\n            int kron;\n            kron = BN_kronecker(x, group->field, ctx);\n            if (kron == -2)\n                goto err;\n            if (kron == 1)\n                ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES,\n                      EC_R_INVALID_COMPRESSION_BIT);\n            else\n                ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES,\n                      EC_R_INVALID_COMPRESSED_POINT);\n            goto err;\n        }\n        if (!BN_usub(y, group->field, y))\n            goto err;\n    }\n    if (y_bit != BN_is_odd(y)) {\n        ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES,\n              ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n    if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx))\n        goto err;\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\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}', 'int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx)\n{\n    BIGNUM *t;\n    int ret = 0;\n    bn_check_top(a);\n    bn_check_top(b);\n    bn_check_top(m);\n    BN_CTX_start(ctx);\n    if ((t = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    if (a == b) {\n        if (!BN_sqr(t, a, ctx))\n            goto err;\n    } else {\n        if (!BN_mul(t, a, b, ctx))\n            goto err;\n    }\n    if (!BN_nnmod(r, t, m, ctx))\n        goto err;\n    bn_check_top(r);\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    return ret;\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}']