anchor.diff:      %% FIXME: enum values can be negative, but "raw" varints are positive
       %%        insert a 2-complement in the mapping in order to move computations
       %%        from run-time to compile-time??
  -    [[gpb_codegen:format_fn(
  -        mk_fn(d_enum_, EnumName),
  -        fun('<enum-int-value>') -> '<enum-sym>' end,
  -        [splice_clauses(
  -           '<enum-int-value>',
  -           [gpb_codegen:fn_clause(fun('<i>') -> '<s>' end,
  -                                  [replace_term('<i>', EnumValue),
  -                                   replace_term('<s>', EnumSym)])
  -            || {EnumSym, EnumValue} <- EnumDef])])
  -      "\n\n"]
  +    [gpb_codegen:format_fn(
  +       mk_fn(d_enum_, EnumName),
  +       fun('<enum-int-value>') -> '<enum-sym>' end,
  +       [splice_clauses(
  +          '<enum-int-value>',
  +          [gpb_codegen:fn_clause(fun('<i>') -> '<s>' end,
  +                                 [replace_term('<i>', EnumValue),
  +                                  replace_term('<s>', EnumSym)])
  +           || {EnumSym, EnumValue} <- EnumDef])])
        || {{enum, EnumName}, EnumDef} <- Defs,
           smember({enum,EnumName}, UsedTypes)].
   
  
positive.code:      || MsgName <- MsgNames].
  
  format_msg_merger(MsgName, [], _AnRes) ->
      [gpb_codegen:format_fn(
         mk_fn(merge_msg_, MsgName),
         fun(_Prev, New) -> New end),
       "\n\n"];
  format_msg_merger(MsgName, MsgDef, AnRes) ->
      {PFields, NFields, Mergings} = compute_msg_field_merge_exprs(MsgDef),
      Transforms = [replace_tree('<Prev>', record_match(MsgName, PFields)),
                    replace_tree('<New>', record_match(MsgName, NFields)),
                    replace_tree('<merge>', record_create(MsgName, Mergings))],
      [case occurs_as_optional_submsg(MsgName, AnRes) of
          true ->
               gpb_codegen:format_fn(
                 mk_fn(merge_msg_, MsgName),
                 fun(Prev, undefined)   -> Prev;
                    (undefined, New)    -> New;
                    ('<Prev>', '<New>') -> '<merge>'
                 end,
                 Transforms);
           false ->
               gpb_codegen:format_fn(
                 mk_fn(merge_msg_, MsgName),
                 fun('<Prev>', '<New>') -> '<merge>' end,
                 Transforms)
       end,
       "\n\n"].
  
  compute_msg_field_merge_exprs(MsgDef) ->
      PFields = [{FName, erl_syntax:variable(?ff("PF~s", [FName]))}
  
negative.code:                 DecodeExprs ++ C
          end,
      Body = decode_int_value(FVar, Bindings, FieldDef, Opts, BodyTailFn),
      gpb_codegen:format_fn(
        mk_fn(d_packed_field_, MsgName, FName),
        fun(<<1:1, X:7, Rest/binary>>, N, Acc, AccSeq) ->
                call_self(Rest, N + 7, X bsl N + Acc, AccSeq);
           (<<0:1, X:7, Rest/binary>>, N, Acc, AccSeq) ->
                '<body>';
           (<<>>, 0, 0, AccSeq) ->
                AccSeq
        end,
        [splice_trees('<body>', Body)]).
  
  format_vi_based_field_decoder(MsgName, FieldDef, AnRes, Opts) ->
      #field{name=FName}=FieldDef,
  