static unsigned int BN_STACK_pop(BN_STACK *st)
	{
	return st->indexes[--(st->depth)];
	}
['int test_sqr(BIO *bp, BN_CTX *ctx)\n\t{\n\tBIGNUM *a,*c,*d,*e;\n\tint i, ret = 0;\n\ta = BN_new();\n\tc = BN_new();\n\td = BN_new();\n\te = BN_new();\n\tif (a == NULL || c == NULL || d == NULL || e == NULL)\n\t\t{\n\t\tgoto err;\n\t\t}\n\tfor (i=0; i<num0; i++)\n\t\t{\n\t\tBN_bntest_rand(a,40+i*10,0,0);\n\t\ta->neg=rand_neg();\n\t\tBN_sqr(c,a,ctx);\n\t\tif (bp != NULL)\n\t\t\t{\n\t\t\tif (!results)\n\t\t\t\t{\n\t\t\t\tBN_print(bp,a);\n\t\t\t\tBIO_puts(bp," * ");\n\t\t\t\tBN_print(bp,a);\n\t\t\t\tBIO_puts(bp," - ");\n\t\t\t\t}\n\t\t\tBN_print(bp,c);\n\t\t\tBIO_puts(bp,"\\n");\n\t\t\t}\n\t\tBN_div(d,e,c,a,ctx);\n\t\tBN_sub(d,d,a);\n\t\tif(!BN_is_zero(d) || !BN_is_zero(e))\n\t\t\t{\n\t\t\tfprintf(stderr,"Square test failed!\\n");\n\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\tBN_hex2bn(&a,\n\t\t"80000000000000008000000000000001FFFFFFFFFFFFFFFE0000000000000000");\n\tBN_sqr(c, a, ctx);\n\tif (bp != NULL)\n\t\t{\n\t\tif (!results)\n\t\t\t{\n\t\t\tBN_print(bp,a);\n\t\t\tBIO_puts(bp," * ");\n\t\t\tBN_print(bp,a);\n\t\t\tBIO_puts(bp," - ");\n\t\t\t}\n\t\tBN_print(bp,c);\n\t\tBIO_puts(bp,"\\n");\n\t\t}\n\tBN_mul(d, a, a, ctx);\n\tif (BN_cmp(c, d))\n\t\t{\n\t\tfprintf(stderr, "Square test failed: BN_sqr and BN_mul produce "\n\t\t\t"different results!\\n");\n\t\tgoto err;\n\t\t}\n\tBN_hex2bn(&a,\n\t\t"80000000000000000000000080000001FFFFFFFE000000000000000000000000");\n\tBN_sqr(c, a, ctx);\n\tif (bp != NULL)\n\t\t{\n\t\tif (!results)\n\t\t\t{\n\t\t\tBN_print(bp,a);\n\t\t\tBIO_puts(bp," * ");\n\t\t\tBN_print(bp,a);\n\t\t\tBIO_puts(bp," - ");\n\t\t\t}\n\t\tBN_print(bp,c);\n\t\tBIO_puts(bp,"\\n");\n\t\t}\n\tBN_mul(d, a, a, ctx);\n\tif (BN_cmp(c, d))\n\t\t{\n\t\tfprintf(stderr, "Square test failed: BN_sqr and BN_mul produce "\n\t\t\t"different results!\\n");\n\t\tgoto err;\n\t\t}\n\tret = 1;\nerr:\n\tif (a != NULL) BN_free(a);\n\tif (c != NULL) BN_free(c);\n\tif (d != NULL) BN_free(d);\n\tif (e != NULL) BN_free(e);\n\treturn ret;\n\t}', 'int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)\n\t{\n\tint max,al;\n\tint ret = 0;\n\tBIGNUM *tmp,*rr;\n\tbn_check_top(a);\n\tal=a->top;\n\tif (al <= 0)\n\t\t{\n\t\tr->top=0;\n\t\tr->neg = 0;\n\t\treturn 1;\n\t\t}\n\tBN_CTX_start(ctx);\n\trr=(a != r) ? r : BN_CTX_get(ctx);\n\ttmp=BN_CTX_get(ctx);\n\tif (!rr || !tmp) goto err;\n\tmax = 2 * al;\n\tif (bn_wexpand(rr,max) == NULL) goto err;\n\tif (al == 4)\n\t\t{\n#ifndef BN_SQR_COMBA\n\t\tBN_ULONG t[8];\n\t\tbn_sqr_normal(rr->d,a->d,4,t);\n#else\n\t\tbn_sqr_comba4(rr->d,a->d);\n#endif\n\t\t}\n\telse if (al == 8)\n\t\t{\n#ifndef BN_SQR_COMBA\n\t\tBN_ULONG t[16];\n\t\tbn_sqr_normal(rr->d,a->d,8,t);\n#else\n\t\tbn_sqr_comba8(rr->d,a->d);\n#endif\n\t\t}\n\telse\n\t\t{\n#if defined(BN_RECURSION)\n\t\tif (al < BN_SQR_RECURSIVE_SIZE_NORMAL)\n\t\t\t{\n\t\t\tBN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL*2];\n\t\t\tbn_sqr_normal(rr->d,a->d,al,t);\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tint j,k;\n\t\t\tj=BN_num_bits_word((BN_ULONG)al);\n\t\t\tj=1<<(j-1);\n\t\t\tk=j+j;\n\t\t\tif (al == j)\n\t\t\t\t{\n\t\t\t\tif (bn_wexpand(tmp,k*2) == NULL) goto err;\n\t\t\t\tbn_sqr_recursive(rr->d,a->d,al,tmp->d);\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tif (bn_wexpand(tmp,max) == NULL) goto err;\n\t\t\t\tbn_sqr_normal(rr->d,a->d,al,tmp->d);\n\t\t\t\t}\n\t\t\t}\n#else\n\t\tif (bn_wexpand(tmp,max) == NULL) goto err;\n\t\tbn_sqr_normal(rr->d,a->d,al,tmp->d);\n#endif\n\t\t}\n\trr->neg=0;\n\tif(a->d[al - 1] == (a->d[al - 1] & BN_MASK2l))\n\t\trr->top = max - 1;\n\telse\n\t\trr->top = max;\n\tif (rr != r) BN_copy(r,rr);\n\tret = 1;\n err:\n\tbn_check_top(rr);\n\tbn_check_top(tmp);\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}', '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}']