anchor.diff:            hibernate = false :: boolean()
           }).
   
  -%% Keep in sync with parse_actions/5 that constructs this record
  -%% from all fields
  --record(trans_opts,
  -        {hibernate = false :: boolean(),
  -         postpone = false :: boolean(),
  -         timeouts_r = [] ::
  -           [{timeout_event_type(),timeout(),TimeoutMsg::term()} |
  -            {timeout_event_type(),timeout()|integer(),TimeoutMsg::term(),
  -             [timeout_option()]}],
  -         next_events_r = [] ::
  -           [{'next_event',event_type(),EventContent::term()}]
  -        }).
  -
   %%%==========================================================================
   %%% API
   
  
positive.code:               ?STACKTRACE(), P, Debug,
                S#state{
                  state_data = State_Data,
                  hibernate = '#trans_opts.hibernate'(TransOpts)},
                Q)
      end.
  
  %% Ensure that Actions are a list
  loop_actions(
    P, Debug, S, Q, NextState_NewData, TransOpts,
    [], CallEnter) ->
      %%
      %% Shortcut for no actions
      case CallEnter andalso P#params.state_enter of
  	true ->
              loop_state_enter(
                P, Debug, S, Q, NextState_NewData, trans_opts(TransOpts));
  	false ->
              loop_state_transition(
                P, Debug, S, Q, NextState_NewData, trans_opts(TransOpts))
      end;
  loop_actions(
    P, Debug, S, Q, NextState_NewData, TransOpts,
    Actions, CallEnter) ->
      %%
      loop_actions_list(
        P, Debug, S, Q, NextState_NewData, TransOpts,
        listify(Actions), CallEnter).
  
  -compile({inline, loop_actions_list/8}).
  %% Process actions from the state function
  loop_actions_list(
    #params{state_enter = StateEnter} = P, Debug, S,
    Q, NextState_NewData, TransOpts,
    Actions, CallEnter) ->
      %%
      case parse_actions(P, Debug, S, Actions, TransOpts) of
          {Debug_1,TransOpts_1}
            when StateEnter, CallEnter ->
              loop_state_enter(
                P, Debug_1, S, Q, NextState_NewData, TransOpts_1);
          {Debug_1,TransOpts_1} ->
              loop_state_transition(
                P, Debug_1, S, Q, NextState_NewData, TransOpts_1);
          [Class,Reason,Stacktrace,Debug_1] ->
              terminate(
                Class, Reason, Stacktrace, P, Debug_1,
                S#state{
                  state_data = NextState_NewData,
                  hibernate = '#trans_opts.hibernate'(TransOpts)},
                Q)
      end.
  
  %%---------------------------------------------------------------------------
  %% The server loop continues after parse_actions
  
  parse_actions(P, Debug, S, Actions, TransOpts) ->
      if
          ?state_call(TransOpts) ->
              %% Inlining of trans_opts/1 for when
              %% ?state_call(TransOpts) is 'true'
              %%
              Hibernate = (#trans_opts{})#trans_opts.hibernate,
              Postpone = (#trans_opts{})#trans_opts.postpone,
              TimeoutsR = (#trans_opts{})#trans_opts.timeouts_r,
              NextEventsR = (#trans_opts{})#trans_opts.next_events_r,
              parse_actions(
                P, Debug, S, Actions, true,
                Hibernate, Postpone, TimeoutsR, NextEventsR);
          true ->
              #trans_opts{
                 hibernate = Hibernate,
                 postpone = Postpone,
                 timeouts_r = TimeoutsR,
                 next_events_r = NextEventsR} = TransOpts,
              parse_actions(
                P, Debug, S, Actions, false,
                Hibernate, Postpone, TimeoutsR, NextEventsR)
      end.
  %%
  parse_actions(
    _P, Debug, _S, [], _StateCall,
    Hibernate, Postpone, TimeoutsR, NextEventsR) ->
      {Debug,
       #trans_opts{
          hibernate = Hibernate,
          postpone = Postpone,
          timeouts_r = TimeoutsR,
          next_events_r = NextEventsR}};
  parse_actions(
    P, Debug, S, [Action|Actions], StateCall,
    Hibernate, Postpone, TimeoutsR, NextEventsR) ->
      case Action of
  	%% Actual actions
  	{reply,From,Reply} ->
              parse_actions_reply(
                P, Debug, S, Actions, StateCall,
                Hibernate, Postpone, TimeoutsR, NextEventsR, From, Reply);
  	%%
  	%% Actions that set options
  	{hibernate,Hibernate_1} when is_boolean(Hibernate_1) ->
              parse_actions(
                P, Debug, S, Actions, StateCall,
                Hibernate_1, Postpone, TimeoutsR, NextEventsR);
  	hibernate ->
              parse_actions(
                P, Debug, S, Actions, StateCall,
                true, Postpone, TimeoutsR, NextEventsR);
  	%%
  	{postpone,Postpone_1} when not Postpone_1 orelse StateCall ->
              parse_actions(
                P, Debug, S, Actions, StateCall,
                Hibernate, Postpone_1, TimeoutsR, NextEventsR);
  	postpone when StateCall ->
              parse_actions(
                P, Debug, S, Actions, StateCall,
                Hibernate, true, TimeoutsR, NextEventsR);
  	postpone ->
              [error,
               {bad_state_enter_action_from_state_function,Action},
               ?STACKTRACE(),
               Debug];
  	%%
  	{next_event,Type,Content} ->
              parse_actions_next_event(
                P, Debug, S, Actions, StateCall,
                Hibernate, Postpone, TimeoutsR, NextEventsR, Type, Content);
  	%%
          Timeout ->
              parse_actions_timeout(
                P, Debug, S, Actions, StateCall,
                Hibernate, Postpone, TimeoutsR, NextEventsR, Timeout)
      end.
  
  parse_actions_reply(
    P, Debug, S, Actions, StateCall,
    Hibernate, Postpone, TimeoutsR, NextEventsR, From, Reply) ->
      %%
      case from(From) of
          true ->
  
negative.code:               ?STACKTRACE(), P, Debug,
                S#state{
                  state_data = State_Data,
                  hibernate = Hibernate},
                Q);
  	{next_state,State,NewData,Actions} ->
              loop_actions(
                P, Debug, S, Q, {State,NewData},
                NextEventsR, Hibernate, TimeoutsR, Postpone,
                false, StateCall, Actions);
  	{next_state,NextState,NewData,Actions}
            when StateCall ->
              loop_actions(
                P, Debug, S, Q, {NextState,NewData},
                NextEventsR, Hibernate, TimeoutsR, Postpone,
                true, StateCall, Actions);
  	{next_state,_NextState,_NewData,_Actions} ->
              terminate(
                error,
  