anchor.diff:  -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=undefined :: term()}).                             %% Temporary information from pre to post
  +              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(),[]}.
  
positive.code: def({#c_var{name={F,Arity}}=Name,B0}) ->
      try
          put(new_var_num, 0),
          {B1,_} = cerl_trees:mapfold(fun pre/2, fun post/2, sub_new(undefined), B0),
          erase(new_var_num),
          {Name,B1}
      catch
  
negative.code: sub_new(Temp) ->
      #sub{t=Temp}.
  
  %% 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,
  %% 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}}) ->
  