anchor.diff:  sub_new(Temp) ->
       #sub{t=Temp}.
   
  -%% Folds the sub into a new one if the variables in nodes are not disjoint
  +%% Folds the sub into a new one.
  +%% If the variables are disjoint, it means we can continue reusing
  +%% the patterns collected so far. Otherwise, it means a variable
  +%% was reassigned, so we build a new sub with fresh patterns.
   sub_fold(VarNames, #sub{v=SubNames}=Sub) ->
       case is_disjoint_variables(VarNames, SubNames) of
           true  -> Sub#sub{t={temp,Sub#sub.t}};
           false -> sub_new({sub,Sub})
       end.
   
  -%% Unfolds the sub in case one was folded in the previous step
  +%% Unfolds the sub in case one was folded in the previous step,
  +%% otherwise returns the (root) Sub itself.
  +sub_unfold(#sub{t=none}=Sub) ->
  +    Sub;
   sub_unfold(#sub{t={temp,Temp}}=Sub) ->
       Sub#sub{t=Temp};
   sub_unfold(#sub{t={sub,Sub}}) ->
  
positive.code:     Sub2 = sub_unfold(Sub1#sub{v=V,t=T}),
      {Node#c_clause{pats=Pats1},Sub2};
  
  post(Node, Sub) ->
      {Node,Sub}.
  
  
negative.code: -include("core_parse.hrl").
  
  -define(NOTSET, 0).
  -define(HAS_SUBS(Sub), Sub#sub.t =/= none).
  
  -record(sub, {p=#{} :: #{term() => ?NOTSET | atom()},              %% Found pattern substitutions
                v=cerl_sets:new() :: cerl_sets:set(cerl:var_name()), %% Variables used by patterns
                t=none :: temp()}).                                  %% Temporary information from pre to post
  
  -type sub() :: #sub{}.
  
  %% temp keeps the stack of substitutions.
  %%
  %% 1. none is the root
  %% 2. temp stores the previous temp value - this is used when
  %%    we update the existing sub instead of replacing it
  %% 3. sub is the previous substitution - this is used when
  %%    we replace the current sub
  %% 4. clause is used when there are clauses with patterns
  %%
  -type temp() ::
          none
          | {temp, temp()}
          | {sub, sub()}
          | {clause, [term()], [term()], cerl_sets:set(cerl:var_name()), temp()}.
  
  -spec module(cerl:c_module(), [compile:option()]) ->
          {'ok',cerl:c_module(),[]}.
  