static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,

                                     uintptr_t searched_pc)

{

    CPUArchState *env = cpu->env_ptr;

    TCGContext *s = &tcg_ctx;

    int j;

    uintptr_t tc_ptr;

#ifdef CONFIG_PROFILER

    int64_t ti;

#endif



#ifdef CONFIG_PROFILER

    ti = profile_getclock();

#endif

    tcg_func_start(s);



    gen_intermediate_code_pc(env, tb);



    if (use_icount) {

        /* Reset the cycle counter to the start of the block.  */

        cpu->icount_decr.u16.low += tb->icount;

        /* Clear the IO flag.  */

        cpu->can_do_io = 0;

    }



    /* find opc index corresponding to search_pc */

    tc_ptr = (uintptr_t)tb->tc_ptr;

    if (searched_pc < tc_ptr)

        return -1;



    s->tb_next_offset = tb->tb_next_offset;

#ifdef USE_DIRECT_JUMP

    s->tb_jmp_offset = tb->tb_jmp_offset;

    s->tb_next = NULL;

#else

    s->tb_jmp_offset = NULL;

    s->tb_next = tb->tb_next;

#endif

    j = tcg_gen_code_search_pc(s, (tcg_insn_unit *)tc_ptr,

                               searched_pc - tc_ptr);

    if (j < 0)

        return -1;

    /* now find start of instruction before */

    while (s->gen_opc_instr_start[j] == 0) {

        j--;

    }

    cpu->icount_decr.u16.low -= s->gen_opc_icount[j];



    restore_state_to_opc(env, tb, j);



#ifdef CONFIG_PROFILER

    s->restore_time += profile_getclock() - ti;

    s->restore_count++;

#endif

    return 0;

}

static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,

                                     uintptr_t searched_pc)

{

    CPUArchState *env = cpu->env_ptr;

    TCGContext *s = &tcg_ctx;

    int j;

    uintptr_t tc_ptr;

#ifdef CONFIG_PROFILER

    int64_t ti;

#endif



#ifdef CONFIG_PROFILER

    ti = profile_getclock();

#endif

    tcg_func_start(s);



    gen_intermediate_code_pc(env, tb);



    if (use_icount) {

        

        cpu->icount_decr.u16.low += tb->icount;

        

        cpu->can_do_io = 0;

    }



    

    tc_ptr = (uintptr_t)tb->tc_ptr;

    if (searched_pc < tc_ptr)

        return -1;



    s->tb_next_offset = tb->tb_next_offset;

#ifdef USE_DIRECT_JUMP

    s->tb_jmp_offset = tb->tb_jmp_offset;

    s->tb_next = NULL;

#else

    s->tb_jmp_offset = NULL;

    s->tb_next = tb->tb_next;

#endif

    j = tcg_gen_code_search_pc(s, (tcg_insn_unit *)tc_ptr,

                               searched_pc - tc_ptr);

    if (j < 0)

        return -1;

    

    while (s->gen_opc_instr_start[j] == 0) {

        j--;

    }

    cpu->icount_decr.u16.low -= s->gen_opc_icount[j];



    restore_state_to_opc(env, tb, j);



#ifdef CONFIG_PROFILER

    s->restore_time += profile_getclock() - ti;

    s->restore_count++;

#endif

    return 0;

}

static int FUNC_0(CPUState *VAR_0, TranslationBlock *VAR_1,

                                     uintptr_t VAR_2)

{

    CPUArchState *env = VAR_0->env_ptr;

    TCGContext *s = &tcg_ctx;

    int VAR_3;

    uintptr_t tc_ptr;

#ifdef CONFIG_PROFILER

    int64_t ti;

#endif



#ifdef CONFIG_PROFILER

    ti = profile_getclock();

#endif

    tcg_func_start(s);



    gen_intermediate_code_pc(env, VAR_1);



    if (use_icount) {

        

        VAR_0->icount_decr.u16.low += VAR_1->icount;

        

        VAR_0->can_do_io = 0;

    }



    

    tc_ptr = (uintptr_t)VAR_1->tc_ptr;

    if (VAR_2 < tc_ptr)

        return -1;



    s->tb_next_offset = VAR_1->tb_next_offset;

#ifdef USE_DIRECT_JUMP

    s->tb_jmp_offset = VAR_1->tb_jmp_offset;

    s->tb_next = NULL;

#else

    s->tb_jmp_offset = NULL;

    s->tb_next = VAR_1->tb_next;

#endif

    VAR_3 = tcg_gen_code_search_pc(s, (tcg_insn_unit *)tc_ptr,

                               VAR_2 - tc_ptr);

    if (VAR_3 < 0)

        return -1;

    

    while (s->gen_opc_instr_start[VAR_3] == 0) {

        VAR_3--;

    }

    VAR_0->icount_decr.u16.low -= s->gen_opc_icount[VAR_3];



    restore_state_to_opc(env, VAR_1, VAR_3);



#ifdef CONFIG_PROFILER

    s->restore_time += profile_getclock() - ti;

    s->restore_count++;

#endif

    return 0;

}

static int FUNC_0(CPUState *VAR_0, TranslationBlock *VAR_1,
uintptr_t VAR_2)
{ CPUArchState *env = VAR_0->env_ptr; TCGContext *s = &tcg_ctx; int VAR_3; uintptr_t tc_ptr; #ifdef CONFIG_PROFILER
int64_t ti; #endif
#ifdef CONFIG_PROFILER
ti = profile_getclock(); #endif
tcg_func_start(s); gen_intermediate_code_pc(env, VAR_1); if (use_icount) { VAR_0->icount_decr.u16.low += VAR_1->icount; VAR_0->can_do_io = 0; } tc_ptr = (uintptr_t)VAR_1->tc_ptr; if (VAR_2 < tc_ptr)
return -1; s->tb_next_offset = VAR_1->tb_next_offset; #ifdef USE_DIRECT_JUMP
s->tb_jmp_offset = VAR_1->tb_jmp_offset; s->tb_next = NULL; #else
s->tb_jmp_offset = NULL; s->tb_next = VAR_1->tb_next; #endif
VAR_3 = tcg_gen_code_search_pc(s, (tcg_insn_unit *)tc_ptr,
VAR_2 - tc_ptr); if (VAR_3 < 0)
return -1; while (s->gen_opc_instr_start[VAR_3] == 0) { VAR_3--; } VAR_0->icount_decr.u16.low -= s->gen_opc_icount[VAR_3]; restore_state_to_opc(env, VAR_1, VAR_3); #ifdef CONFIG_PROFILER
s->restore_time += profile_getclock() - ti; s->restore_count++; #endif
return 0; }