anchor.diff:  %%%----------------------------------------------------------------------
   %%% Records
   %%%----------------------------------------------------------------------
  -
  -%% Scheduler state
  -%%
  -%% active  : A set containing all processes ready to be scheduled.
  -%% blocked : A set containing all processes that cannot be scheduled next
  -%%          (e.g. waiting for a message on a `receive`).
  -%% current : The LID of the currently running or last run process.
  -%% actions : The actions performed (concuerror_proc_action:proc_action()).
  -%% error   : A term describing the error that occurred.
  -%% state   : The current state of the program.
  --record(context, {active         :: ?SET_TYPE(concuerror_lid:lid()),
  -                  blocked        :: ?SET_TYPE(concuerror_lid:lid()),
  -                  current        :: concuerror_lid:lid(),
  -                  actions        :: [concuerror_proc_action:proc_action()],
  -                  error          :: ?NO_ERROR | concuerror_error:error(),
  -                  state          :: concuerror_state:state()}).
   
   
   %% 'next' messages are about next instrumented instruction not yet dispatched
  
positive.code: %% Produce all possible process interleavings of (Mod, Fun, Args).
  interleave(Target, PreBound, Dpor) ->
      Self = self(),
      spawn_link(fun() -> interleave_dpor(Target, PreBound, Self, Dpor) end),
      receive
          {interleave_result, Result} -> Result
      end.
  
  interleave_aux(Target, PreBound, Parent) ->
      register(?RP_SCHED, self()),
      %% The mailbox is flushed mainly to discard possible `exit` messages
      %% before enabling the `trap_exit` flag.
      concuerror_util:flush_mailbox(),
      process_flag(trap_exit, true),
      %% Initialize state table.
      state_start(),
      %% Save empty replay state for the first run.
      InitState = concuerror_state:empty(),
      state_save([InitState]),
      Result = interleave_outer_loop(Target, 0, [], -1, PreBound),
      state_stop(),
      unregister(?RP_SCHED),
      Parent ! {interleave_result, Result}.
  
  interleave_dpor(Target, PreBound, Parent, Dpor) ->
      ?f_debug("Dpor is not really ready yet...\n"),
      register(?RP_SCHED, self()),
      Result = interleave_dpor(Target, PreBound, Dpor),
      ?stop_debug,
      Parent ! {interleave_result, Result}.
  
  interleave_outer_loop(_T, RunCnt, Tickets, MaxBound, MaxBound) ->
      interleave_outer_loop_ret(Tickets, RunCnt);
  interleave_outer_loop(Target, RunCnt, Tickets, CurrBound, MaxBound) ->
      {NewRunCnt, TotalTickets, Stop} = interleave_loop(Target, 1, Tickets),
      TotalRunCnt = NewRunCnt + RunCnt,
      state_swap(),
      case state_peak() of
          no_state -> interleave_outer_loop_ret(TotalTickets, TotalRunCnt);
          _State ->
              case Stop of
                  true -> interleave_outer_loop_ret(TotalTickets, TotalRunCnt);
                  false ->
                      interleave_outer_loop(Target, TotalRunCnt, TotalTickets,
                                            CurrBound + 1, MaxBound)
              end
      end.
  
  interleave_outer_loop_ret([], RunCnt) ->
      {ok, RunCnt};
  interleave_outer_loop_ret(Tickets, RunCnt) ->
      {error, RunCnt, Tickets}.
  
  %%------------------------------------------------------------------------------
  
  -type s_i()        :: non_neg_integer().
  -type instr()      :: term().
  
negative.code:         Tickets -> {error, RunCnt, Tickets}
      end.
  
  %%%----------------------------------------------------------------------
  %%% Helper functions
  %%%----------------------------------------------------------------------
  