Habib Zaidi

89 papers B 1C 2Journal 75Unranked 11
YearRankTypeTitle / Venue / Authors
2026 J jnl
Expert Syst. Appl.
Menatalla Haggag, Abbes Amira, Fatih Kurugollu, Habib Zaidi, Bassel Soudan
2026 J jnl
Comput. Methods Programs Biomed.
Hao Sun, Xiaotong Hong, Yijun Lu, Fanghu Wang, Amirhossein Sanaat, Weiping Xu, Shuxia Wang, Habib Zaidi, Lijun Lu
2026 J jnl
CoRR
Zanting Ye, Xiaolong Niu, Xuanbin Wu, Xu Han, Shengyuan Liu, Jing Hao, Zhihao Peng, Hao Sun, Jieqin Lv, Fanghu Wang, Yanchao Huang, Hubing Wu, Yixuan Yuan, Habib Zaidi, Arman Rahmim, Yefeng Zheng, Lijun Lu
2025 J jnl
CoRR
Maziar Sabouri, Ghasem Hajianfar, Alireza Rafiei Sardouei, Milad Yazdani, Azin Asadzadeh, Soroush Bagheri, Mohsen Arabi, Seyed Rasoul Zakavi, Emran Askari, Atena Aghaee, Dena Shahriari, Habib Zaidi, Arman Rahmim
2025 J jnl
CoRR
Alejandro López-Montes, Fereshteh Yousefirizi, Yizhou Chen, Yazdan Salimi, Robert Seifert, Ali Afshar-Oromieh, Carlos F. Uribe, Axel Rominger, Habib Zaidi, Arman Rahmim, Kuangyu Shi
2025 J jnl
Medical Biol. Eng. Comput.
Yashar Ahmadyar, Alireza Kamali-Asl, Rezvan Samimi, Hossein Arabi, Habib Zaidi
2025 conf
EUVIP
Taifour Yousra, Azeddine Beghdadi, Marie Luong, Zuheng Ming, Habib Zaidi, Faouzi Alaya Cheikh
2025 J jnl
CoRR
Taifour Yousra, Azeddine Beghdadi, Marie Luong, Zuheng Ming, Habib Zaidi, Faouzi Alaya Cheikh
2025 J jnl
NeuroImage
Yiyi Hu, Amirhossein Sanaat, Gregory Mathoux, Eliluane Pirazzo Andrade Teixeira, Valentina Garibotto, Habib Zaidi
2025 J jnl
Comput. Biol. Medicine
Mohammad Saber Azimi, Vahid Felfelian, Navid Zeraatkar, Habibollah Dadgar, Hossein Arabi, Habib Zaidi
2025 J jnl
Comput. Electr. Eng.
Jie Cai, Haiyan Li, Habib Zaidi, Hao Zhou, Yaqun Huang
2025 J jnl
CoRR
Pooya Mohammadi Kazaj, Giovanni Baj, Yazdan Salimi, Anselm W. Stark, Waldo Valenzuela, George CM. Siontis, Habib Zaidi, Mauricio Reyes, Christoph Graeni, Isaac Shiri
2025 J jnl
NeuroImage
Mohammad Saber Azimi, Maryam Cheraghi, Fatemeh Mahdimaleki, Faezeh Mahdimaleki, Amirhossein Sanaat, Poul Flemming Høilund-Carlsen, Abass Alavi, Habib Zaidi
2024 J jnl
Comput. Methods Programs Biomed.
Chang Sun, Yazdan Salimi, Neroladaki Angeliki, Sana Boudabbous, Habib Zaidi
2024 J jnl
J. Imaging Inform. Medicine
Hossein Arabi, Habib Zaidi
2024 J jnl
Int. J. Imaging Syst. Technol.
Isaac Shiri, Yazdan Salimi, Abdollah Saberi, Masoumeh Pakbin, Ghasem Hajianfar, Atlas Haddadi Avval, Amirhossein Sanaat, Azadeh Akhavanallaf, Shayan Mostafaei, Zahra Mansouri, Dariush Askari, Mohammadreza Ghasemian, Ehsan Sharifipour, Saleh Sandoughdaran, Ahmad Sohrabi, Elham Sadati, Somayeh Livani, Pooya Iranpour, Shahriar Kolahi, Bardia Khosravi, Maziar Khateri, Salar Bijari, Mohammad Reza Atashzar, Sajad P. Shayesteh, Mohammadreza Babaei, Elnaz Jenabi, Mohammad Hasanian, Alireza Shahhamzeh, Seyed Yaser Foroghi Ghomi, Abolfazl Mozafari, Hesamaddin Shirzad-Aski, Fatemeh Movaseghi, Rama Bozorgmehr, Neda Goharpey, Hamid Abdollahi, Parham Geramifar, Amir Reza Radmard, Hossein Arabi, Kiara Rezaei-Kalantari, Mehrdad Oveisi, Arman Rahmim, Habib Zaidi
2024 J jnl
Medical Biol. Eng. Comput.
Ghasem Hajianfar, Seyyed Ali Hosseini, Sara Bagherieh, Mehrdad Oveisi, Isaac Shiri, Habib Zaidi
2024 J jnl
J. Biomed. Informatics
Isaac Shiri, Behrooz Razeghi, Sohrab Ferdowsi, Yazdan Salimi, Deniz Gündüz, Douglas Teodoro, Slava Voloshynovskiy, Habib Zaidi
2024 J jnl
CoRR
Amirhosein Toosi, Isaac Shiri, Habib Zaidi, Arman Rahmim
2024 J jnl
Biomed. Signal Process. Control.
Hossein Arabi, Habib Zaidi
2024 conf
EUVIP
Ghasem Hajianfar, Maziar Sabouri, Abdollah Saberi Manesh, Soroush Bagheri, Mohsen Arabi, Seyed Rasoul Zakavi, Emran Askari, Ali Rasouli, Azin Asadzadeh, Atena Aghaee, Kourosh Fattahi, Ehsan Bayat, Mahdi Mogharrabi, Mohammad Chehreghani, Yazdan Salimi, Amirhossein Sanaat, Arman Rahmim, Isaac Shiri, Habib Zaidi
2024 conf
EUVIP
Maziar Sabouri, Shadab Ahamed, Azin Asadzadeh, Atlas Haddadi Avval, Soroush Bagheri, Mohsen Arabi, Seyed Rasoul Zakavi, Emran Askari, Ali Rasouli, Atena Aghaee, Mohaddese Sehati, Fereshteh Yousefirizi, Carlos F. Uribe, Ghasem Hajianfar, Habib Zaidi, Arman Rahmim
2024 J jnl
CoRR
Maziar Sabouri, Shadab Ahamed, Azin Asadzadeh, Atlas Haddadi Avval, Soroush Bagheri, Mohsen Arabi, Seyed Rasoul Zakavi, Emran Askari, Ali Rasouli, Atena Aghaee, Mohaddese Sehati, Fereshteh Yousefirizi, Carlos F. Uribe, Ghasem Hajianfar, Habib Zaidi, Arman Rahmim
2024 J jnl
CAAI Trans. Intell. Technol.
Imene Mecheter, Maysam Abbod, Habib Zaidi, Abbes Amira
2024 J jnl
Int. J. Imaging Syst. Technol.
Mohamed L. Seghier, Habib Zaidi
2023 J jnl
J. Digit. Imaging
Haniyeh Taleie, Ghasem Hajianfar, Maziar Sabouri, Mozhgan Parsaee, Golnaz Houshmand, Ahmad Bitarafan-rajabi, Habib Zaidi, Isaac Shiri
2023 J jnl
Comput. Methods Programs Biomed.
Isaac Shiri, Behrooz Razeghi, Alireza Vafaei Sadr, Mehdi Amini, Yazdan Salimi, Sohrab Ferdowsi, Peter Boor, Deniz Gündüz, Slava Voloshynovskiy, Habib Zaidi
2023 J jnl
J. Digit. Imaging
Maziar Sabouri, Ghasem Hajianfar, Zahra Hosseini, Mehdi Amini, Mobin Mohebi, Tahereh Ghaedian, Shabnam Madadi, Fereydoon Rastgou, Mehrdad Oveisi, Ahmad Bitarafan-rajabi, Isaac Shiri, Habib Zaidi
2023 J jnl
J. Digit. Imaging
Mobin Mohebi, Mehdi Amini, Mohammad Javad Alemzadeh-Ansari, Azin Alizadehasl, Ahmad Bitarafan-rajabi, Isaac Shiri, Habib Zaidi, Mahdi Orooji
2022 J jnl
Neurocomputing
Imene Mecheter, Maysam Abbod, Habib Zaidi, Abbes Amira
2022 J jnl
Int. J. Imaging Syst. Technol.
Isaac Shiri, Hossein Arabi, Yazdan Salimi, Amirhossein Sanaat, Azadeh Akhavanallaf, Ghasem Hajianfar, Dariush Askari, Shakiba Moradi, Zahra Mansouri, Masoumeh Pakbin, Saleh Sandoughdaran, Hamid Abdollahi, Amir Reza Radmard, Kiara Rezaei-Kalantari, Mostafa Ghelich Oghli, Habib Zaidi
2022 J jnl
Comput. Biol. Medicine
Isaac Shiri, Yazdan Salimi, Masoumeh Pakbin, Ghasem Hajianfar, Atlas Haddadi Avval, Amirhossein Sanaat, Shayan Mostafaei, Azadeh Akhavanallaf, Abdollah Saberi, Zahra Mansouri, Dariush Askari, Mohammadreza Ghasemian, Ehsan Sharifipour, Saleh Sandoughdaran, Ahmad Sohrabi, Elham Sadati, Somayeh Livani, Pooya Iranpour, Shahriar Kolahi, Maziar Khateri, Salar Bijari, Mohammad Reza Atashzar, Sajad P. Shayesteh, Bardia Khosravi, Mohammadreza Babaei, Elnaz Jenabi, Mohammad Hasanian, Alireza Shahhamzeh, Seyed Yaser Foroghi Ghomi, Abolfazl Mozafari, Arash Teimouri, Fatemeh Movaseghi, Azin Ahmari, Neda Goharpey, Rama Bozorgmehr, Hesamaddin Shirzad-Aski, Roozbeh Mortazavi, Jalal Karimi, Nazanin Mortazavi, Sima Besharat, Mandana Afsharpad, Hamid Abdollahi, Parham Geramifar, Amir Reza Radmard, Hossein Arabi, Kiara Rezaei-Kalantari, Mehrdad Oveisi, Arman Rahmim, Habib Zaidi
2022 J jnl
Artif. Intell. Medicine
Imene Mecheter, Maysam Abbod, Abbes Amira, Habib Zaidi
2022 J jnl
J. Comput. Des. Eng.
Samaneh Mostafapour, Faeze Gholamiankhah, Sirwan Maroufpour, Mehdi Momennezhad, Mohsen Asadinezhad, Seyed Rasoul Zakavi, Hossein Arabi, Habib Zaidi
2022 J jnl
Comput. Biol. Medicine
Isaac Shiri, Mehdi Amini, Mostafa Nazari, Ghasem Hajianfar, Atlas Haddadi Avval, Hamid Abdollahi, Mehrdad Oveisi, Hossein Arabi, Arman Rahmim, Habib Zaidi
2022 J jnl
J. Digit. Imaging
Fatemeh Arian, Mehdi Amini, Shayan Mostafaei, Kiara Rezaei-Kalantari, Atlas Haddadi Avval, Zahra Shahbazi, Kianosh Kasani, Ahmad Bitarafan-rajabi, Saikat Chatterjee, Mehrdad Oveisi, Isaac Shiri, Habib Zaidi
2022 J jnl
Comput. Biol. Medicine
Elham Avard, Isaac Shiri, Ghasem Hajianfar, Hamid Abdollahi, Kiara Rezaei-Kalantari, Golnaz Houshmand, Kianosh Kasani, Ahmad Bitarafan-rajabi, Mohammad Reza Deevband, Mehrdad Oveisi, Habib Zaidi
2022 conf
HECKTOR@MICCAI
Vincent Andrearczyk, Valentin Oreiller, Moamen Abobakr, Azadeh Akhavanallaf, Panagiotis Balermpas, Sarah Boughdad, Leo Capriotti, Joël Castelli, Catherine Cheze Le Rest, Pierre Decazes, Ricardo Correia, Dina El-Habashy, Hesham Elhalawani, Clifton D. Fuller, Mario Jreige, Yomna Khamis, Agustina La Greca Saint-Esteven, Abdallah Sherif Radwan Mohamed, Mohamed A. Naser, John O. Prior, Su Ruan, Stephanie Tanadini-Lang, Olena Tankyevych, Yazdan Salimi, Martin Vallières, Pierre Vera, Dimitris Visvikis, Kareem A. Wahid, Habib Zaidi, Mathieu Hatt, Adrien Depeursinge
2022 J jnl
J. Digit. Imaging
Amirhossein Sanaat, Isaac Shiri, Sohrab Ferdowsi, Hossein Arabi, Habib Zaidi
2022 J jnl
CoRR
Arman Rahmim, Amirhosein Toosi, Mohammad R. Salmanpour, Natalia Dubljevic, Ian Janzen, Isaac Shiri, Mohamad A. Ramezani, Ren Yuan, Cheryl Ho, Habib Zaidi, Calum MacAulay, Carlos F. Uribe, Fereshteh Yousefirizi
2022 J jnl
Comput. Biol. Medicine
Pegah Moradi Khaniabadi, Yassine Bouchareb, Humoud Al Dhuhli, Isaac Shiri, Faiza Al Kindi, Bita Moradi Khaniabadi, Habib Zaidi, Arman Rahmim
2022 J jnl
Comput. Biol. Medicine
Amir Jabbarpour, Seied Rabi Mahdavi, Alireza Vafaei Sadr, Golbarg Esmaili, Isaac Shiri, Habib Zaidi
2021 conf
ISBI
Mahsa Amirrashedi, Saeed Sarkar, Hossein Ghadiri, Pardis Ghafarian, Habib Zaidi, Mohammad Reza Ay
2021 J jnl
Comput. Biol. Medicine
Yassine Bouchareb, Pegah Moradi Khaniabadi, Faiza Al Kindi, Humoud Al Dhuhli, Isaac Shiri, Habib Zaidi, Arman Rahmim
2021 J jnl
NeuroImage
Amirhossein Sanaat, Hossein Shooli, Sohrab Ferdowsi, Isaac Shiri, Hossein Arabi, Habib Zaidi
2021 J jnl
IEEE Access
Yongbo Wang, Gaofeng Chen, Tao Xi, Zhaoying Bian, Dong Zeng, Habib Zaidi, Ji He, Jianhua Ma
2021 J jnl
Comput. Medical Imaging Graph.
Mahsa Amirrashedi, Saeed Sarkar, Hojjat Mamizadeh, Hossein Ghadiri, Pardis Ghafarian, Habib Zaidi, Mohammad Reza Ay
2021 J jnl
Comput. Biol. Medicine
Isaac Shiri, Majid Sorouri, Parham Geramifar, Mostafa Nazari, Mohammad Abdollahi, Yazdan Salimi, Bardia Khosravi, Dariush Askari, Leila Aghaghazvini, Ghasem Hajianfar, Amir Kasaeian, Hamid Abdollahi, Hossein Arabi, Arman Rahmim, Amir Reza Radmard, Habib Zaidi
2021 J jnl
Comput. Biol. Medicine
Zahra Khodabakhshi, Shayan Mostafaei, Hossein Arabi, Mehrdad Oveisi, Isaac Shiri, Habib Zaidi
2021 J jnl
J. Digit. Imaging
Zahra Khodabakhshi, Mehdi Amini, Shayan Mostafaei, Atlas Haddadi Avval, Mostafa Nazari, Mehrdad Oveisi, Isaac Shiri, Habib Zaidi
2021 J jnl
Comput. Biol. Medicine
Azadeh Akhavanallaf, Reza Mohammadi, Isaac Shiri, Yazdan Salimi, Hossein Arabi, Habib Zaidi
2021 J jnl
Comput. Biol. Medicine
Mostafa Nazari, Isaac Shiri, Habib Zaidi
2020 conf
IntelliSys (3)
Imene Mecheter, Abbes Amira, Maysam Abbod, Habib Zaidi
2020 conf
SSCI
Imene Mecheter, Abbes Amira, Maysam Abbod, Habib Zaidi
2020 J jnl
Medical Image Anal.
Hossein Arabi, Habib Zaidi
2019 conf
MeMeA
Hamidreza Khodajou-Chokami, Seyed Abolfazl Hosseini, Mohammad Reza Ay, Ali Safarzadehamiri, Pardis Ghafarian, Habib Zaidi
2019 conf
MeMeA
Hamidreza Khodajou-Chokami, Seyed Abolfazl Hosseini, Mohammad Reza Ay, Habib Zaidi
2017 J jnl
Medical Image Anal.
Hossein Arabi, Habib Zaidi
2017 J jnl
NeuroImage
Abolfazl Mehranian, Habib Zaidi, Andrew J. Reader
2017 J jnl
Comput. Medical Imaging Graph.
Nicolas A. Karakatsanis, Charalampos Tsoumpas, Habib Zaidi
2016 J jnl
Medical Image Anal.
Hossein Arabi, Habib Zaidi
2016 J jnl
NeuroImage
Abolfazl Mehranian, Hossein Arabi, Habib Zaidi
2016 J jnl
IEEE Signal Process. Mag.
Habib Zaidi, Minerva Becker
2015 J jnl
IEEE Trans. Medical Imaging
Abolfazl Mehranian, Habib Zaidi
2014 J jnl
Comput. Medical Imaging Graph.
Fotis A. Kotasidis, Charalampos Tsoumpas, Irene Polycarpou, Habib Zaidi
2013 J jnl
IEEE Trans. Medical Imaging
Abolfazl Mehranian, Mohammad Reza Ay, Arman Rahmim, Habib Zaidi
2012 J jnl
Comput. Medical Imaging Graph.
Daniel Gutierrez, Marie-Louise Montandon, Frédéric Assal, Mohamed Allaoua, Osman Ratib, Karl-Olof Lövblad, Habib Zaidi
2012 J jnl
Adv. Fuzzy Syst.
Mhd Saeed Sharif, Maysam F. Abbod, Abbes Amira, Habib Zaidi
2012 J jnl
IEEE Trans. Medical Imaging
Tony Shepherd, Mika Teräs, Reinhard Beichel, Ronald Boellaard, Michel Bruynooghe, Volker Dicken, Mark J. Gooding, Peter J. Julyan, John Aldo Lee, Sébastien Lefèvre, Michael Mix, Valery Naranjo, Xiaodong Wu, Habib Zaidi, Ziming Zeng, Heikki Minn
2011 J jnl
Comput. Methods Programs Biomed.
Mohammad Saleh Nambakhsh, Alireza Ahmadian, Habib Zaidi
2011 J jnl
Int. J. Biomed. Imaging
Maï Khuong Nguyen, Tuong T. Truong, Marcela A. Morvidone, Habib Zaidi
2010 C conf
ISCAS
Mhd Saeed Sharif, Abbes Amira, Habib Zaidi
2010 B conf
ICIP
Marcela A. Morvidone, Tuong T. Truong, Maï Khuong Nguyen, Habib Zaidi
2010 J jnl
Int. J. Biomed. Imaging
Mhd Saeed Sharif, Maysam F. Abbod, Abbes Amira, Habib Zaidi
2010 C conf
ISCAS
Mhd Saeed Sharif, Abbes Amira, Habib Zaidi
2010 conf
APCCAS
Mhd Saeed Sharif, Maysam F. Abbod, Abbes Amira, Habib Zaidi
2010 J jnl
Int. J. Biomed. Imaging
Marcela A. Morvidone, Maï Khuong Nguyen, Tuong T. Truong, Habib Zaidi
2009 J jnl
Proc. IEEE
Habib Zaidi, Benjamin M. W. Tsui
2007 J jnl
Medical Biol. Eng. Comput.
Habib Zaidi, Mohammad Reza Ay
2007 J jnl
Comput. Medical Imaging Graph.
Marie-Louise Montandon, Habib Zaidi
2007 J jnl
NeuroImage
Habib Zaidi, Marie-Louise Montandon, Steve Meikle
2007 J jnl
Int. J. Biomed. Imaging
Tuong T. Truong, Maï Khuong Nguyen, Habib Zaidi
2006 J jnl
NeuroImage
Habib Zaidi, Torsten Ruest, Frederic Schoenahl, Marie-Louise Montandon
2006 J jnl
Comput. Methods Programs Biomed.
Abdel-Ouahab Boudraa, Jean-Christophe Cexus, Habib Zaidi
2006 J jnl
Comput. Methods Programs Biomed.
Habib Zaidi
2005 J jnl
NeuroImage
Marie-Louise Montandon, Habib Zaidi
2003 J jnl
NeuroImage
Marie-Louise Montandon, Daniel O. Slosman, Habib Zaidi
1999 conf
Bildverarbeitung für die Medizin
Claire Labbé, Kris Thielemans, D. Belluzzo, Valentino Bettinardi, Maria Carla Gilardi, D. S. Hague, Matthew W. Jacobson, S. Kaiser, Roni Levkovitz, T. Margalit, Gautam Mitra, Christian Morel, Terry J. Spinks, Patrick Valente, Habib Zaidi, Alexey Zverovich
1998 J jnl
Parallel Comput.
Habib Zaidi, Claire Labbé, Christian Morel
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"