Habib Youssef

182 papers A 5B 32C 31Misc 4Journal 51Unranked 54
YearRankTypeTitle / Venue / Authors
2026 J jnl
Clust. Comput.
Islem Chouchene, Hamdi Eltaief, Habib Youssef
2025 J jnl
J. Supercomput.
Nawel Kortas, Habib Youssef
2025 conf
AINA (8)
Ahmed Saidane, Ali El Kamel, Habib Youssef
2025 conf
AINA (1)
Ali El Kamel, Habib Youssef
2025 J jnl
Clust. Comput.
Ahmed Saidane, Ali El Kamel, Habib Youssef
2024 J jnl
Clust. Comput.
Khaoula Braiki, Habib Youssef
2024 B conf
IWCMC
Maroua Moatemri, Hamdi Eltaief, Habib Youssef
2024 J jnl
Clust. Comput.
Fatma Hendaoui, Hamdi Eltaief, Habib Youssef
2024 J jnl
J. Inf. Telecommun.
Hamdi Eltaief, Ali El Kamel, Habib Youssef
2024 J jnl
SN Comput. Sci.
Manel Majdoub, Ali El Kamel, Habib Youssef
2023 C conf
INISTA
Nawel Kortas, Habib Youssef
2023 C conf
INISTA
Ahmed Saidane, Ali El Kamel, Habib Youssef
2023 J jnl
J. Netw. Syst. Manag.
Ramzi Snoussi, Habib Youssef
2022 ed.
WMNC
Habib Youssef, Farouk Kamoun, Mohamed Faten Zhani, Meriem Kassar, Tara Yahia, Marillia Curado, Thi Mai Trang Nguyen
2022 J jnl
Comput. Sci. Rev.
Rihab Chaari, Omar Cheikhrouhou, Anis Koubâa, Habib Youssef, Tuan Nguyen Gia
2022 conf
ISDA (4)
Ali El Kamel, Hamdi Eltaief, Habib Youssef
2022 J jnl
Comput. Commun.
Ali El Kamel, Hamdi Eltaief, Habib Youssef
2022 J jnl
Int. J. Grid Util. Comput.
Nawel Kortas, Habib Youssef
2022 conf
ICCSA (1)
Maroua Moatemri, Hamdi Eltaief, Ali El Kamel, Habib Youssef
2021 J jnl
Internet Things
Abdelwahed Berguiga, Ahlem Harchay, Ayman Massaoudi, Habib Youssef
2021 B conf
WiMob
Rihab Chaari, Omar Cheikhrouhou, Anis Koubâa, Habib Youssef, Habib Hamam
2021 J jnl
Comput. Networks
Fatma Hendaoui, Hamdi Eltaief, Habib Youssef
2020 B conf
AINA
Amel Ben Lazreg, Anis Ben Arbia, Habib Youssef
2020 C conf
HIS
Amna Fekih, Sonia Gaied Fantar, Habib Youssef
2020 conf
ICOIN
Amel Ben Lazreg, Anis Ben Arbia, Habib Youssef
2020 J jnl
J. Interconnect. Networks
Manel Majdoub, Ali El Kamel, Habib Youssef
2020 B conf
AINA
Khaoula Braiki, Habib Youssef
2020 J jnl
J. Supercomput.
Khaoula Braiki, Habib Youssef
2020 J jnl
J. Netw. Syst. Manag.
Ali El Kamel, Habib Youssef
2020 conf
ICIST
Soufiene Ben Othman, Abdullah Ali Bahattab, Abdelbasset Trad, Habib Youssef
2020 J jnl
Int. J. Commun. Syst.
Emna Bouzid Smida, Sonia Gaied Fantar, Habib Youssef
2020 conf
FNC/MobiSPC
Soufiene Ben Othman, Abdullah Ali Bahattab, Abdelbasset Trad, Habib Youssef
2020 C conf
ISDA
Amna Fekih, Sonia Gaied Fantar, Habib Youssef
2020 conf
DiCES-N
Amna Fekih, Sonia Gaied Fantar, Habib Youssef
2020 C conf
ISDA
Amna Fekih, Sonia Gaied Fantar, Habib Youssef
2020 conf
AINA Workshops
Amna Fekih, Sonia Gaied Fantar, Habib Youssef
2019 C conf
ISDA
Manel Majdoub, Ali El Kamel, Habib Youssef
2019 B conf
IWCMC
Nawel Kortas, Habib Youssef
2019 B conf
AINA
Nawel Kortas, Habib Youssef
2019 conf
IINTEC
Soufiene Ben Othman, Abdullah Ali Bahattab, Abdelbasset Trad, Habib Youssef
2019 B conf
IWCMC
Khaoula Braiki, Habib Youssef
2019 conf
GIIS
Manel Majdoub, Ali El Kamel, Habib Youssef
2019 B conf
IWCMC
Rihab Chaari, Omar Cheikhrouhou, Anis Koubâa, Habib Youssef, Habib Hmam
2018 J jnl
Trans. Emerg. Telecommun. Technol.
Fatma Hendaoui, Hamdi Eltaief, Habib Youssef
2018 J jnl
Telecommun. Syst.
Abdelwahed Berguiga, Habib Youssef
2018 C conf
DATA
Amel Ben Lazreg, Dhafer Ben Arbia, Anis Ben Arbia, Habib Youssef
2018 J jnl
Intell. Serv. Robotics
Sahar Trigui, Omar Cheikhrouhou, Anis Koubaa, Anis Zarrad, Habib Youssef
2018 J jnl
Wirel. Pers. Commun.
Amira Ben Ammar, Ali Dziri, Michel Terré, Habib Youssef
2018 conf
ISDA (2)
Emna Bouzid Smida, Sonia Gaied Fantar, Habib Youssef
2018 conf
IDEAL (1)
Hela Maddar, Wafa Kammoun, Habib Youssef
2018 B conf
KES
Hela Maddar, Wafa Kammoun, Habib Youssef
2018 conf
ICCTA
Nawel Kortas, Habib Youssef
2018 conf
ADHOC-NOW
Abdelwahed Berguiga, Ahlem Harchay, Mohamed Kassab, Habib Youssef
2018 Misc conf
SoftCOM
Amira Ben Ammar, Ali Dziri, Michel Terré, Habib Youssef
2018 conf
ISDA (1)
Emna Bouzid Smida, Sonia Gaied Fantar, Habib Youssef
2018 B conf
IWCMC
Khaoula Braiki, Habib Youssef
2018 conf
ICARSC
Imen Châari, Anis Koubaa, Basit Qureshi, Habib Youssef, Ricardo Severino, Eduardo Tovar
2018 conf
SOCA
Amna Fekih, Sonia Gaied Fantar, Habib Youssef
2018 J jnl
Trans. Emerg. Telecommun. Technol.
Nesrine Khelifi, Emmanuel Nataf, Sharief M. A. Oteafy, Habib Youssef
2018 conf
SOCA
Emna Bouzid Smida, Sonia Gaied Fantar, Habib Youssef
2017 conf
MSPN
Ali El Kamel, Manel Majdoub, Habib Youssef
2017 C conf
AICCSA
Ali El Kamel, Manel Majdoub, Habib Youssef
2017 C conf
AICCSA
Fatma Hendaoui, Hamdi Eltaief, Habib Youssef
2017 J jnl
Soft Comput.
Sahar Trigui, Omar Cheikhrouhou, Anis Koubaa, Uthman Baroudi, Habib Youssef
2017 C conf
AICCSA
Abdelwahed Berguiga, Habib Youssef
2017 C conf
AICCSA
Emna Bouzid Smida, Sonia Gaied Fantar, Habib Youssef
2016 conf
ICARSC
Sahar Trigui, Anis Koubâa, Omar Cheikhrouhou, Basit Qureshi, Habib Youssef
2016 C conf
ISDA
Hela Maddar, Wafa Kammoun, Habib Youssef
2016 J jnl
Comput. Networks
Rihab Chaari, Fatma Ellouze, Anis Koubâa, Basit Qureshi, Nuno Pereira, Habib Youssef, Eduardo Tovar
2016 conf
ICMCS
Hajer Gahbiche Msakni, Habib Youssef
2016 J jnl
Ann. des Télécommunications
Ali Lourimi, Boulbaba Thabti, Habib Youssef
2016 J jnl
Int. J. Robotics Autom.
Maram Alajlan, Imen Châari, Anis Koubaa, Hachemi Bennaceur, Adel Ammar, Habib Youssef
2016 C conf
ICISSP
Hela Maddar, Wafa Kammoun, Omar Cheikhrouhou, Habib Youssef
2016 J jnl
Trans. Emerg. Telecommun. Technol.
Soufiene Ben Othman, Abdullah Ali Bahattab, Abdelbasset Trad, Habib Youssef
2016 B conf
IWCMC
Amira Ben Ammar, Ali Dziri, Michel Terré, Habib Youssef
2016 C conf
ISDA
Hela Maddar, Wafa Kammoun, Habib Youssef
2015 J jnl
Wirel. Pers. Commun.
Soufiene Ben Othman, Abdullah Ali Bahattab, Abdelbasset Trad, Habib Youssef
2015 J jnl
Int. J. Space Based Situated Comput.
Wafa Ben Jaballah, Mohamed Mosbah, Habib Youssef, Akka Zemmari
2015 conf
NETYS
Sonia Gaied Fantar, Habib Youssef
2015 B conf
IWCMC
Amira Ben Ammar, Olfa Bouattay, Ali Dziri, Michel Terré, Habib Youssef
2015 B conf
IWCMC
Nesrine Khelifi, Sharief M. A. Oteafy, Hossam S. Hassanein, Habib Youssef
2015 conf
Nets4Cars/Nets4Trains/Nets4Aircraft
Sofiene Jelassi, Amna Bouzid, Habib Youssef
2015 J jnl
Ad Hoc Networks
Nouha Baccour, Anis Koubâa, Habib Youssef, Mário Alves
2014 conf
ANT/SEIT
Sahar Trigui, Anis Koubâa, Omar Cheikhrouhou, Habib Youssef, Hachemi Bennaceur, Mohamed-Foued Sriti, Yasir Javed
2014 conf
HPCC/CSS/ICESS
Fatma Hendaoui, Hamdi Eltaief, Habib Youssef, Abdelbasset Trad
2014 B conf
IWCMC
Nesrine Khelifi, Wafa Kammoun, Habib Youssef
2014 conf
ANT/SEIT
Imen Châari, Anis Koubâa, Hachemi Bennaceur, Adel Ammar, Sahar Trigui, Mohamed Tounsi, Elhadi M. Shakshuki, Habib Youssef
2014 B conf
AINA
Soufiene Ben Othman, Abdullah Ali Bahattab, Abdelbasset Trad, Habib Youssef
2014 B conf
IWCMC
Soufiene Ben Othman, Abdelbasset Trad, Habib Youssef
2014 Misc conf
ICNC
Boulbaba Thabti, Habib Youssef, Ali Ridha Mahjoub, Aref Meddeb
2013 C conf
AICCSA
Ali El Kamel, Habib Youssef
2013 C conf
HIS
Ali El Kamel, Hamdi Eltaief, Habib Youssef
2013 C conf
IAS
Hamdi Eltaief, Ali El Kamel, Habib Youssef
2013 conf
IISA
Soufiene Ben Othman, Hani Alzaid, Abdelbasset Trad, Habib Youssef
2013 J jnl
Comput. Networks
Ibrahima Diarrassouba, Ali Lourimi, Ali Ridha Mahjoub, Habib Youssef
2013 B conf
IWCMC
Hajer Gahbiche Msakni, Habib Youssef
2013 B conf
AINA
Wafa Ben Jaballah, Mohamed Mosbah, Habib Youssef, Akka Zemmari
2013 conf
PerCom Workshops
Wafa Ben Jaballah, Mohamed Mosbah, Habib Youssef
2013 book
Nouha Baccour, Anis Koubaa, Claro Noda, Hossein Fotouhi, Mário Alves, Habib Youssef, Marco Zuniga, Carlo Alberto Boano, Kay Römer, Daniele Puccinelli, Thiemo Voigt, Luca Mottola
2013 conf
TrustCom/ISPA/IUCC
Soufiene Ben Othman, Abdelbasset Trad, Habib Youssef, Hani Alzaid
2013 conf
Med-Hoc-Net
Soufiene Ben Othman, Abdelbasset Trad, Habib Youssef, Hani Alzaid
2012 C conf
PDP
Ali El Kamel, Habib Youssef
2012 J jnl
CoRR
Radhouane Boughammoura, Mohamed Nazih Omri, Habib Youssef
2012 conf
MOBIWAC
Abdelwahed Berguiga, Habib Youssef
2012 B conf
IWCMC
Wafa Berrayana, Habib Youssef, Guy Pujolle
2012 J jnl
CoRR
Amen Ajroud, Mohamed Nazih Omri, Habib Youssef, Salem Benferhat
2012 conf
MobiHealth
Soufiene Ben Othman, Abdelbasset Trad, Hani Alzaid, Habib Youssef
2012 conf
HPCC-ICESS
Hajer Gahbiche Msakni, Habib Youssef
2012 J jnl
IEEE Commun. Surv. Tutorials
Sofiene Jelassi, Gerardo Rubino, Hugh Melvin, Habib Youssef, Guy Pujolle
2012 J jnl
ACM Trans. Sens. Networks
Nouha Baccour, Anis Koubaa, Luca Mottola, Marco Antonio Zúñiga Zamalloa, Habib Youssef, Carlo Alberto Boano, Mário Alves
2012 J jnl
Telecommun. Syst.
Sofiene Jelassi, Habib Youssef, Christian Hoene, Guy Pujolle
2011 J jnl
Pers. Ubiquitous Comput.
Mohamed Aissa, Adel Ben Mnaouer, Rion Murray, Habib Youssef, Abdelfettah Belghith
2011 conf
NOTERE
Sonia Gaied Fantar, Habib Youssef
2011 Misc conf
ICNC
Boulbaba Thabti, Habib Youssef, Aref Meddeb, Ali Ridha Mahjoub
2011 J jnl
J. Commun.
Manel Boujelben, Habib Youssef, Rania Mzid, Mohamed Abid
2011 J jnl
Ad Hoc Networks
Nouha Baccour, Anis Koubaa, Maissa Ben Jamâa, Denis do Rosário, Habib Youssef, Mário Alves, Leandro Buss Becker
2010 conf
ICWUS
Mohamed Aissa, Adel Ben Mnaouer, Habib Youssef, Abdelfettah Belghith
2010 C conf
AICCSA
Nouha Baccour, Maissa Ben Jamâa, Denis do Rosário, Anis Koubaa, Habib Youssef, Mário Alves, Leandro Buss Becker
2010 conf
ICWUS
Rania Mzid, Manel Boujelben, Habib Youssef, Mohamed Abid
2010 J jnl
Int. J. Commun. Syst.
S. Messaoud, Habib Youssef
2010 C conf
AICCSA
Wafa Ben Jaballah, Aref Meddeb, Habib Youssef
2010 conf
Med-Hoc-Net
Wafa Berrayana, Habib Youssef, Rami Langar, Guy Pujolle
2010 C conf
AICCSA
Hamdi Eltaief, Habib Youssef
2010 J jnl
Ann. des Télécommunications
Wafa Kammoun, Habib Youssef
2010 C conf
ISCC
Sonia Gaied Fantar, Habib Youssef
2010 B conf
EWSN
Nouha Baccour, Anis Koubaa, Habib Youssef, Maissa Ben Jamâa, Denis do Rosário, Mário Alves, Leandro Buss Becker
2010 conf
Web Intelligence
Saloua Messaoud Abid, Habib Youssef
2010 B conf
LCN
Hamdi Eltaief, Habib Youssef
2009 B conf
MASCOTS
Nouha Baccour, Anis Koubaa, Maissa Ben Jamâa, Habib Youssef, Marco Zuniga, Mário Alves
2009 C conf
ISCC
Ali El Kamel, Habib Youssef
2009 C conf
ISCC
Aref Meddeb, Enis Elgueder, Issam Harrathi, Habib Youssef
2009 B conf
LCN
Aref Meddeb, Abdelwahed Berguiga, Habib Youssef
2009 conf
GSN
Sonia Gaied Fantar, Habib Youssef
2009 C conf
ISCC
Wafa Kammoun, Habib Youssef
2009 J jnl
Int. J. Commun. Syst.
Hamdi Eltaief, Habib Youssef
2009 conf
MMNS
Sofiene Jelassi, Habib Youssef, Lingfen Sun, Guy Pujolle
2009 Misc conf
FLAIRS
Amen Ajroud, Salem Benferhat, Mohamed Nazih Omri, Habib Youssef
2009 C conf
ISCC
Aref Meddeb, Abdelwahed Berguiga, Habib Youssef
2009 B conf
LCN
Sofiene Jelassi, Habib Youssef, Guy Pujolle
2009 B conf
IWCMC
Wafa Berrayana, Guy Pujolle, Habib Youssef
2008 conf
Wireless Days
Wafa Berrayana, Habib Youssef, Stéphane Lohier, Guy Pujolle
2008 J jnl
Comput. Networks
Sofiene Jelassi, Habib Youssef
2008 conf
ICEIS (2)
Amen Ajroud, Mohamed Nazih Omri, Salem Benferhat, Habib Youssef
2008 B conf
WiMob
Manel Boujelben, Habib Youssef, Mohamed Abid
2008 conf
NTMS
Sofiene Jelassi, Habib Youssef
2008 C conf
QSHINE
Sofiene Jelassi, Habib Youssef
2008 C conf
ISCC
Wafa Kammoun, Habib Youssef
2007 A conf
MSWiM
Sofiene Jelassi, Habib Youssef
2007 B conf
MASS
Sofiene Jelassi, Habib Youssef
2006 B conf
IWCMC
Sofiene Jelassi, Habib Youssef
2006 A conf
CoNEXT
Wafa Berrayana, Habib Youssef, Stéphane Lohier, Guy Pujolle
2005 conf
ICECS
Wafa Kammoun, Habib Youssef
2003 J jnl
J. Comb. Optim.
Eugene Shragowitz, Habib Youssef, Bing Lu
2003 A conf
IPDPS
Ahmad A. Al-Yamani, Sadiq M. Sait, Hassan R. Barada, Habib Youssef
2002 conf
International Conference on Internet Computing
Muhammad Atif Tahir, Habib Youssef, Abdulaziz Al-Mulhem, Sadiq M. Sait
2002 conf
ISPD
H. Chang, Eugene Shragowitz, Jian Liu, Habib Youssef, Bing Lu, Suphachai Sutanthavibul
2002 J jnl
J. Heuristics
Ahmad A. Al-Yamani, Sadiq M. Sait, Habib Youssef, Hassan R. Barada
2002 J jnl
Comput. Commun.
Habib Youssef, Abdulaziz Al-Mulhem, Sadiq M. Sait, Muhammad Atif Tahir
2001 conf
ISCAS (5)
Habib Youssef, Sadiq M. Sait, Hussain Ali
2001 C conf
ICCD
Sadiq M. Sait, Habib Youssef, Junaid A. Khan, Aiman H. El-Maleh
2001 C conf
EMO
Habib Youssef, Sadiq M. Sait, Salman A. Khan
2001 J jnl
Int. J. Commun. Syst.
Mayez A. Al-Mouhamed, Mohammad Kaleemuddin, Habib Youssef
2000 C conf
ISCAS
Sadiq M. Sait, Habib Youssef, Hassan R. Barada, Ahmad A. Al-Yamani
2000 B conf
CEC
Habib Youssef, Sadiq M. Sait, Salman A. Khan
1999 J jnl
IEEE/ACM Trans. Netw.
Mayez A. Al-Mouhamed, Mohammad Kaleemuddin, Habib Youssef
1999 B conf
CEC
Sadiq M. Sait, Habib Youssef, Hussain Ali
1999 book
Iterative computer algorithms with applications in engineering - solving combinatorial optimization problems.
Sadiq M. Sait, Habib Youssef
1999 book
Sadiq M. Sait, Habib Youssef
1998 B conf
LCN
Khalid Al-Tawil, Ali Akrami, Habib Youssef
1998 B conf
ICCCN
Mayez A. Al-Mouhamed, Habib Youssef, Wasif Hasan
1998 J jnl
Int. J. Commun. Syst.
Mayez A. Al-Mouhamed, Habib Youssef, Wasif Hasan
1998 J jnl
Int. J. Commun. Syst.
Mostafa I. H. Abd-El-Barr, Khalid Al-Tawil, Habib Youssef, Talha Al-Jarad
1998 conf
Great Lakes Symposium on VLSI
Ahmad S. Al-Mulhem, Alaaeldin Amin, Habib Youssef
1998 conf
Great Lakes Symposium on VLSI
Sadiq M. Sait, Habib Youssef, Munir M. Zahra
1995 conf
Great Lakes Symposium on VLSI
Habib Youssef, Sadiq M. Sait, Khaled Nassar, Muhammad S. T. Benten
1995 conf
EURO-DAC
Habib Youssef, Sadiq M. Sait, Khalid J. Al-Farra
1995 conf
ASP-DAC
Sadiq M. Sait, Habib Youssef, Shahid K. Tanvir, Muhammad S. T. Benten
1995 book
VLSI physical design automation - theory and practice.
Sadiq M. Sait, Habib Youssef
1992 J jnl
Comput. Aided Des.
Habib Youssef, Eugene Shragowitz, Suphachai Sutanthavibul
1991 conf
VLSI
Habib Youssef, Rung-Bin Lin, Eugene Shragowitz
1990 A conf
ICCAD
Habib Youssef, Eugene Shragowitz
1989 A conf
ICCAD
Habib Youssef, Eugene Shragowitz, Lionel Bening
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"