static unsigned int BN_STACK_pop(BN_STACK *st)
	{
	return st->indexes[--(st->depth)];
	}
['int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a_, const int p[], BN_CTX *ctx)\n\t{\n\tint ret = 0, count = 0, j;\n\tBIGNUM *a, *z, *rho, *w, *w2, *tmp;\n\tbn_check_top(a_);\n\tif (!p[0])\n\t\t{\n\t\tBN_zero(r);\n\t\treturn 1;\n\t\t}\n\tBN_CTX_start(ctx);\n\ta = BN_CTX_get(ctx);\n\tz = BN_CTX_get(ctx);\n\tw = BN_CTX_get(ctx);\n\tif (w == NULL) goto err;\n\tif (!BN_GF2m_mod_arr(a, a_, p)) goto err;\n\tif (BN_is_zero(a))\n\t\t{\n\t\tBN_zero(r);\n\t\tret = 1;\n\t\tgoto err;\n\t\t}\n\tif (p[0] & 0x1)\n\t\t{\n\t\tif (!BN_copy(z, a)) goto err;\n\t\tfor (j = 1; j <= (p[0] - 1) / 2; j++)\n\t\t\t{\n\t\t\tif (!BN_GF2m_mod_sqr_arr(z, z, p, ctx)) goto err;\n\t\t\tif (!BN_GF2m_mod_sqr_arr(z, z, p, ctx)) goto err;\n\t\t\tif (!BN_GF2m_add(z, z, a)) goto err;\n\t\t\t}\n\t\t}\n\telse\n\t\t{\n\t\trho = BN_CTX_get(ctx);\n\t\tw2 = BN_CTX_get(ctx);\n\t\ttmp = BN_CTX_get(ctx);\n\t\tif (tmp == NULL) goto err;\n\t\tdo\n\t\t\t{\n\t\t\tif (!BN_rand(rho, p[0], 0, 0)) goto err;\n\t\t\tif (!BN_GF2m_mod_arr(rho, rho, p)) goto err;\n\t\t\tBN_zero(z);\n\t\t\tif (!BN_copy(w, rho)) goto err;\n\t\t\tfor (j = 1; j <= p[0] - 1; j++)\n\t\t\t\t{\n\t\t\t\tif (!BN_GF2m_mod_sqr_arr(z, z, p, ctx)) goto err;\n\t\t\t\tif (!BN_GF2m_mod_sqr_arr(w2, w, p, ctx)) goto err;\n\t\t\t\tif (!BN_GF2m_mod_mul_arr(tmp, w2, a, p, ctx)) goto err;\n\t\t\t\tif (!BN_GF2m_add(z, z, tmp)) goto err;\n\t\t\t\tif (!BN_GF2m_add(w, w2, rho)) goto err;\n\t\t\t\t}\n\t\t\tcount++;\n\t\t\t} while (BN_is_zero(w) && (count < MAX_ITERATIONS));\n\t\tif (BN_is_zero(w))\n\t\t\t{\n\t\t\tBNerr(BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR,BN_R_TOO_MANY_ITERATIONS);\n\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\tif (!BN_GF2m_mod_sqr_arr(w, z, p, ctx)) goto err;\n\tif (!BN_GF2m_add(w, z, w)) goto err;\n\tif (BN_GF2m_cmp(w, a))\n\t\t{\n\t\tBNerr(BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR, BN_R_NO_SOLUTION);\n\t\tgoto err;\n\t\t}\n\tif (!BN_copy(r, z)) goto err;\n\tbn_check_top(r);\n\tret = 1;\nerr:\n\tBN_CTX_end(ctx);\n\treturn ret;\n\t}', 'void BN_CTX_start(BN_CTX *ctx)\n\t{\n\tCTXDBG_ENTRY("BN_CTX_start", ctx);\n\tif(ctx->err_stack || ctx->too_many)\n\t\tctx->err_stack++;\n\telse if(!BN_STACK_push(&ctx->stack, ctx->used))\n\t\t{\n\t\tBNerr(BN_F_BN_CTX_START,BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n\t\tctx->err_stack++;\n\t\t}\n\tCTXDBG_EXIT(ctx);\n\t}', 'int\tBN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], BN_CTX *ctx)\n\t{\n\tint i, ret = 0;\n\tBIGNUM *s;\n\tbn_check_top(a);\n\tBN_CTX_start(ctx);\n\tif ((s = BN_CTX_get(ctx)) == NULL) return 0;\n\tif (!bn_wexpand(s, 2 * a->top)) goto err;\n\tfor (i = a->top - 1; i >= 0; i--)\n\t\t{\n\t\ts->d[2*i+1] = SQR1(a->d[i]);\n\t\ts->d[2*i  ] = SQR0(a->d[i]);\n\t\t}\n\ts->top = 2 * a->top;\n\tbn_correct_top(s);\n\tif (!BN_GF2m_mod_arr(r, s, p)) goto err;\n\tbn_check_top(r);\n\tret = 1;\nerr:\n\tBN_CTX_end(ctx);\n\treturn ret;\n\t}', 'void BN_CTX_end(BN_CTX *ctx)\n\t{\n\tCTXDBG_ENTRY("BN_CTX_end", ctx);\n\tif(ctx->err_stack)\n\t\tctx->err_stack--;\n\telse\n\t\t{\n\t\tunsigned int fp = BN_STACK_pop(&ctx->stack);\n\t\tif(fp < ctx->used)\n\t\t\tBN_POOL_release(&ctx->pool, ctx->used - fp);\n\t\tctx->used = fp;\n\t\tctx->too_many = 0;\n\t\t}\n\tCTXDBG_EXIT(ctx);\n\t}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n\t{\n\treturn st->indexes[--(st->depth)];\n\t}']