code: def _slice(self):
          
  
          regs = set(self._target_regs)
          tmps = set(self._target_tmps)
          stack_offsets = set(self._target_stack_offsets)
  
          state = SimLightState(regs=regs, temps=tmps, stack_offsets=stack_offsets)
  
          for stmt_idx, stmt in reversed(list(enumerate(self._statements))):
              if self._backward_handler_stmt(stmt, state):
                  self.stmts.insert(0, stmt)
                  self.stmt_indices.insert(0, stmt_idx)
  
                  if self._inslice_callback:
                      self._inslice_callback(stmt_idx, stmt, self.inslice_callback_infodict)
  
              if not regs and not tmps and not stack_offsets:
                  break
  
          self.final_regs = state.regs
          self.final_stack_offsets = state.stack_offsets
docs: Slice it!