static int tag_tree_decode(Jpeg2000DecoderContext *s, Jpeg2000TgtNode *node,
                           int threshold)
{
    Jpeg2000TgtNode *stack[30];
    int sp = -1, curval = 0;
    while (node && !node->vis) {
        stack[++sp] = node;
        node        = node->parent;
    }
    if (node)
        curval = node->val;
    else
        curval = stack[sp]->val;
    while (curval < threshold && sp >= 0) {
        if (curval < stack[sp]->val)
            curval = stack[sp]->val;
        while (curval < threshold) {
            int ret;
            if ((ret = get_bits(s, 1)) > 0) {
                stack[sp]->vis++;
                break;
            } else if (!ret)
                curval++;
            else
                return ret;
        }
        stack[sp]->val = curval;
        sp--;
    }
    return curval;
}
static int tag_tree_decode(Jpeg2000DecoderContext *s, Jpeg2000TgtNode *node,
                           int threshold)
{
    Jpeg2000TgtNode *stack[30];
    int sp = -1, curval = 0;
    while (node && !node->vis) {
        stack[++sp] = node;
        node        = node->parent;
    }
    if (node)
        curval = node->val;
    else
        curval = stack[sp]->val;
    while (curval < threshold && sp >= 0) {
        if (curval < stack[sp]->val)
            curval = stack[sp]->val;
        while (curval < threshold) {
            int ret;
            if ((ret = get_bits(s, 1)) > 0) {
                stack[sp]->vis++;
                break;
            } else if (!ret)
                curval++;
            else
                return ret;
        }
        stack[sp]->val = curval;
        sp--;
    }
    return curval;
}
static int FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000TgtNode *VAR_1,
                           int VAR_2)
{
    Jpeg2000TgtNode *stack[30];
    int VAR_3 = -1, VAR_4 = 0;
    while (VAR_1 && !VAR_1->vis) {
        stack[++VAR_3] = VAR_1;
        VAR_1        = VAR_1->parent;
    }
    if (VAR_1)
        VAR_4 = VAR_1->val;
    else
        VAR_4 = stack[VAR_3]->val;
    while (VAR_4 < VAR_2 && VAR_3 >= 0) {
        if (VAR_4 < stack[VAR_3]->val)
            VAR_4 = stack[VAR_3]->val;
        while (VAR_4 < VAR_2) {
            int VAR_5;
            if ((VAR_5 = get_bits(VAR_0, 1)) > 0) {
                stack[VAR_3]->vis++;
                break;
            } else if (!VAR_5)
                VAR_4++;
            else
                return VAR_5;
        }
        stack[VAR_3]->val = VAR_4;
        VAR_3--;
    }
    return VAR_4;
}
static int FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000TgtNode *VAR_1,
int VAR_2)
{ Jpeg2000TgtNode *stack[30]; int VAR_3 = -1, VAR_4 = 0; while (VAR_1 && !VAR_1->vis) { stack[++VAR_3] = VAR_1; VAR_1        = VAR_1->parent; } if (VAR_1)
VAR_4 = VAR_1->val; else
VAR_4 = stack[VAR_3]->val; while (VAR_4 < VAR_2 && VAR_3 >= 0) { if (VAR_4 < stack[VAR_3]->val)
VAR_4 = stack[VAR_3]->val; while (VAR_4 < VAR_2) { int VAR_5; if ((VAR_5 = get_bits(VAR_0, 1)) > 0) { stack[VAR_3]->vis++; break; } else if (!VAR_5) VAR_4++; else
return VAR_5; } stack[VAR_3]->val = VAR_4; VAR_3--; } return VAR_4; }