static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['static int file_square(STANZA *s)\n{\n    BIGNUM *a = getBN(s, "A");\n    BIGNUM *square = getBN(s, "Square");\n    BIGNUM *zero = BN_new();\n    BIGNUM *ret = BN_new();\n    BIGNUM *remainder = BN_new();\n    BIGNUM *tmp = NULL;\n    int st = 0;\n    if (a == NULL || square == NULL || zero == NULL || ret == NULL\n            || remainder == NULL)\n        goto err;\n    BN_zero(zero);\n    if (!BN_sqr(ret, a, ctx)\n            || !equalBN("A^2", square, ret)\n            || !BN_mul(ret, a, a, ctx)\n            || !equalBN("A * A", square, ret)\n            || !BN_div(ret, remainder, square, a, ctx)\n            || !equalBN("Square / A", a, ret)\n            || !equalBN("Square % A", zero, remainder))\n        goto err;\n#if HAVE_BN_SQRT\n    BN_set_negative(a, 0);\n    if (!BN_sqrt(ret, square, ctx)\n            || !equalBN("sqrt(Square)", a, ret))\n        goto err;\n    if (!BN_is_zero(square)) {\n        tmp = BN_new();\n        if (tmp == NULL || !BN_copy(tmp, square))\n            goto err;\n        BN_set_negative(tmp, 1);\n        if (BN_sqrt(ret, tmp, ctx)) {\n            fprintf(stderr, "BN_sqrt succeeded on a negative number");\n            goto err;\n        }\n        ERR_clear_error();\n        BN_set_negative(tmp, 0);\n        if (BN_add(tmp, tmp, BN_value_one()))\n            goto err;\n        if (BN_sqrt(ret, tmp, ctx)) {\n            fprintf(stderr, "BN_sqrt succeeded on a non-square");\n            goto err;\n        }\n        ERR_clear_error();\n    }\n#endif\n    st = 1;\nerr:\n    BN_free(a);\n    BN_free(square);\n    BN_free(zero);\n    BN_free(ret);\n    BN_free(remainder);\n    BN_free(tmp);\n    return st;\n}', 'int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)\n{\n    int max, al;\n    int ret = 0;\n    BIGNUM *tmp, *rr;\n    bn_check_top(a);\n    al = a->top;\n    if (al <= 0) {\n        r->top = 0;\n        r->neg = 0;\n        return 1;\n    }\n    BN_CTX_start(ctx);\n    rr = (a != r) ? r : BN_CTX_get(ctx);\n    tmp = BN_CTX_get(ctx);\n    if (!rr || !tmp)\n        goto err;\n    max = 2 * al;\n    if (bn_wexpand(rr, max) == NULL)\n        goto err;\n    if (al == 4) {\n#ifndef BN_SQR_COMBA\n        BN_ULONG t[8];\n        bn_sqr_normal(rr->d, a->d, 4, t);\n#else\n        bn_sqr_comba4(rr->d, a->d);\n#endif\n    } else if (al == 8) {\n#ifndef BN_SQR_COMBA\n        BN_ULONG t[16];\n        bn_sqr_normal(rr->d, a->d, 8, t);\n#else\n        bn_sqr_comba8(rr->d, a->d);\n#endif\n    } else {\n#if defined(BN_RECURSION)\n        if (al < BN_SQR_RECURSIVE_SIZE_NORMAL) {\n            BN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL * 2];\n            bn_sqr_normal(rr->d, a->d, al, t);\n        } else {\n            int j, k;\n            j = BN_num_bits_word((BN_ULONG)al);\n            j = 1 << (j - 1);\n            k = j + j;\n            if (al == j) {\n                if (bn_wexpand(tmp, k * 2) == NULL)\n                    goto err;\n                bn_sqr_recursive(rr->d, a->d, al, tmp->d);\n            } else {\n                if (bn_wexpand(tmp, max) == NULL)\n                    goto err;\n                bn_sqr_normal(rr->d, a->d, al, tmp->d);\n            }\n        }\n#else\n        if (bn_wexpand(tmp, max) == NULL)\n            goto err;\n        bn_sqr_normal(rr->d, a->d, al, tmp->d);\n#endif\n    }\n    rr->neg = 0;\n    if (a->d[al - 1] == (a->d[al - 1] & BN_MASK2l))\n        rr->top = max - 1;\n    else\n        rr->top = max;\n    if (r != rr && BN_copy(r, rr) == NULL)\n        goto err;\n    ret = 1;\n err:\n    bn_check_top(rr);\n    bn_check_top(tmp);\n    BN_CTX_end(ctx);\n    return (ret);\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}', '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}']