# Path: xform_utils.py
# def apply_iterative(func, args):
#     cnt = 0
#     while func(*args):
#         cnt += 1
#     _log.info("Ran %s %d times" % (func, cnt))
#     return cnt


from dom import *
from dataflow import *
from xform import *
from decomp import *
from xform_utils import apply_iterative
    remove_unreachable_entries(cfg)
    # Various algos below require single-exit CFG
    cfg_single_exit(cfg)

    foreach_inst(cfg, sub_const_to_add)
    foreach_inst(cfg, rewrite_complex_dest)
    foreach_inst(cfg, booleanize_cond)
    # Initial pass on simplifying expressions
    foreach_inst(cfg, simplify_inst)

    analyze_live_vars(cfg)
    insert_initial_regs(cfg)

    do_propagate(cfg)

    # Estimate args only at the beginning of processing
    analyze_live_vars(cfg)
    estimate_params(cfg)

    dce(cfg)

    # This should be run after propagation, so it caught all cases.
    # Run this after DCE to not do useless work ;-).
    foreach_inst(cfg, normalize_cond)

    #
    # Control flow
    #

    remove_trailing_jumps(cfg)

# Path: xform_utils.py
# def apply_iterative(func, args):
#     cnt = 0
#     while func(*args):
#         cnt += 1
#     _log.info("Ran %s %d times" % (func, cnt))
#     return cnt


# Path: script_decompile.py
from dom import *
from dataflow import *
from xform import *
from decomp import *
from xform_utils import apply_iterative

    remove_unreachable_entries(cfg)
    # Various algos below require single-exit CFG
    cfg_single_exit(cfg)

    foreach_inst(cfg, sub_const_to_add)
    foreach_inst(cfg, rewrite_complex_dest)
    foreach_inst(cfg, booleanize_cond)
    # Initial pass on simplifying expressions
    foreach_inst(cfg, simplify_inst)

    analyze_live_vars(cfg)
    insert_initial_regs(cfg)

    do_propagate(cfg)

    # Estimate args only at the beginning of processing
    analyze_live_vars(cfg)
    estimate_params(cfg)

    dce(cfg)

    # This should be run after propagation, so it caught all cases.
    # Run this after DCE to not do useless work ;-).
    foreach_inst(cfg, normalize_cond)

    #
    # Control flow
    #

    remove_trailing_jumps(cfg)

    remove_jump_over_jump(cfg)