Xiaojing Liu

116 papers A 3B 5C 15Journal 73Unranked 20
YearRankTypeTitle / Venue / Authors
2026 J jnl
Reliab. Eng. Syst. Saf.
Enping Zhu, Tao Li, Jinbiao Xiong, Xiang Chai, Tengfei Zhang, Xiaojing Liu
2026 J jnl
Array
Bokai Li, Mingkang Guo, Yongli Jia, Tianzi Zeng, Xiaojing Liu
2026 J jnl
Adv. Eng. Informatics
Qingquan Pan, Lianjie Wang, Bangyang Xia, Yun Cai, Xiaojing Liu
2026 J jnl
ACM Trans. Inf. Syst.
Yuli Liu, Jiahao Wang, Bokang Fu, Yachao Cui, Yu Zhu, Zheng-Jun Du, Xiaojing Liu
2025 J jnl
J. Comput. Methods Sci. Eng.
Zixuan Cheng, Bo Zhang, Yi Zhang, Xiaojing Liu, Yongdong Wei, Wen Fang
2025 J jnl
Reliab. Eng. Syst. Saf.
Xiao Xiao, Meiqi Song, Xiaojing Liu
2025 J jnl
IEEE Trans. Syst. Man Cybern. Syst.
Shoufei Han, Xiaojing Liu, MengChu Zhou, Kun Zhu, Liang Zhao, Changhe Li
2025 J jnl
CoRR
Bokang Fu, Jiahao Wang, Xiaojing Liu, Yuli Liu
2025 J jnl
J. Comput. Phys.
Hongtao Bi, Meiqi Song, Tengfei Zhang, Xiaojing Liu
2025 J jnl
CoRR
Chengjun Yu, Yixin Ran, Yangyi Xia, Jia Wu, Xiaojing Liu
2025 C conf
BSN
Xulin Ma, Jiankai Tang, Zhang Jiang, Songqin Cheng, Yuanchun Shi, Dong Li, Xin Liu, Daniel McDuff, Xiaojing Liu, Yuntao Wang
2025 J jnl
CoRR
Xulin Ma, Jiankai Tang, Zhang Jiang, Songqin Cheng, Yuanchun Shi, Dong Li, Xin Liu, Daniel McDuff, Xiaojing Liu, Yuntao Wang
2025 J jnl
Comput. Phys. Commun.
Qingquan Pan, He Liaoyuan, Xiaojing Liu
2025 conf
EMNLP (Findings)
Tianjiao Li, Mengran Yu, Chenyu Shi, Yanjun Zhao, Xiaojing Liu, Qi Zhang, Xuanjing Huang, Qiang Zhang, Jiayin Wang
2025 J jnl
CoRR
Tianjiao Li, Mengran Yu, Chenyu Shi, Yanjun Zhao, Xiaojing Liu, Qiang Zhang, Qi Zhang, Xuanjing Huang, Jiayin Wang
2025 J jnl
Robotica
Xingtao Wang, Zhen Qiu, Xingchen Liu, Chuanbin Guo, Xiaojing Liu, Jing Wang, Xingguang Duan, Changsheng Li, Jiang Deng, Yubin Xue
2025 B conf
SMC
Xiaojing Liu, Ogulcan Gurelli, Yan Wang, Joshua Reiss
2025 J jnl
CoRR
Xiaojing Liu, Ogulcan Gurelli, Yan Wang, Joshua Reiss
2024 conf
PEAI
Jie Yang, Cong Li, Xianda Chen, Yunpeng Wang, Xiaojing Liu
2024 J jnl
Comput. Math. Appl.
Qizheng Sun, Xiaojing Liu, Xiang Chai, Hui He, Tengfei Zhang
2024 J jnl
CoRR
Xiaojing Liu, Angeliki Mourgela, Hongwei Ai, Joshua D. Reiss
2024 conf
ICNSC
Shoufei Han, Xu Liu, Xiaojing Liu, Honghao Zhu, Ruyi Han
2024 J jnl
IEEE Trans. Intell. Transp. Syst.
Xiaojing Liu, Xiaolin Qin, MengChu Zhou, Hao Sun, Shoufei Han
2024 conf
ICNSC
Xiaojing Liu, Shugen Ma, Shoufei Han, Honghao Zhu, Ruyi Han
2024 J jnl
Appl. Soft Comput.
Qingquan Pan, Songchuan Zheng, Xiaojing Liu
2024 conf
EITCE
Yongheng Zhao, Bingfeng Seng, Xiaojing Liu, Shuhong Wang
2024 J jnl
J. Comput. Assist. Learn.
Xiaojing Liu, Chunmiao Zhou
2024 conf
ICDM (Workshops)
Lujia Lv, Di Wu, Yangyi Xia, Jia Wu, Xiaojing Liu, Yi He
2024 J jnl
CoRR
Lujia Lv, Di Wu, Yangyi Xia, Jia Wu, Xiaojing Liu, Yi He
2024 conf
ICIC (LNAI 3)
Jinliang Li, Junlei Wang, Canyu Li, Xiaojing Liu, Zaiwen Feng, Li Qin, Wolfgang Mayer
2024 J jnl
Multim. Tools Appl.
Hao Sun, Xiaolin Qin, Xiaojing Liu
2024 J jnl
IEEE Internet Things J.
Siyuan Zhou, Xiaojing Liu, Bin Tang, Guoping Tan
2024 J jnl
IEEE Trans. Mob. Comput.
Shoufei Han, Xiaojing Liu, MengChu Zhou, Kun Zhu, Liang Zhao, Aiiad Albeshri, Abdullah Abusorrah
2024 J jnl
Intell. Data Anal.
Hao Sun, Xiaolin Qin, Xiaojing Liu
2024 conf
COCOON (2)
Xiaojing Liu, Jiayu Cui, Winston K. G. Seah, Xiaodong Xu, Gang Xu, Celimuge Wu
2024 conf
ICIC (LNAI 3)
Xiaojing Liu, Canyu Li, Li Qin, Jinliang Li, Junlei Wang, Zaiwen Feng, Wolfgang Mayer
2024 A conf
RecSys
Yuli Liu, Min Liu, Xiaojing Liu
2024 J jnl
CoRR
Yuli Liu, Min Liu, Xiaojing Liu
2024 B conf
IJCNN
Canyu Li, Xiaojing Liu, Jinliang Li, Junlei Wang, Zaiwen Feng, Li Qin
2024 J jnl
CoRR
Ke Liu, Jiankai Tang, Zhang Jiang, Yuntao Wang, Xiaojing Liu, Dong Li, Yuanchun Shi
2024 J jnl
Image Vis. Comput.
Jing Bai, Haiyang Hu, Xiaojing Liu, Shanna Zhuang, Zhengyou Wang
2023 J jnl
Comput. Math. Appl.
Qingquan Pan, Lianjie Wang, Yun Cai, Xiaojing Liu, Jinbiao Xiong
2023 J jnl
IEEE Trans. Cybern.
Shoufei Han, Kun Zhu, MengChu Zhou, Xiaojing Liu
2023 conf
MSN
Siyuan Zhou, Xiaojing Liu, Bin Tang, Guoping Tan
2023 J jnl
CoRR
Bing Yang, Jizeng Wang, Xiaojing Liu, Youhe Zhou
2023 J jnl
Multim. Syst.
Hao Sun, Xiaolin Qin, Xiaojing Liu
2023 J jnl
IEEE Access
Zexian Zhou, Xiaojing Liu
2023 J jnl
Comput. Phys. Commun.
Xiangyue Li, Xiaojing Liu, Xiang Chai, Hui He, Bin Zhang, Tengfei Zhang
2023 B conf
ICPADS
Xiaojing Liu, Xuesong Jiang, Fengge Yi
2023 J jnl
Comput. Phys. Commun.
Qingquan Pan, Huanwen Lv, Songqian Tang, Jinbiao Xiong, Xiaojing Liu
2023 J jnl
J. Organ. End User Comput.
Si Sun, Xuandong Zhang, Li Dong, Lu Fan, Xiaojing Liu
2023 B conf
ICPADS
Fengge Yi, Xiumei Wei, Xiaojing Liu, Xuesong Jiang
2022 J jnl
IEEE CAA J. Autom. Sinica
Shoufei Han, Kun Zhu, MengChu Zhou, Xiaojing Liu, Haoyue Liu, Yusuf Al-Turki, Abdullah Abusorrah
2022 J jnl
Comput. Phys. Commun.
Han Yin, Tengfei Zhang, Donghao He, Xiaojing Liu
2022 J jnl
Comput. Phys. Commun.
Wei Xiao, Qizheng Sun, Xiaojing Liu, Hui He, Donghao He, Qingquan Pan, Tengfei Zhang
2022 J jnl
Comput. Phys. Commun.
Wei Xiao, Xiangyue Li, Peijie Li, Tengfei Zhang, Xiaojing Liu
2022 J jnl
Enterp. Inf. Syst.
Limeng Ying, Xiaojing Liu, Menghao Li, Lipeng Sun, Pishi Xiu, Jie Yang
2022 J jnl
Symmetry
Xiaojing Liu, Shuiting Ding, Longtao Shao, Shuai Zhao, Tian Qiu, Yu Zhou, Xiaozhe Zhang, Guo Li
2022 J jnl
IEEE Trans. Intell. Transp. Syst.
Shoufei Han, Kun Zhu, MengChu Zhou, Xiaojing Liu
2022 conf
SmartWorld/UIC/ScalCom/DigitalTwin/PriComp/Meta
Jiajia Li, Chunhui Liu, Ying Zhao, Xiaojing Liu, Liang Zhao, Xiufeng Xia
2022 J jnl
Comput. Phys. Commun.
Qingquan Pan, Nan An, Tengfei Zhang, Xiaojing Liu, Yun Cai, Lianjie Wang, Kan Wang
2021 J jnl
Expert Syst. Appl.
Xiaojing Liu, Xiaolin Qin
2021 B conf
TrustCom
Mingxin Li, Mingde Huo, Xinzhou Cheng, Lexi Xu, Xiaojing Liu, Rui Yang
2021 J jnl
Ind. Manag. Data Syst.
Xiaojing Liu, Tiru S. Arthanari, Yangyan Shi
2021 J jnl
IEEE Access
Yuhong Chen, Zhen Fan, Xiaojing Liu
2020 J jnl
Eng. Appl. Artif. Intell.
Xiaojing Liu, Xiaolin Qin
2020 C conf
IGARSS
Jian Wang, Lingmei Jiang, Xiaojing Liu, Jianwei Yang
2019 J jnl
IEEE J. Sel. Top. Appl. Earth Obs. Remote. Sens.
Shirui Hao, Lingmei Jiang, Jiancheng Shi, Gongxue Wang, Xiaojing Liu
2019 J jnl
J. Medical Imaging Health Informatics
Qianqian Li, Rui Song, Xin Ma, Xiaojing Liu
2019 C conf
IGARSS
Xiaojing Liu, Lingmei Jiang, Gongxue Wang, Shu Wang
2019 J jnl
Remote. Sens.
Jianwei Yang, Lingmei Jiang, Shengli Wu, Gongxue Wang, Jian Wang, Xiaojing Liu
2019 C conf
IGARSS
Gongxue Wang, Lingmei Jiang, Xiaojing Liu, Huizhen Cui, Jianwei Yang, Jian Wang
2019 conf
NAACL-HLT (2)
Xiaojing Liu, Feiyu Gao, Qiong Zhang, Huasha Zhao
2019 J jnl
CoRR
Xiaojing Liu, Feiyu Gao, Qiong Zhang, Huasha Zhao
2019 J jnl
Remote. Sens.
Gongxue Wang, Lingmei Jiang, Jiancheng Shi, Xiaojing Liu, Jianwei Yang, Huizhen Cui
2019 C conf
IGARSS
Jian Wang, Lingmei Jiang, Huizhen Cui, Jianwei Yang, Gongxue Wang, Xiaojing Liu, Xu Su
2018 J jnl
IEEE Access
Qianqian Li, Rui Song, Xin Ma, Xiaojing Liu
2018 J jnl
Remote. Sens.
Xiaojing Liu, Lingmei Jiang, Shengli Wu, Shirui Hao, Gongxue Wang, Jianwei Yang
2018 C conf
IGARSS
Xiaojing Liu, Lingmei Jiang, Shirui Hao, Gongxue Wang, Jianwei Yang, Zhizhong Chen
2018 C conf
IGARSS
Gongxue Wang, Lingmei Jiang, Shirui Hao, Xiaojing Liu, Jianwei Yang, Huizhen Cui
2018 C conf
IGARSS
Jianwei Yang, Lingmei Jiang, Shengli Wu, Xiaojing Liu, Gongxue Wang, Shirui Hao, Jian Wang
2018 J jnl
IEEE J. Sel. Top. Appl. Earth Obs. Remote. Sens.
Xiaojing Liu, Lingmei Jiang, Gongxue Wang, Shirui Hao, Zhizhong Chen
2017 conf
RCAR
Qianqian Li, Ping Liu, Lei Qi, Xiaojing Liu, Xin Ma, Rui Song
2017 J jnl
Comput. Phys. Commun.
Lei Zhang, Jizeng Wang, Xiaojing Liu, Youhe Zhou
2017 J jnl
Remote. Sens.
Gongxue Wang, Lingmei Jiang, Shengli Wu, Jiancheng Shi, Shirui Hao, Xiaojing Liu
2017 C conf
IGARSS
Gongxue Wang, Lingmei Jiang, Shirui Hao, Xiaojing Liu, Huizhen Cui
2017 C conf
IGARSS
Zhizhong Chen, Linna Chai, Wenxing Hu, Xiaojing Liu
2017 C conf
IGARSS
Shirui Hao, Lingmei Jiang, Gongxue Wang, Xiaojing Liu
2016 J jnl
Comput. Math. Appl.
Xiaojing Liu, Jizeng Wang, Youhe Zhou
2016 C conf
IGARSS
Xiaojing Liu, Lingmei Jiang, Gongxue Wang, Zheng Lu
2016 J jnl
CoRR
Zhipeng Gui, Jun Cao, Xiaojing Liu, Xiaoqiang Cheng, Huayi Wu
2016 J jnl
ISPRS Int. J. Geo Inf.
Zhipeng Gui, Jun Cao, Xiaojing Liu, Xiaoqiang Cheng, Huayi Wu
2016 J jnl
Neural Comput. Appl.
Xiaojing Liu
2016 C conf
IGARSS
Xiaojing Liu, Lingmei Jiang, Gongxue Wang, Shirui Hao
2015 J jnl
Neurocomputing
Xiaojing Liu
2015 J jnl
Multim. Syst.
Feng Xia, Ching-Hsien Hsu, Xiaojing Liu, Haifeng Liu, Fangwei Ding, Wei Zhang
2014 conf
EMBC
Kai-Yuan Chen, Xiaojing Liu, Pengcheng Bu, Chieh-Sheng Lin, Nikolai Rakhilin, Jason W. Locasale, Xiling Shen
2014 J jnl
PLoS Comput. Biol.
Lei Huang, Dongsung Kim, Xiaojing Liu, Christopher R. Myers, Jason W. Locasale
2014 conf
BMEI
Chaowei Gao, Li Chen, Bochao Hou, Xiaojing Liu, Chuanbin Guo
2013 J jnl
Commun. Nonlinear Sci. Numer. Simul.
Xiaojing Liu, Youhe Zhou, Xiaomin Wang, Jizeng Wang
2013 conf
GreenCom/iThings/CPScom
Xiaojing Liu, Fangwei Ding, Jie Li, Haifeng Liu, Zhuo Yang, Juan Chen, Feng Xia
2013 J jnl
CoRR
Feng Xia, Ching-Hsien Hsu, Xiaojing Liu, Fangwei Ding, Wei Zhang
2011 conf
CSISE (2)
Yueqiu Jiang, Yang Wang, Hongwei Gao, Xiaojing Liu
2010 J jnl
J. Comput.
Xixiang Zhang, Guangxue Yue, Xiaojing Liu, Fei Yu
2010 J jnl
J. Educ. Technol. Soc.
Xiaojing Liu, Shijuan Liu, Seunghee Lee, Richard J. Magjuka
2010 conf
Geoinformatics
Lili Song, Lina Qi, Ji Qi, Kun Wang, Xiaojing Liu
2010 J jnl
J. Geogr. Inf. Syst.
Wenyou Fan, Xin Meng, Xiaojing Liu, Niaoniao Hu
2009 J jnl
Int. J. Comput. Games Technol.
Mingquan Zhou, QingSong Huo, Guohua Geng, Xiaojing Liu
2009 J jnl
J. Educ. Technol. Soc.
Seunghee Lee, Jieun Lee, Xiaojing Liu, Curtis J. Bonk, Richard J. Magjuka
2008 J jnl
Br. J. Educ. Technol.
Xiaojing Liu, Richard J. Magjuka, Seunghee Lee
2007 conf
IITA
Xiaojing Liu, Wenbing Wu, Fei Yu, Deng Chang
2005 conf
ISNN (3)
Xiaojing Liu, Jianqiang Yi, Dongbin Zhao
2005 C conf
ACC
Xiaojing Liu, Jianqiang Yi, Dongbin Zhao
2005 A conf
IROS
Jianqiang Yi, Wei Wang, Dongbin Zhao, Xiaojing Liu
2005 C conf
ACC
Wei Wang, Jianqiang Yi, Dongbin Zhao, Xiaojing Liu
2005 A conf
IROS
Wei Wang, Jianqiang Yi, Dongbin Zhao, Xiaojing Liu
redb/extractors/decompiler/bninja/analysis/cfg-old.py
← Index redb/extractors/decompiler/bninja/analysis/cfg-old.py python
from collections import deque
from enum import Enum

from binaryninja.enums import (
    BranchType,
    InstructionTextTokenType,
)

# Support both package and standalone imports
try:
    from ..utils.hashes import calculate_md5, calculate_sha256
except ImportError:
    # Fallback to absolute imports (for multiprocessing spawned processes)
    from redb.extractors.decompiler.bninja.utils.hashes import calculate_md5, calculate_sha256


class CFGAnalysis:
    def __init__(self, function):
        self.function = function

    def determine_block_type(self, block) -> str:
        """Determine the type of a basic block."""
        # Check if it's a thunk function (usually just a jump or call)
        if len(block.disassembly_text) <= 2 and any(
            "jmp" in line.tokens[0].text.lower() for line in block.disassembly_text
        ):
            return "THUNK"

        # Check if it contains only data (no valid instructions)
        if all(not line.tokens for line in block.disassembly_text):
            return "DATA"

        # Default to code
        return "CODE"

    def extract_cyclomatic_complexity(self):
        """
        Cyclomatic complexity (McCabe’s metric) measures the number of linearly independent paths
        through a function’s control flow graph (CFG).
        The standard formula is:

            M = E - N + 2

        where:
            - E = number of edges in the CFG
            - N = number of nodes (basic blocks)
            - 2 accounts for the entry and exit nodes of a single connected graph
        """
        if self.function is None:
            return 0

        # number of basic blocks
        num_blocks = len(self.function.basic_blocks)
        # number of edges in the graph
        num_edges = sum(
            len(basic_block.outgoing_edges)
            for basic_block in self.function.basic_blocks
        )
        return num_edges - num_blocks + 2

    def extract_function_cfg(self):
        """Extract information about a function CFG and return it as a dictionary."""

        function = self.function
        function_data = {
            "function_address": self.function.start,
            "blocks": [],
            "measures": {
                "cyclomatic_complexity": self.extract_cyclomatic_complexity(),
            },
        }

        if self.function is None:
            return function_data

        # Get the map of the depth associated to every block
        depths = self.get_map_depth()

        # Get the map of the positions associated to every block
        id_maps = self.get_block_id_map()

        # Extract block data with graph structure information
        for block in function.basic_blocks:
            # dominators per every block translated
            dominators = sorted(self.extract_dominators(block, id_maps))

            # post dominators
            post_dominators = sorted(self.extract_post_dominators(block, id_maps))

            # Build block instructions string
            block_instructions = "\n".join(str(line) for line in block.disassembly_text)

            # Determine block type
            block_type = self.determine_block_type(block)

            # Extract successors directly from basic block
            successor_blocks = [edge.target.start for edge in block.outgoing_edges]
            # We ensure a canonical order and we sort the edges
            successor_blocks.sort()

            # Extract predecessors directly from basic block
            predecessor_blocks = [edge.source.start for edge in block.incoming_edges]
            # We ensure a canonical order and we sort the edges
            predecessor_blocks.sort()

            # Determine branch type from outgoing edges
            branch_type = self.determine_branch_type(block)

            instructions_count = len(block.disassembly_text)

            # Create block record
            block_json = {
                "function_address": self.function.start,
                "block_start_address": block.start,
                "block_end_address": block.end,
                "block_size": block.end - block.start,
                "instructions_count": instructions_count,
                "block_instructions_hash": calculate_sha256(block_instructions),
                "predecessor_blocks": predecessor_blocks,
                "successor_blocks": successor_blocks,
                "depth": depths[block.start],
                "position": id_maps[block.start],
                "branch_type": branch_type,
                "block_type": block_type,
                "flags": self.extract_block_flags(block),
                "dominators": dominators,
                "post_dominators": post_dominators,
            }
            function_data["blocks"].append(block_json)

        return function_data

    def extract_dominators(self, bb, id_maps):
        """Extract the dominators normalized"""
        dom_idx = [id_maps[d.start] for d in bb.dominators]
        return dom_idx

    def extract_post_dominators(self, bb, id_maps):
        """Extract the post-dominators normalized"""
        post_dom_idx = [id_maps[d.start] for d in bb.post_dominators]
        return post_dom_idx

    def determine_branch_type(self, block):
        """
        Determine the type of branch at the end of a basic block.
        This combines edge type information with instruction analysis.
        """
        # If no outgoing edges, it might be a return or terminal block
        if not block.outgoing_edges:
            # Check if the last instruction is a return
            for line in reversed(list(block.disassembly_text)):
                if line.tokens and any(
                    token.text.lower() in ["ret", "retn"] for token in line.tokens
                ):
                    return "RETURN"
            return "UNKNOWN"

        # Collect branch types from all outgoing edges
        branch_types = []
        for edge in block.outgoing_edges:
            edge_type = edge.type
            # Map edge type to our branch type enum
            if isinstance(edge_type, str):
                if edge_type == "IndirectCall":
                    branch_types.append("CALL")
                else:
                    branch_types.append("UNKNOWN")
            else:
                # Use our mapping for integer/enum values
                type_mapping = {
                    BranchType.UnconditionalBranch: "DIRECT",
                    BranchType.FalseBranch: "CONDITIONAL",
                    BranchType.TrueBranch: "CONDITIONAL",
                    BranchType.CallDestination: "CALL",
                    BranchType.FunctionReturn: "RETURN",
                    BranchType.SystemCall: "CALL",
                    BranchType.IndirectBranch: "INDIRECT",
                    BranchType.ExceptionBranch: "UNKNOWN",
                    BranchType.UnresolvedBranch: "UNKNOWN",
                    BranchType.UserDefinedBranch: "UNKNOWN",
                }
                branch_types.append(type_mapping.get(edge_type, "UNKNOWN"))

        # Determine overall branch type (prioritize CALL > RETURN > CONDITIONAL > DIRECT)
        if "CALL" in branch_types:
            return "CALL"
        elif "RETURN" in branch_types:
            return "RETURN"
        elif "CONDITIONAL" in branch_types:
            return "CONDITIONAL"
        elif "DIRECT" in branch_types:
            return "DIRECT"
        elif len(block.outgoing_edges) == 1:
            return "FALLTHROUGH"

        # If edge analysis was inconclusive, fall back to instruction analysis
        last_instr = None
        for line in reversed(list(block.disassembly_text)):
            if line.tokens:
                last_instr = line
                break

        if last_instr:
            mnemonic = None
            for token in last_instr.tokens:
                if token.type == InstructionTextTokenType.InstructionToken:
                    mnemonic = token.text.lower()
                    break

            if mnemonic:
                if mnemonic == "call":
                    return "CALL"
                elif mnemonic == "jmp":
                    return "DIRECT"
                elif mnemonic.startswith("j") and mnemonic != "jmp":
                    return "CONDITIONAL"
                elif mnemonic in ["ret", "retn"]:
                    return "RETURN"

        return "UNKNOWN"

    def get_map_depth(self):
        """
        Run a BFS on the basic blocks of the function to assign a depth to every block
        """

        depths = {}
        entry = self.function.get_basic_block_at(self.function.start)

        ### Simple BFS
        q = deque()
        q.append(entry)
        depths[entry.start] = 0

        while q:
            b = q.popleft()
            b_depth = depths[b.start]
            for edge in b.outgoing_edges:
                tgt = edge.target

                if tgt is None:
                    continue

                if tgt.start not in depths:
                    depths[tgt.start] = b_depth + 1
                    q.append(tgt)

        return depths

    def get_block_id_map(self):
        """
        Assign a unique, sequential ID to each basic block of the function using a BFS starting from the entry block.
        """

        id_map = {}
        entry = self.function.get_basic_block_at(self.function.start)

        q = deque()
        q.append(entry)

        current_id = 0
        id_map[entry.start] = current_id

        while q:
            b = q.popleft()
            for edge in b.outgoing_edges:
                tgt = edge.target

                if tgt is None:
                    continue

                if tgt.start not in id_map:
                    current_id += 1
                    id_map[tgt.start] = current_id
                    q.append(tgt)

        return id_map

    def extract_block_flags(self, block):
        """
        Get the flags for every basic block. Currently, we implemented these heuristics:
            - if a basic block is the entry node for a function
            - if a basic block is the exit block for a function
            - if a basic block is part of a natural loop
        """
        flags = []

        if block.start == self.function.start:
            flags.append(BlockFlags.EntryBlock.value)

        if any(edge.type == BranchType.FunctionReturn for edge in block.outgoing_edges):
            flags.append(BlockFlags.ExitBlock.value)

        # if this block is in its dominance frontier, then it's part of a natural loop
        if block in block.dominance_frontier:
            flags.append(BlockFlags.LoopBlock.value)

        return flags


class BlockFlags(Enum):
    # generally, the basic block identifying the entry point of the function
    EntryBlock = "EntryBlock"
    # any basic blocks that makes the control flow exiting from the current function
    ExitBlock = "ExitBlock"
    # any block is in a natural loop if it is in its own dominance frontier
    LoopBlock = "LoopBlock"


class BlockType(Enum):
    THUNK = "THUNK"
    DATA = "DATA"
    PADDING = "PADDING"
    CODE = "CODE"