def _find_candidate_bbs(self, start_address, end_address, mode=BARF_DISASM_RECURSIVE, symbols=None):
        if not symbols:
            symbols = {}

        bbs = []

        addrs_to_process = Queue()
        addrs_processed = set()

        addrs_to_process.put(start_address)

        while not addrs_to_process.empty():
            addr_curr = addrs_to_process.get()

            # Skip current address if:
            #   a. it has already been processed or
            #   b. it is not within range ([start_address, end_address]) or
            if  addr_curr in addrs_processed or \
                not (addr_curr >= start_address and addr_curr <= end_address):
                continue

            bb = self._disassemble_bb(addr_curr, end_address + 0x1, symbols)

            if bb.empty():
                continue

            # Add new basic block to the list.
            bbs += [bb]

            # Add current address to the list of processed addresses.
            addrs_processed.add(addr_curr)

            # Linear sweep mode: add next address to process queue.
            if mode == BARF_DISASM_LINEAR:
                next_addr = bb.address + bb.size

                if  not self._bb_ends_in_direct_jmp(bb) and \
                    not self._bb_ends_in_return(bb) and \
                    not next_addr in addrs_processed:
                    addrs_to_process.put(next_addr)

            # Recursive descent mode: add branches to process queue.
            if mode == BARF_DISASM_RECURSIVE:
                for addr, _ in bb.branches:
                    if not addr in addrs_processed:
                        addrs_to_process.put(addr)

        return bbs
dataset/ETHPy150Open programa-stic/barf-project/barf/barf/analysis/basicblock/basicblock.py/BasicBlockBuilder._find_candidate_bbs/original