static bool liveness_pass_2(TCGContext *s)

{

    int nb_globals = s->nb_globals;

    int nb_temps, i, oi, oi_next;

    bool changes = false;



    /* Create a temporary for each indirect global.  */

    for (i = 0; i < nb_globals; ++i) {

        TCGTemp *its = &s->temps[i];

        if (its->indirect_reg) {

            TCGTemp *dts = tcg_temp_alloc(s);

            dts->type = its->type;

            dts->base_type = its->base_type;

            its->state_ptr = dts;

        } else {

            its->state_ptr = NULL;

        }

        /* All globals begin dead.  */

        its->state = TS_DEAD;

    }

    for (nb_temps = s->nb_temps; i < nb_temps; ++i) {

        TCGTemp *its = &s->temps[i];

        its->state_ptr = NULL;

        its->state = TS_DEAD;

    }



    for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) {

        TCGOp *op = &s->gen_op_buf[oi];

        TCGOpcode opc = op->opc;

        const TCGOpDef *def = &tcg_op_defs[opc];

        TCGLifeData arg_life = op->life;

        int nb_iargs, nb_oargs, call_flags;

        TCGTemp *arg_ts, *dir_ts;



        oi_next = op->next;



        if (opc == INDEX_op_call) {

            nb_oargs = op->callo;

            nb_iargs = op->calli;

            call_flags = op->args[nb_oargs + nb_iargs + 1];

        } else {

            nb_iargs = def->nb_iargs;

            nb_oargs = def->nb_oargs;



            /* Set flags similar to how calls require.  */

            if (def->flags & TCG_OPF_BB_END) {

                /* Like writing globals: save_globals */

                call_flags = 0;

            } else if (def->flags & TCG_OPF_SIDE_EFFECTS) {

                /* Like reading globals: sync_globals */

                call_flags = TCG_CALL_NO_WRITE_GLOBALS;

            } else {

                /* No effect on globals.  */

                call_flags = (TCG_CALL_NO_READ_GLOBALS |

                              TCG_CALL_NO_WRITE_GLOBALS);

            }

        }



        /* Make sure that input arguments are available.  */

        for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) {

            arg_ts = arg_temp(op->args[i]);

            if (arg_ts) {

                dir_ts = arg_ts->state_ptr;

                if (dir_ts && arg_ts->state == TS_DEAD) {

                    TCGOpcode lopc = (arg_ts->type == TCG_TYPE_I32

                                      ? INDEX_op_ld_i32

                                      : INDEX_op_ld_i64);

                    TCGOp *lop = tcg_op_insert_before(s, op, lopc, 3);



                    lop->args[0] = temp_arg(dir_ts);

                    lop->args[1] = temp_arg(arg_ts->mem_base);

                    lop->args[2] = arg_ts->mem_offset;



                    /* Loaded, but synced with memory.  */

                    arg_ts->state = TS_MEM;

                }

            }

        }



        /* Perform input replacement, and mark inputs that became dead.

           No action is required except keeping temp_state up to date

           so that we reload when needed.  */

        for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) {

            arg_ts = arg_temp(op->args[i]);

            if (arg_ts) {

                dir_ts = arg_ts->state_ptr;

                if (dir_ts) {

                    op->args[i] = temp_arg(dir_ts);

                    changes = true;

                    if (IS_DEAD_ARG(i)) {

                        arg_ts->state = TS_DEAD;

                    }

                }

            }

        }



        /* Liveness analysis should ensure that the following are

           all correct, for call sites and basic block end points.  */

        if (call_flags & TCG_CALL_NO_READ_GLOBALS) {

            /* Nothing to do */

        } else if (call_flags & TCG_CALL_NO_WRITE_GLOBALS) {

            for (i = 0; i < nb_globals; ++i) {

                /* Liveness should see that globals are synced back,

                   that is, either TS_DEAD or TS_MEM.  */

                arg_ts = &s->temps[i];

                tcg_debug_assert(arg_ts->state_ptr == 0

                                 || arg_ts->state != 0);

            }

        } else {

            for (i = 0; i < nb_globals; ++i) {

                /* Liveness should see that globals are saved back,

                   that is, TS_DEAD, waiting to be reloaded.  */

                arg_ts = &s->temps[i];

                tcg_debug_assert(arg_ts->state_ptr == 0

                                 || arg_ts->state == TS_DEAD);

            }

        }



        /* Outputs become available.  */

        for (i = 0; i < nb_oargs; i++) {

            arg_ts = arg_temp(op->args[i]);

            dir_ts = arg_ts->state_ptr;

            if (!dir_ts) {

                continue;

            }

            op->args[i] = temp_arg(dir_ts);

            changes = true;



            /* The output is now live and modified.  */

            arg_ts->state = 0;



            /* Sync outputs upon their last write.  */

            if (NEED_SYNC_ARG(i)) {

                TCGOpcode sopc = (arg_ts->type == TCG_TYPE_I32

                                  ? INDEX_op_st_i32

                                  : INDEX_op_st_i64);

                TCGOp *sop = tcg_op_insert_after(s, op, sopc, 3);



                sop->args[0] = temp_arg(dir_ts);

                sop->args[1] = temp_arg(arg_ts->mem_base);

                sop->args[2] = arg_ts->mem_offset;



                arg_ts->state = TS_MEM;

            }

            /* Drop outputs that are dead.  */

            if (IS_DEAD_ARG(i)) {

                arg_ts->state = TS_DEAD;

            }

        }

    }



    return changes;

}

static bool liveness_pass_2(TCGContext *s)

{

    int nb_globals = s->nb_globals;

    int nb_temps, i, oi, oi_next;

    bool changes = false;



    

    for (i = 0; i < nb_globals; ++i) {

        TCGTemp *its = &s->temps[i];

        if (its->indirect_reg) {

            TCGTemp *dts = tcg_temp_alloc(s);

            dts->type = its->type;

            dts->base_type = its->base_type;

            its->state_ptr = dts;

        } else {

            its->state_ptr = NULL;

        }

        

        its->state = TS_DEAD;

    }

    for (nb_temps = s->nb_temps; i < nb_temps; ++i) {

        TCGTemp *its = &s->temps[i];

        its->state_ptr = NULL;

        its->state = TS_DEAD;

    }



    for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) {

        TCGOp *op = &s->gen_op_buf[oi];

        TCGOpcode opc = op->opc;

        const TCGOpDef *def = &tcg_op_defs[opc];

        TCGLifeData arg_life = op->life;

        int nb_iargs, nb_oargs, call_flags;

        TCGTemp *arg_ts, *dir_ts;



        oi_next = op->next;



        if (opc == INDEX_op_call) {

            nb_oargs = op->callo;

            nb_iargs = op->calli;

            call_flags = op->args[nb_oargs + nb_iargs + 1];

        } else {

            nb_iargs = def->nb_iargs;

            nb_oargs = def->nb_oargs;



            

            if (def->flags & TCG_OPF_BB_END) {

                

                call_flags = 0;

            } else if (def->flags & TCG_OPF_SIDE_EFFECTS) {

                

                call_flags = TCG_CALL_NO_WRITE_GLOBALS;

            } else {

                

                call_flags = (TCG_CALL_NO_READ_GLOBALS |

                              TCG_CALL_NO_WRITE_GLOBALS);

            }

        }



        

        for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) {

            arg_ts = arg_temp(op->args[i]);

            if (arg_ts) {

                dir_ts = arg_ts->state_ptr;

                if (dir_ts && arg_ts->state == TS_DEAD) {

                    TCGOpcode lopc = (arg_ts->type == TCG_TYPE_I32

                                      ? INDEX_op_ld_i32

                                      : INDEX_op_ld_i64);

                    TCGOp *lop = tcg_op_insert_before(s, op, lopc, 3);



                    lop->args[0] = temp_arg(dir_ts);

                    lop->args[1] = temp_arg(arg_ts->mem_base);

                    lop->args[2] = arg_ts->mem_offset;



                    

                    arg_ts->state = TS_MEM;

                }

            }

        }



        





        for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) {

            arg_ts = arg_temp(op->args[i]);

            if (arg_ts) {

                dir_ts = arg_ts->state_ptr;

                if (dir_ts) {

                    op->args[i] = temp_arg(dir_ts);

                    changes = true;

                    if (IS_DEAD_ARG(i)) {

                        arg_ts->state = TS_DEAD;

                    }

                }

            }

        }



        



        if (call_flags & TCG_CALL_NO_READ_GLOBALS) {

            

        } else if (call_flags & TCG_CALL_NO_WRITE_GLOBALS) {

            for (i = 0; i < nb_globals; ++i) {

                



                arg_ts = &s->temps[i];

                tcg_debug_assert(arg_ts->state_ptr == 0

                                 || arg_ts->state != 0);

            }

        } else {

            for (i = 0; i < nb_globals; ++i) {

                



                arg_ts = &s->temps[i];

                tcg_debug_assert(arg_ts->state_ptr == 0

                                 || arg_ts->state == TS_DEAD);

            }

        }



        

        for (i = 0; i < nb_oargs; i++) {

            arg_ts = arg_temp(op->args[i]);

            dir_ts = arg_ts->state_ptr;

            if (!dir_ts) {

                continue;

            }

            op->args[i] = temp_arg(dir_ts);

            changes = true;



            

            arg_ts->state = 0;



            

            if (NEED_SYNC_ARG(i)) {

                TCGOpcode sopc = (arg_ts->type == TCG_TYPE_I32

                                  ? INDEX_op_st_i32

                                  : INDEX_op_st_i64);

                TCGOp *sop = tcg_op_insert_after(s, op, sopc, 3);



                sop->args[0] = temp_arg(dir_ts);

                sop->args[1] = temp_arg(arg_ts->mem_base);

                sop->args[2] = arg_ts->mem_offset;



                arg_ts->state = TS_MEM;

            }

            

            if (IS_DEAD_ARG(i)) {

                arg_ts->state = TS_DEAD;

            }

        }

    }



    return changes;

}

    for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) {         oi_next = op->next;     int nb_temps, i, oi, oi_next;     for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) {         TCGOp *op = &s->gen_op_buf[oi];         oi_next = op->next;     for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) {         oi_next = op->next;
static bool FUNC_0(TCGContext *s)

{

    int VAR_0 = s->VAR_0;

    int VAR_1, VAR_2, VAR_3, VAR_4;

    bool changes = false;



    

    for (VAR_2 = 0; VAR_2 < VAR_0; ++VAR_2) {

        TCGTemp *its = &s->temps[VAR_2];

        if (its->indirect_reg) {

            TCGTemp *dts = tcg_temp_alloc(s);

            dts->type = its->type;

            dts->base_type = its->base_type;

            its->state_ptr = dts;

        } else {

            its->state_ptr = NULL;

        }

        

        its->state = TS_DEAD;

    }

    for (VAR_1 = s->VAR_1; VAR_2 < VAR_1; ++VAR_2) {

        TCGTemp *its = &s->temps[VAR_2];

        its->state_ptr = NULL;

        its->state = TS_DEAD;

    }



    for (VAR_3 = s->gen_op_buf[0].next; VAR_3 != 0; VAR_3 = VAR_4) {

        TCGOp *op = &s->gen_op_buf[VAR_3];

        TCGOpcode opc = op->opc;

        const TCGOpDef *VAR_5 = &tcg_op_defs[opc];

        TCGLifeData arg_life = op->life;

        int VAR_6, VAR_7, VAR_8;

        TCGTemp *arg_ts, *dir_ts;



        VAR_4 = op->next;



        if (opc == INDEX_op_call) {

            VAR_7 = op->callo;

            VAR_6 = op->calli;

            VAR_8 = op->args[VAR_7 + VAR_6 + 1];

        } else {

            VAR_6 = VAR_5->VAR_6;

            VAR_7 = VAR_5->VAR_7;



            

            if (VAR_5->flags & TCG_OPF_BB_END) {

                

                VAR_8 = 0;

            } else if (VAR_5->flags & TCG_OPF_SIDE_EFFECTS) {

                

                VAR_8 = TCG_CALL_NO_WRITE_GLOBALS;

            } else {

                

                VAR_8 = (TCG_CALL_NO_READ_GLOBALS |

                              TCG_CALL_NO_WRITE_GLOBALS);

            }

        }



        

        for (VAR_2 = VAR_7; VAR_2 < VAR_6 + VAR_7; VAR_2++) {

            arg_ts = arg_temp(op->args[VAR_2]);

            if (arg_ts) {

                dir_ts = arg_ts->state_ptr;

                if (dir_ts && arg_ts->state == TS_DEAD) {

                    TCGOpcode lopc = (arg_ts->type == TCG_TYPE_I32

                                      ? INDEX_op_ld_i32

                                      : INDEX_op_ld_i64);

                    TCGOp *lop = tcg_op_insert_before(s, op, lopc, 3);



                    lop->args[0] = temp_arg(dir_ts);

                    lop->args[1] = temp_arg(arg_ts->mem_base);

                    lop->args[2] = arg_ts->mem_offset;



                    

                    arg_ts->state = TS_MEM;

                }

            }

        }



        





        for (VAR_2 = VAR_7; VAR_2 < VAR_6 + VAR_7; VAR_2++) {

            arg_ts = arg_temp(op->args[VAR_2]);

            if (arg_ts) {

                dir_ts = arg_ts->state_ptr;

                if (dir_ts) {

                    op->args[VAR_2] = temp_arg(dir_ts);

                    changes = true;

                    if (IS_DEAD_ARG(VAR_2)) {

                        arg_ts->state = TS_DEAD;

                    }

                }

            }

        }



        



        if (VAR_8 & TCG_CALL_NO_READ_GLOBALS) {

            

        } else if (VAR_8 & TCG_CALL_NO_WRITE_GLOBALS) {

            for (VAR_2 = 0; VAR_2 < VAR_0; ++VAR_2) {

                



                arg_ts = &s->temps[VAR_2];

                tcg_debug_assert(arg_ts->state_ptr == 0

                                 || arg_ts->state != 0);

            }

        } else {

            for (VAR_2 = 0; VAR_2 < VAR_0; ++VAR_2) {

                



                arg_ts = &s->temps[VAR_2];

                tcg_debug_assert(arg_ts->state_ptr == 0

                                 || arg_ts->state == TS_DEAD);

            }

        }



        

        for (VAR_2 = 0; VAR_2 < VAR_7; VAR_2++) {

            arg_ts = arg_temp(op->args[VAR_2]);

            dir_ts = arg_ts->state_ptr;

            if (!dir_ts) {

                continue;

            }

            op->args[VAR_2] = temp_arg(dir_ts);

            changes = true;



            

            arg_ts->state = 0;



            

            if (NEED_SYNC_ARG(VAR_2)) {

                TCGOpcode sopc = (arg_ts->type == TCG_TYPE_I32

                                  ? INDEX_op_st_i32

                                  : INDEX_op_st_i64);

                TCGOp *sop = tcg_op_insert_after(s, op, sopc, 3);



                sop->args[0] = temp_arg(dir_ts);

                sop->args[1] = temp_arg(arg_ts->mem_base);

                sop->args[2] = arg_ts->mem_offset;



                arg_ts->state = TS_MEM;

            }

            

            if (IS_DEAD_ARG(VAR_2)) {

                arg_ts->state = TS_DEAD;

            }

        }

    }



    return changes;

}

static bool FUNC_0(TCGContext *s)
{ int VAR_0 = s->VAR_0; int VAR_1, VAR_2, VAR_3, VAR_4; bool changes = false; for (VAR_2 = 0; VAR_2 < VAR_0; ++VAR_2) { TCGTemp *its = &s->temps[VAR_2]; if (its->indirect_reg) { TCGTemp *dts = tcg_temp_alloc(s); dts->type = its->type; dts->base_type = its->base_type; its->state_ptr = dts; } else { its->state_ptr = NULL; } its->state = TS_DEAD; } for (VAR_1 = s->VAR_1; VAR_2 < VAR_1; ++VAR_2) { TCGTemp *its = &s->temps[VAR_2]; its->state_ptr = NULL; its->state = TS_DEAD; } for (VAR_3 = s->gen_op_buf[0].next; VAR_3 != 0; VAR_3 = VAR_4) { TCGOp *op = &s->gen_op_buf[VAR_3]; TCGOpcode opc = op->opc; const TCGOpDef *VAR_5 = &tcg_op_defs[opc]; TCGLifeData arg_life = op->life; int VAR_6, VAR_7, VAR_8; TCGTemp *arg_ts, *dir_ts; VAR_4 = op->next; if (opc == INDEX_op_call) { VAR_7 = op->callo; VAR_6 = op->calli; VAR_8 = op->args[VAR_7 + VAR_6 + 1]; } else { VAR_6 = VAR_5->VAR_6; VAR_7 = VAR_5->VAR_7; if (VAR_5->flags & TCG_OPF_BB_END) { VAR_8 = 0; } else if (VAR_5->flags & TCG_OPF_SIDE_EFFECTS) { VAR_8 = TCG_CALL_NO_WRITE_GLOBALS; } else { VAR_8 = (TCG_CALL_NO_READ_GLOBALS |
TCG_CALL_NO_WRITE_GLOBALS); } } for (VAR_2 = VAR_7; VAR_2 < VAR_6 + VAR_7; VAR_2++) { arg_ts = arg_temp(op->args[VAR_2]); if (arg_ts) { dir_ts = arg_ts->state_ptr; if (dir_ts && arg_ts->state == TS_DEAD) { TCGOpcode lopc = (arg_ts->type == TCG_TYPE_I32
? INDEX_op_ld_i32
: INDEX_op_ld_i64); TCGOp *lop = tcg_op_insert_before(s, op, lopc, 3); lop->args[0] = temp_arg(dir_ts); lop->args[1] = temp_arg(arg_ts->mem_base); lop->args[2] = arg_ts->mem_offset; arg_ts->state = TS_MEM; } } } for (VAR_2 = VAR_7; VAR_2 < VAR_6 + VAR_7; VAR_2++) { arg_ts = arg_temp(op->args[VAR_2]); if (arg_ts) { dir_ts = arg_ts->state_ptr; if (dir_ts) { op->args[VAR_2] = temp_arg(dir_ts); changes = true; if (IS_DEAD_ARG(VAR_2)) { arg_ts->state = TS_DEAD; } } } } if (VAR_8 & TCG_CALL_NO_READ_GLOBALS) { } else if (VAR_8 & TCG_CALL_NO_WRITE_GLOBALS) { for (VAR_2 = 0; VAR_2 < VAR_0; ++VAR_2) { arg_ts = &s->temps[VAR_2]; tcg_debug_assert(arg_ts->state_ptr == 0
|| arg_ts->state != 0); } } else { for (VAR_2 = 0; VAR_2 < VAR_0; ++VAR_2) { arg_ts = &s->temps[VAR_2]; tcg_debug_assert(arg_ts->state_ptr == 0
|| arg_ts->state == TS_DEAD); } } for (VAR_2 = 0; VAR_2 < VAR_7; VAR_2++) { arg_ts = arg_temp(op->args[VAR_2]); dir_ts = arg_ts->state_ptr; if (!dir_ts) { continue; } op->args[VAR_2] = temp_arg(dir_ts); changes = true; arg_ts->state = 0; if (NEED_SYNC_ARG(VAR_2)) { TCGOpcode sopc = (arg_ts->type == TCG_TYPE_I32
? INDEX_op_st_i32
: INDEX_op_st_i64); TCGOp *sop = tcg_op_insert_after(s, op, sopc, 3); sop->args[0] = temp_arg(dir_ts); sop->args[1] = temp_arg(arg_ts->mem_base); sop->args[2] = arg_ts->mem_offset; arg_ts->state = TS_MEM; } if (IS_DEAD_ARG(VAR_2)) { arg_ts->state = TS_DEAD; } } } return changes; }