# Path: utils.py
# def pairwise(iterable, trailing=True):
#     "For sequence of (a, b, c) yield pairs of (a, b), (b, c), (c, None)."
#     prev = Ellipsis
#     for it in iterable:
#         if prev is not Ellipsis:
#             yield (prev, it)
#         prev = it
#     if trailing:
#         yield (it, None)
# 
# def natural_sort_key(s):
#     if not isinstance(s, str):
#         return s
#     arr = re.split("([0-9]+)", s)
#     return [int(x) if x.isdigit() else x for x in arr]
# 
# Path: cfgutils.py
# def swap_if_branches(cfg, node):
#     "Assuming `node` is 'if' node, swap its branches and invert condition."
#     succ = cfg.sorted_succ(node)
#     print(succ, cfg[node, succ[0]])
#     cond = cfg[node, succ[0]]["cond"]
#     cfg[node, succ[0]]["cond"] = None
#     cfg[node, succ[1]]["cond"] = cond.neg()


import sys
import progdb
from utils import pairwise, natural_sort_key
from cfgutils import swap_if_branches


no_dead = False

def find_used_labels(cfg):
    labels = set()

# Path: utils.py
# def pairwise(iterable, trailing=True):
#     "For sequence of (a, b, c) yield pairs of (a, b), (b, c), (c, None)."
#     prev = Ellipsis
#     for it in iterable:
#         if prev is not Ellipsis:
#             yield (prev, it)
#         prev = it
#     if trailing:
#         yield (it, None)
# 
# def natural_sort_key(s):
#     if not isinstance(s, str):
#         return s
#     arr = re.split("([0-9]+)", s)
#     return [int(x) if x.isdigit() else x for x in arr]
# 
# Path: cfgutils.py
# def swap_if_branches(cfg, node):
#     "Assuming `node` is 'if' node, swap its branches and invert condition."
#     succ = cfg.sorted_succ(node)
#     print(succ, cfg[node, succ[0]])
#     cond = cfg[node, succ[0]]["cond"]
#     cfg[node, succ[0]]["cond"] = None
#     cfg[node, succ[1]]["cond"] = cond.neg()


# Path: cprinter.py
import sys
import progdb
from utils import pairwise, natural_sort_key
from cfgutils import swap_if_branches



no_dead = False

def find_used_labels(cfg):
    labels = set()

    for addr, nxt in pairwise(cfg.iter_rev_postorder()):