Extract the composite array's data into a usable bitarray based on if NoCare bits should be rendered as True or False.

        This method does the heavy lifting of producing a bitarray
        that is more efficient for tdo bits when that optimization is
        available.

        KWArgs:
            primef: A contracts.Requirement capability of the associated primitive.
            reqef: A contracts.Requirement (generated from primitive compilation) describing the signal requirements of the data in this CompositeBitarray.

        Returns:
            A bitarray (CompositeBitarray, ConstantBitarray, etc) that
            is the combined result of all the composite bitarray's
            components. If this CompositeBitarray's backing linked
            list can be merged into a single node, that single node is
            returned. Otherwise, this CompositeBitarray is returned.

def prepare(self, *, primef, reqef):
        """Extract the composite array's data into a usable bitarray based on if NoCare bits should be rendered as True or False.

        This method does the heavy lifting of producing a bitarray
        that is more efficient for tdo bits when that optimization is
        available.

        KWArgs:
            primef: A contracts.Requirement capability of the associated primitive.
            reqef: A contracts.Requirement (generated from primitive compilation) describing the signal requirements of the data in this CompositeBitarray.

        Returns:
            A bitarray (CompositeBitarray, ConstantBitarray, etc) that
            is the combined result of all the composite bitarray's
            components. If this CompositeBitarray's backing linked
            list can be merged into a single node, that single node is
            returned. Otherwise, this CompositeBitarray is returned.

        """
        #TODO remove bitarray copies!
        if not primef.satisfies(reqef):
            raise Exception("Compiler error. Requested effect can not be "
                            "satisfied by primitive capabilities")
        assertPreferFalse = reqef == ZERO or primef == ARBITRARY or\
                            (reqef == NOCARE and primef == ZERO)
        testBitarrayFalse = reqef==ZERO or\
                            (reqef==NOCARE and primef==ZERO)
        testBitarrayTrue = reqef==ONE or (reqef==NOCARE and primef==ONE)
        assert not (testBitarrayTrue and testBitarrayFalse)

        #print("DATA", self)
        #print("ORIG", ["%s(%s:%s)"%
        #       (type(elem.value).__name__,
        #        elem.value._val if isinstance(elem.value,
        #                                      ConstantBitarray)\
        #        else "_", len(elem.value))
        #       for elem in self._llhead.iternexttill(self._lltail)])

        if self._offset or self._tailoffset:
            if self._is_single_llnode:
                if isinstance(self._llhead.value, (ConstantBitarray,
                                             NoCareBitarray,
                                             PreferFalseBitarray)):
                    oldnode = self._llhead
                    if self._offset == 0:
                        oldnode.prev = None
                    if self._tailoffset == 0:
                        oldnode.next = None
                    self._llhead = _DLLNode(
                        oldnode.value[self._offset:\
                                      self._offset+self._tailbitsused])
                    self._lltail = self._llhead
                    self._offset = 0
                    self._tailbitsused = self._taillen

                elif isinstance(self._llhead.value, bitarray):
                    if testBitarrayFalse or testBitarrayTrue:
                        oldnode = self._llhead
                        newval = oldnode.value[self._offset:
                                               self._offset+self._tailbitsused]
                        if testBitarrayFalse:
                            if not newval.any():
                                newval = ConstantBitarray(False, len(newval))
                            else:
                                raise Exception("bitarray in data contains a 1")
                        if testBitarrayTrue:
                            if newval.all():
                                newval = ConstantBitarray(True, len(newval))
                            else:
                                raise Exception("bitarray in data contains a 0")

                        self._llhead = _DLLNode(newval)
                        self._lltail = self._llhead
                        self._offset = 0
                        self._tailbitsused = self._taillen

            else: #IF HEAD IS NOT TAIL; OFFSET OR TAILOFFSET
                if self._offset:
                    if isinstance(self._llhead.value,
                                  (ConstantBitarray, NoCareBitarray,
                                   PreferFalseBitarray)):
                        oldhead = self._llhead
                        self._llhead = _DLLNode(
                            oldhead.value[self._offset:])
                        self._llhead.next = oldhead.next
                        oldhead.next = None
                        self._offset = 0
                    elif isinstance(self._llhead.value, bitarray):
                        oldhead = self._llhead
                        newval = oldhead.value[self._offset:]
                        if testBitarrayFalse:
                            if not newval.any():
                                newval = ConstantBitarray(False, len(newval))
                            else:
                                raise Exception("bitarray in data contains a 1")
                        if testBitarrayTrue:
                            if newval.all():
                                newval = ConstantBitarray(True, len(newval))
                            else:
                                raise Exception("bitarray in data contains a 0")

                        self._llhead = _DLLNode(newval)
                        self._llhead.next = oldhead.next
                        oldhead.next = None
                        self._offset = 0

                if self._tailoffset:#IF HEAD IS NOT TAIL AND TAILOFFSET
                    if isinstance(self._lltail.value,
                                  (ConstantBitarray, NoCareBitarray,
                                   PreferFalseBitarray)):
                        oldtail = self._lltail
                        self._lltail = _DLLNode(
                            oldtail.value[:self._tailbitsused])
                        self._lltail.prev = oldtail.prev
                        oldtail.prev = None
                        self._tailbitsused = self._taillen
                    elif isinstance(self._lltail.value, bitarray):
                        oldtail = self._lltail
                        newval = oldtail.value[:self._tailbitsused]
                        if testBitarrayFalse:
                            if not newval.any():
                                newval = ConstantBitarray(False, len(newval))
                            else:
                                raise Exception("bitarray in data contains a 1")
                        if testBitarrayTrue:
                            if newval.all():
                                newval = ConstantBitarray(True, len(newval))
                            else:
                                raise Exception("bitarray in data contains a 0")

                        self._lltail = _DLLNode(newval)
                        self._lltail.prev = oldtail.prev
                        oldtail.prev = None
                        self._tailbitsused = self._taillen


        for elem in self._llhead.iternexttill(self._lltail):
            if isinstance(elem.value, PreferFalseBitarray):
                if assertPreferFalse:
                    elem._value = ConstantBitarray(False, len(elem.value))
                else:
                    elem._value = NoCareBitarray(len(elem.value))
            if isinstance(elem.value, bitarray):
                if testBitarrayFalse:
                    if not elem.value.any():
                        elem.value = ConstantBitarray(False,
                                                      len(elem.value))
                    else:
                        raise Exception("bitarray in data contains a 1")
                if testBitarrayTrue:
                    if elem.value.all():
                        elem.value = ConstantBitarray(True,
                                                      len(elem.value))
                    else:
                        raise Exception("bitarray in data contains a 0")


        #print("TRAN", ["%s(%s:%s)"%
        #       (type(elem.value).__name__,
        #        elem.value._val if isinstance(elem.value,
        #                                      ConstantBitarray)\
        #        else "_", len(elem.value))
        #       for elem in self._llhead.iternexttill(self._lltail)])



        if not self._is_single_llnode and\
           (self._lltail.next is not self._llhead or\
            (self._offset == 0 and self._tailbitsused == self._taillen)
            ):
            self._do_merge(stoponfail=False)

        #print("\033[1mPOST", "+ ".join(["%s%s(%s:%s)\033[0m"%
        #       ('\033[91m' if isinstance(elem.value, bitarray) else
        #        ('\033[94m' if isinstance(elem.value,
        #                            (NoCareBitarray, PreferFalseBitarray))
        #         else '\033[92m'),type(elem.value).__name__,
        #        elem.value._val if isinstance(elem.value,
        #                                      ConstantBitarray)\
        #        else (elem.value.to01() if isinstance(elem.value,
        #                                              bitarray)
        #              else "_"), len(elem.value))
        #       for elem in self._llhead.iternexttill(self._lltail)]))
        if self._is_single_llnode and self._offset == 0 and\
           self._tailbitsused == self._taillen:
            if isinstance(self._llhead.value, (NoCareBitarray,
                                               PreferFalseBitarray)):
                return ConstantBitarray(False, len(self._llhead.value))
            return self._llhead.value
        return self