/*
** Automatically generated from `canonical.m'
** by the Mercury compiler,
** version 22.01.9-beta-2026-08-29
** configured for x86_64-pc-linux-gnu.
** Do not edit.
**
** The autoconfigured grade settings governing
** the generation of this C file were
**
** TAG_BITS=2
** UNBOXED_FLOAT=no
** UNBOXED_INT64S=no
** PREGENERATED_DIST=yes
** HIGHLEVEL_CODE=yes
**
** END_OF_C_GRADE_INFO
*/


// :- module canonical.
// :- implementation.

/*
INIT mercury__canonical__init
ENDINIT
*/

#include "canonical.mih"


#include "array.mih"
#include "array_util.mih"
#include "assoc_list.mih"
#include "bimap.mih"
#include "bitmap.mih"
#include "bool.mih"
#include "builtin.mih"
#include "callgraph.mih"
#include "char.mih"
#include "construct.mih"
#include "deconstruct.mih"
#include "enum.mih"
#include "exclude.mih"
#include "int.mih"
#include "io.mih"
#include "list.mih"
#include "map.mih"
#include "maybe.mih"
#include "mdbcomp.mih"
#include "measurement_units.mih"
#include "measurements.mih"
#include "ops.mih"
#include "pair.mih"
#include "pretty_printer.mih"
#include "private_builtin.mih"
#include "profile.mih"
#include "random.mih"
#include "require.mih"
#include "set.mih"
#include "set_ordlist.mih"
#include "stream.mih"
#include "string.mih"
#include "term.mih"
#include "time.mih"
#include "tree234.mih"
#include "type_desc.mih"
#include "unit.mih"
#include "univ.mih"
#include "mdbcomp.feedback.mih"
#include "mdbcomp.goal_path.mih"
#include "mdbcomp.program_representation.mih"
#include "mdbcomp.feedback.automatic_parallelism.mih"




static const MR_FA_PseudoTypeInfo_Struct1 canonical__list__pti_list_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0;

static const MR_FA_PseudoTypeInfo_Struct1 canonical__set_ordlist__pti_set_ordlist_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0;

static const MR_FA_TypeInfo_Struct1 canonical__list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0;

static const MR_FA_PseudoTypeInfo_Struct2 canonical__pair__pti_pair_2__plain_profile__type_ctor_info_proc_static_ptr_0__plain_list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0;

static const MR_FA_PseudoTypeInfo_Struct2 canonical__tree234__pti_tree234_2__plain_profile__type_ctor_info_proc_static_ptr_0__plain_list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0;

static const MR_FA_PseudoTypeInfo_Struct1 canonical__array__pti_array_1__plain_profile__type_ctor_info_call_site_dynamic_0;

static const MR_FA_PseudoTypeInfo_Struct1 canonical__array__pti_array_1__plain_profile__type_ctor_info_call_site_array_slot_0;

static const MR_FA_PseudoTypeInfo_Struct1 canonical__array__pti_array_1__plain_profile__type_ctor_info_proc_dynamic_0;

static const MR_FA_PseudoTypeInfo_Struct1 canonical__list__pti_list_1__plain_profile__type_ctor_info_call_site_dynamic_ptr_0;

static const MR_FA_TypeInfo_Struct1 canonical__list__ti_list_1profile__type_ctor_info_call_site_dynamic_ptr_0;

static const MR_FA_PseudoTypeInfo_Struct2 canonical__tree234__pti_tree234_2__plain_profile__type_ctor_info_proc_static_ptr_0__plain_list__ti_list_1profile__type_ctor_info_call_site_dynamic_ptr_0;

static const MR_FA_PseudoTypeInfo_Struct1 canonical__array__pti_array_1__plain_profile__type_ctor_info_call_site_dynamic_ptr_0;

static const MR_FA_TypeInfo_Struct1 canonical__array__ti_array_1list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0;

static const MR_FA_TypeInfo_Struct1 canonical__array__ti_array_1profile__type_ctor_info_clique_ptr_0;

static const MR_PseudoTypeInfo canonical__canonical__field_types_merge_info_0_0[2];

static const MR_ConstString canonical__canonical__field_names_merge_info_0_0[2];

static const MR_DuFunctorDesc canonical__canonical__du_functor_desc_merge_info_0_0;

static const MR_DuFunctorDescPtr canonical__canonical__du_stag_ordered_merge_info_0_0[1];

static const MR_DuPtagLayout canonical__canonical__du_ptag_ordered_merge_info_0[1];

static const MR_DuFunctorDescPtr canonical__canonical__du_name_ordered_merge_info_0[1];

static const MR_Integer canonical__canonical__functor_number_map_merge_info_0[1];

static const MR_FA_TypeInfo_Struct1 canonical__array__ti_array_1profile__type_ctor_info_call_site_dynamic_ptr_0;

static const MR_FA_TypeInfo_Struct1 canonical__array__ti_array_1profile__type_ctor_info_proc_dynamic_ptr_0;

static const MR_PseudoTypeInfo canonical__canonical__field_types_redirect_0_0[2];

static const MR_ConstString canonical__canonical__field_names_redirect_0_0[2];

static const MR_DuFunctorDesc canonical__canonical__du_functor_desc_redirect_0_0;

static const MR_DuFunctorDescPtr canonical__canonical__du_stag_ordered_redirect_0_0[1];

static const MR_DuPtagLayout canonical__canonical__du_ptag_ordered_redirect_0[1];

static const MR_DuFunctorDescPtr canonical__canonical__du_name_ordered_redirect_0[1];

static const MR_Integer canonical__canonical__functor_number_map_redirect_0[1];

static MR_bool MR_CALL 
canonical__IntroducedFrom__pred__merge_call_site_dynamics_2__420__1_2_p_0(
  MR_Word InClique_17,
  MR_Word HeadVar__2_43);

static MR_bool MR_CALL 
canonical__IntroducedFrom__pred__merge_call_site_dynamics_2__415__1_2_p_0(
  MR_Word NotInClique_18,
  MR_Word HeadVar__2_38);

static MR_bool MR_CALL 
canonical__IntroducedFrom__pred__merge_proc_dynamics__241__1_2_p_0(
  MR_Word InvalidPDPtrs_17,
  MR_Word HeadVar__2_36);

static void MR_CALL 
canonical__IntroducedFrom__pred__complete_clique__130__1_3_p_0(
  MR_Word HeadVar__1_22,
  MR_Word HeadVar__2_23,
  MR_Word * HeadVar__3_24);

static void MR_CALL 
canonical____Compare____redirect_0_0(
  MR_Word * HeadVar__1_1,
  MR_Word HeadVar__2_2,
  MR_Word HeadVar__3_3);

static MR_bool MR_CALL 
canonical____Unify____redirect_0_0(
  MR_Word HeadVar__1_1,
  MR_Word HeadVar__2_2);

static void MR_CALL 
canonical____Compare____merge_info_0_0(
  MR_Word * HeadVar__1_1,
  MR_Word HeadVar__2_2,
  MR_Word HeadVar__3_3);

static MR_bool MR_CALL 
canonical____Unify____merge_info_0_0(
  MR_Word HeadVar__1_1,
  MR_Word HeadVar__2_2);

static void MR_CALL 
canonical__subst_in_slot_3_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2);

static void MR_CALL 
canonical__subst_in_slot_3_p_0(
  MR_Word Redirect_1,
  MR_Word HeadVar__2_2,
  MR_Word * HeadVar__3_3);

static void MR_CALL 
canonical__subst_in_proc_dynamic_3_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2);

static void MR_CALL 
canonical__subst_in_proc_dynamic_3_p_0(
  MR_Word Redirect_4,
  MR_Word STATE_VARIABLE_PD_0_10,
  MR_Word * STATE_VARIABLE_PD_11);

static void MR_CALL 
canonical__subst_in_call_site_dynamic_3_p_0(
  MR_Word Redirect_4,
  MR_Word STATE_VARIABLE_CSD_0_11,
  MR_Word * STATE_VARIABLE_CSD_12);

static void MR_CALL 
canonical__lookup_csd_redirect_3_p_0(
  MR_ArrayPtr CallSiteRedirect0_4,
  MR_Word CSDPtr_5,
  MR_Word * OldRedirect_6);

static void MR_CALL 
canonical__cluster_csds_by_ps_4_p_0(
  MR_Word InitDeep_5,
  MR_Word CSDPtr_6,
  MR_Word STATE_VARIABLE_ProcMap_0_15,
  MR_Word * STATE_VARIABLE_ProcMap_16);

static void MR_CALL 
canonical__cluster_pds_by_ps_4_p_0(
  MR_Word InitDeep_5,
  MR_Word PDPtr_6,
  MR_Word STATE_VARIABLE_ProcMap_0_12,
  MR_Word * STATE_VARIABLE_ProcMap_13);

static MR_bool MR_CALL 
canonical__two_or_more_1_p_0(
  MR_Word HeadVar__1_1);

static void MR_CALL 
canonical__union_cliques_4_p_0(
  MR_Word MergeInfo_5,
  MR_Word PDPtr_6,
  MR_Word STATE_VARIABLE_CliqueUnion_0_10,
  MR_Word * STATE_VARIABLE_CliqueUnion_11);

static MR_bool MR_CALL 
canonical__merge_multi_slot_cluster_10_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1);

static void MR_CALL 
canonical__merge_multi_slot_cluster_10_p_0(
  MR_Word MergeInfo_11,
  MR_Word ParentPDPtr_12,
  MR_Word Clique_13,
  MR_Word ClusterCSDPtrs_14,
  MR_Word PrimeCSDPtrs0_15,
  MR_Word * PrimeCSDPtrs_16,
  MR_Word InitDeep0_17,
  MR_Word * InitDeep_18,
  MR_Word Redirect0_19,
  MR_Word * Redirect_20);

static void MR_CALL 
canonical__accumulate_csd_owns_3_p_0(
  MR_Word CSD_4,
  MR_Word Own0_5,
  MR_Word * Own_6);

static void MR_CALL 
canonical__merge_proc_dynamics_ignore_chosen_7_p_0_4(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2);

static void MR_CALL 
canonical__merge_proc_dynamics_ignore_chosen_7_p_0_3(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2);

static MR_bool MR_CALL 
canonical__merge_proc_dynamics_ignore_chosen_7_p_0_2(
  MR_Box closure_arg);

static MR_bool MR_CALL 
canonical__merge_proc_dynamics_ignore_chosen_7_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1);

static void MR_CALL 
canonical__merge_proc_dynamics_ignore_chosen_7_p_0(
  MR_Word MergeInfo_8,
  MR_Word Clique_9,
  MR_Word CandidatePDPtrs_10,
  MR_Word STATE_VARIABLE_InitDeep_0_14,
  MR_Word * STATE_VARIABLE_InitDeep_15,
  MR_Word STATE_VARIABLE_Redirect_0_16,
  MR_Word * STATE_VARIABLE_Redirect_17);

static void MR_CALL 
canonical__merge_call_site_dynamics_descendants_8_p_0_3(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3);

static void MR_CALL 
canonical__merge_call_site_dynamics_descendants_8_p_0_2(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2);

static void MR_CALL 
canonical__merge_call_site_dynamics_descendants_8_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2);

static void MR_CALL 
canonical__merge_call_site_dynamics_descendants_8_p_0(
  MR_Word MergeInfo_9,
  MR_Word PrimeCSDPtr_10,
  MR_Word RestCSDPtrs_11,
  MR_Word * ChosenPDPtr_12,
  MR_Word STATE_VARIABLE_InitDeep_0_22,
  MR_Word * STATE_VARIABLE_InitDeep_23,
  MR_Word STATE_VARIABLE_Redirect_0_24,
  MR_Word * STATE_VARIABLE_Redirect_25);

static void MR_CALL 
canonical__merge_proc_dynamic_slots_11_p_0_2(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3,
  MR_Box wrapper_arg_4,
  MR_Box * wrapper_arg_5,
  MR_Box wrapper_arg_6,
  MR_Box * wrapper_arg_7);

static void MR_CALL 
canonical__merge_proc_dynamic_slots_11_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3);

static void MR_CALL 
canonical__merge_proc_dynamic_slots_11_p_0(
  MR_Word MergeInfo_12,
  MR_Integer SlotNum_13,
  MR_Word Clique_14,
  MR_Word PrimePDPtr_15,
  MR_ArrayPtr STATE_VARIABLE_PrimeSiteArray_0_28,
  MR_Word RestSiteArrays_17,
  MR_ArrayPtr * STATE_VARIABLE_PrimeSiteArray_29,
  MR_Word STATE_VARIABLE_InitDeep_0_30,
  MR_Word * STATE_VARIABLE_InitDeep_31,
  MR_Word STATE_VARIABLE_Redirect_0_32,
  MR_Word * STATE_VARIABLE_Redirect_33);

static void MR_CALL 
canonical__merge_call_site_dynamics_2_8_p_0_6(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2);

static MR_bool MR_CALL 
canonical__merge_call_site_dynamics_2_8_p_0_5(
  MR_Box closure_arg);

static void MR_CALL 
canonical__merge_call_site_dynamics_2_8_p_0_4(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2);

static MR_bool MR_CALL 
canonical__merge_call_site_dynamics_2_8_p_0_3(
  MR_Box closure_arg);

static void MR_CALL 
canonical__merge_call_site_dynamics_2_8_p_0_2(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3);

static MR_bool MR_CALL 
canonical__merge_call_site_dynamics_2_8_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1);

static void MR_CALL 
canonical__merge_call_site_dynamics_2_8_p_0(
  MR_Word MergeInfo_9,
  MR_Word Clique_10,
  MR_Word PrimeCSDPtr_11,
  MR_Word RestCSDPtrs_12,
  MR_Word InitDeep0_13,
  MR_Word * InitDeep_14,
  MR_Word Redirect0_15,
  MR_Word * Redirect_16);

static MR_bool MR_CALL 
canonical__merge_proc_dynamic_normal_slot_11_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1);

static void MR_CALL 
canonical__merge_proc_dynamic_normal_slot_11_p_0(
  MR_Word MergeInfo_12,
  MR_Integer SlotNum_13,
  MR_Word Clique_14,
  MR_Word PrimePDPtr_15,
  MR_Word PrimeCSDPtr0_16,
  MR_Word RestSiteArrays_17,
  MR_Word * PrimeCSDPtr_18,
  MR_Word STATE_VARIABLE_InitDeep_0_22,
  MR_Word * STATE_VARIABLE_InitDeep_23,
  MR_Word STATE_VARIABLE_Redirect_0_24,
  MR_Word * STATE_VARIABLE_Redirect_25);

static void MR_CALL 
canonical__merge_proc_dynamics_8_p_0_4(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2);

static void MR_CALL 
canonical__merge_proc_dynamics_8_p_0_3(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2);

static MR_bool MR_CALL 
canonical__merge_proc_dynamics_8_p_0_2(
  MR_Box closure_arg);

static MR_bool MR_CALL 
canonical__merge_proc_dynamics_8_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1);

static void MR_CALL 
canonical__merge_proc_dynamics_8_p_0(
  MR_Word MergeInfo_9,
  MR_Word Clique_10,
  MR_Word CandidatePDPtrs_11,
  MR_Word * ChosenPDPtr_12,
  MR_Word STATE_VARIABLE_InitDeep_0_29,
  MR_Word * STATE_VARIABLE_InitDeep_30,
  MR_Word STATE_VARIABLE_Redirect_0_31,
  MR_Word * STATE_VARIABLE_Redirect_32);

static void MR_CALL 
canonical__record_csd_redirect_4_p_0(
  MR_Word RestCSDPtrs_5,
  MR_Word PrimeCSDPtr_6,
  MR_Word STATE_VARIABLE_Redirect_0_11,
  MR_Word * STATE_VARIABLE_Redirect_12);

static void MR_CALL 
canonical__record_csd_redirect_2_4_p_0(
  MR_Word HeadVar__1_1,
  MR_Word PrimeCSDPtr_2,
  MR_Word STATE_VARIABLE_Redirect_0_3,
  MR_Word * STATE_VARIABLE_Redirect_4);

static void MR_CALL 
canonical__record_pd_redirect_4_p_0(
  MR_Word RestPDPtrs_5,
  MR_Word PrimePDPtr_6,
  MR_Word STATE_VARIABLE_Redirect_0_11,
  MR_Word * STATE_VARIABLE_Redirect_12);

static void MR_CALL 
canonical__record_pd_redirect_2_4_p_0(
  MR_Word HeadVar__1_1,
  MR_Word PrimePDPtr_2,
  MR_Word STATE_VARIABLE_Redirect_0_3,
  MR_Word * STATE_VARIABLE_Redirect_4);

static MR_bool MR_CALL 
canonical__callee_in_clique_3_p_0(
  MR_Word InitDeep_4,
  MR_Word Clique_5,
  MR_Word CSDPtr_6);

static void MR_CALL 
canonical__lookup_pd_site_3_p_0(
  MR_Word InitDeep_4,
  MR_Word PDPtr_5,
  MR_ArrayPtr * Sites_6);

static void MR_CALL 
canonical__complete_clique_ps_7_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2);

static void MR_CALL 
canonical__complete_clique_ps_7_p_0(
  MR_Word InitDeep_8,
  MR_Word Clique_9,
  MR_Word HeadVar__3_3,
  MR_Word STATE_VARIABLE_ProcMap_0_19,
  MR_Word * STATE_VARIABLE_ProcMap_20,
  MR_Word STATE_VARIABLE_AddedPD_0_21,
  MR_Word * STATE_VARIABLE_AddedPD_22);

static void MR_CALL 
canonical__complete_clique_slots_9_p_0_3(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3);

static void MR_CALL 
canonical__complete_clique_slots_9_p_0_2(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2);

static MR_bool MR_CALL 
canonical__complete_clique_slots_9_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1);

static void MR_CALL 
canonical__complete_clique_slots_9_p_0(
  MR_Integer SlotNum_10,
  MR_Word InitDeep_11,
  MR_Word Clique_12,
  MR_ArrayPtr PSSites_13,
  MR_Word PDSites_14,
  MR_Word STATE_VARIABLE_ProcMap_0_29,
  MR_Word * STATE_VARIABLE_ProcMap_30,
  MR_Word STATE_VARIABLE_AddedPD_0_31,
  MR_Word * STATE_VARIABLE_AddedPD_32);

static void MR_CALL 
canonical__lookup_multi_sites_3_p_0(
  MR_Word HeadVar__1_1,
  MR_Integer SlotNum_2,
  MR_Word * HeadVar__3_3);

static void MR_CALL 
canonical__lookup_normal_sites_3_p_0(
  MR_Word HeadVar__1_1,
  MR_Integer SlotNum_2,
  MR_Word * HeadVar__3_3);

static void MR_CALL 
canonical__canonicalize_cliques_2_p_0_2(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2);

static void MR_CALL 
canonical__canonicalize_cliques_2_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2);

static void MR_CALL 
canonical__compact_pd_redirect_6_p_0(
  MR_Integer CurOld_7,
  MR_Integer CurNew_8,
  MR_Integer MaxOld_9,
  MR_Integer * NumNew_10,
  MR_ArrayPtr STATE_VARIABLE_PDredirect_0_13,
  MR_ArrayPtr * STATE_VARIABLE_PDredirect_14);

static void MR_CALL 
canonical__compact_csd_redirect_6_p_0(
  MR_Integer CurOld_7,
  MR_Integer CurNew_8,
  MR_Integer MaxOld_9,
  MR_Integer * NumNew_10,
  MR_ArrayPtr STATE_VARIABLE_CSDredirect_0_13,
  MR_ArrayPtr * STATE_VARIABLE_CSDredirect_14);

static void MR_CALL 
canonical__merge_cliques_6_p_0_4(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3,
  MR_Box wrapper_arg_4,
  MR_Box * wrapper_arg_5);

static MR_bool MR_CALL 
canonical__merge_cliques_6_p_0_3(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1);

static MR_bool MR_CALL 
canonical__merge_cliques_6_p_0_2(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1);

static void MR_CALL 
canonical__merge_cliques_6_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3);

static void MR_CALL 
canonical__merge_cliques_6_p_0(
  MR_Word HeadVar__1_1,
  MR_Word MergeInfo_2,
  MR_Word STATE_VARIABLE_InitDeep_0_3,
  MR_Word * STATE_VARIABLE_InitDeep_4,
  MR_Word STATE_VARIABLE_Redirect_0_5,
  MR_Word * STATE_VARIABLE_Redirect_6);

static void MR_CALL 
canonical__f_85_110_117_115_101_100_65_114_103_115_95_95_112_114_101_100_95_95_99_111_109_112_108_101_116_101_95_99_108_105_113_117_101_95_95_91_50_93_95_48_5_p_0_2(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3,
  MR_Box wrapper_arg_4,
  MR_Box * wrapper_arg_5);

static void MR_CALL 
canonical__f_85_110_117_115_101_100_65_114_103_115_95_95_112_114_101_100_95_95_99_111_109_112_108_101_116_101_95_99_108_105_113_117_101_95_95_91_50_93_95_48_5_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3);

static void MR_CALL 
canonical__f_85_110_117_115_101_100_65_114_103_115_95_95_112_114_101_100_95_95_99_111_109_112_108_101_116_101_95_99_108_105_113_117_101_95_95_91_50_93_95_48_5_p_0(
  MR_Word InitDeep_6,
  MR_Word STATE_VARIABLE_ProcMap_0_13,
  MR_Word * STATE_VARIABLE_ProcMap_14,
  MR_Word * Clique_9);

static MR_bool MR_CALL 
canonical____Unify____merge_info_0_0_10001(
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2);

static void MR_CALL 
canonical____Compare____merge_info_0_0_10001(
  MR_Box * wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box wrapper_arg_3);

static MR_bool MR_CALL 
canonical____Unify____redirect_0_0_10001(
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2);

static void MR_CALL 
canonical____Compare____redirect_0_0_10001(
  MR_Box * wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box wrapper_arg_3);


static /* final */ const MR_Box canonical_scalar_common_1[10][2];

static /* final */ const MR_Box canonical_scalar_common_2[10][3];

static /* final */ const MR_Box canonical_scalar_common_3[11][6];

static /* final */ const MR_Box canonical_scalar_common_4[2][10];

static /* final */ const MR_Box canonical_scalar_common_5[3][7];

static /* final */ const MR_Box canonical_scalar_common_6[1][4];

static /* final */ const MR_Box canonical_scalar_common_7[6][5];

static /* final */ const MR_Box canonical_scalar_common_8[1][13];




static /* final */ const MR_Box canonical_scalar_common_1[10][2] = {
  /* row 0 */
  {
    ((MR_Box) (&mercury__list__list__type_ctor_info_list_1)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0))
  },
  /* row 1 */
  {
    ((MR_Box) (&mercury__set_ordlist__set_ordlist__type_ctor_info_set_ordlist_1)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0))
  },
  /* row 2 */
  {
    ((MR_Box) (&mercury__array__array__type_ctor_info_array_1)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_array_slot_0))
  },
  /* row 3 */
  {
    ((MR_Box) (&mercury__array__array__type_ctor_info_array_1)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_0))
  },
  /* row 4 */
  {
    ((MR_Box) (&mercury__list__list__type_ctor_info_list_1)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0))
  },
  /* row 5 */
  {
    ((MR_Box) (&mercury__array__array__type_ctor_info_array_1)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_dynamic_0))
  },
  /* row 6 */
  {
    ((MR_Box) (&mercury__array__array__type_ctor_info_array_1)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0))
  },
  /* row 7 */
  {
    ((MR_Box) (&mercury__array__array__type_ctor_info_array_1)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0))
  },
  /* row 8 */
  {
    ((MR_Box) (&mercury__array__array__type_ctor_info_array_1)),
    ((MR_Box) (&canonical_scalar_common_1[0]))
  },
  /* row 9 */
  {
    ((MR_Box) (&mercury__array__array__type_ctor_info_array_1)),
    ((MR_Box) (&profile__profile__type_ctor_info_clique_ptr_0))
  },
};

static /* final */ const MR_Box canonical_scalar_common_2[10][3] = {
  /* row 0 */
  {
    ((MR_Box) (&mercury__tree234__tree234__type_ctor_info_tree234_2)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_static_ptr_0)),
    ((MR_Box) (&canonical_scalar_common_1[0]))
  },
  /* row 1 */
  {
    ((MR_Box) (&mercury__pair__pair__type_ctor_info_pair_2)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_static_ptr_0)),
    ((MR_Box) (&canonical_scalar_common_1[0]))
  },
  /* row 2 */
  {
    ((MR_Box) (&mercury__tree234__tree234__type_ctor_info_tree234_2)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_static_ptr_0)),
    ((MR_Box) (&canonical_scalar_common_1[4]))
  },
  /* row 3 */
  {
    ((MR_Box) (&canonical_scalar_common_3[0])),
    ((MR_Box) (canonical__f_85_110_117_115_101_100_65_114_103_115_95_95_112_114_101_100_95_95_99_111_109_112_108_101_116_101_95_99_108_105_113_117_101_95_95_91_50_93_95_48_5_p_0_1)),
    ((MR_Box) ((MR_Integer) 0))
  },
  /* row 4 */
  {
    ((MR_Box) (&canonical_scalar_common_6[0])),
    ((MR_Box) (canonical__merge_cliques_6_p_0_2)),
    ((MR_Box) ((MR_Integer) 0))
  },
  /* row 5 */
  {
    ((MR_Box) (&canonical_scalar_common_6[0])),
    ((MR_Box) (canonical__merge_cliques_6_p_0_3)),
    ((MR_Box) ((MR_Integer) 0))
  },
  /* row 6 */
  {
    ((MR_Box) (&canonical_scalar_common_7[3])),
    ((MR_Box) (canonical__merge_proc_dynamics_8_p_0_4)),
    ((MR_Box) ((MR_Integer) 0))
  },
  /* row 7 */
  {
    ((MR_Box) (&canonical_scalar_common_3[7])),
    ((MR_Box) (canonical__merge_call_site_dynamics_2_8_p_0_2)),
    ((MR_Box) ((MR_Integer) 0))
  },
  /* row 8 */
  {
    ((MR_Box) (&canonical_scalar_common_7[5])),
    ((MR_Box) (canonical__merge_call_site_dynamics_descendants_8_p_0_2)),
    ((MR_Box) ((MR_Integer) 0))
  },
  /* row 9 */
  {
    ((MR_Box) (&canonical_scalar_common_7[3])),
    ((MR_Box) (canonical__merge_proc_dynamics_ignore_chosen_7_p_0_4)),
    ((MR_Box) ((MR_Integer) 0))
  },
};

static /* final */ const MR_Box canonical_scalar_common_3[11][6] = {
  /* row 0 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 3)),
    ((MR_Box) (&canonical__list__pti_list_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&canonical__set_ordlist__pti_set_ordlist_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&canonical__set_ordlist__pti_set_ordlist_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0))
  },
  /* row 1 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 3)),
    ((MR_Box) (&canonical__canonical__type_ctor_info_redirect_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_dynamic_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_dynamic_0))
  },
  /* row 2 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 3)),
    ((MR_Box) (&canonical__canonical__type_ctor_info_redirect_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_0))
  },
  /* row 3 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 3)),
    ((MR_Box) (&profile__profile__type_ctor_info_initial_deep_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0))
  },
  /* row 4 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 3)),
    ((MR_Box) (&profile__profile__type_ctor_info_initial_deep_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&canonical__array__pti_array_1__plain_profile__type_ctor_info_call_site_array_slot_0))
  },
  /* row 5 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 3)),
    ((MR_Box) (&canonical__array__pti_array_1__plain_profile__type_ctor_info_proc_dynamic_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_0))
  },
  /* row 6 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 3)),
    ((MR_Box) (&profile__profile__type_ctor_info_initial_deep_0)),
    ((MR_Box) (&canonical__set_ordlist__pti_set_ordlist_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0))
  },
  /* row 7 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 3)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_dynamic_0)),
    ((MR_Box) (&measurements__measurements__type_ctor_info_own_prof_info_0)),
    ((MR_Box) (&measurements__measurements__type_ctor_info_own_prof_info_0))
  },
  /* row 8 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 3)),
    ((MR_Box) (&canonical__array__pti_array_1__plain_profile__type_ctor_info_call_site_dynamic_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_dynamic_0))
  },
  /* row 9 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 3)),
    ((MR_Box) (&canonical__canonical__type_ctor_info_redirect_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_array_slot_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_array_slot_0))
  },
  /* row 10 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 3)),
    ((MR_Box) (&canonical__array__pti_array_1__plain_profile__type_ctor_info_call_site_dynamic_ptr_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0))
  },
};

static /* final */ const MR_Box canonical_scalar_common_4[2][10] = {
  /* row 0 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 7)),
    ((MR_Box) (&profile__profile__type_ctor_info_initial_deep_0)),
    ((MR_Box) (&canonical__set_ordlist__pti_set_ordlist_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&canonical__pair__pti_pair_2__plain_profile__type_ctor_info_proc_static_ptr_0__plain_list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&canonical__tree234__pti_tree234_2__plain_profile__type_ctor_info_proc_static_ptr_0__plain_list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&canonical__tree234__pti_tree234_2__plain_profile__type_ctor_info_proc_static_ptr_0__plain_list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&mercury__bool__bool__type_ctor_info_bool_0)),
    ((MR_Box) (&mercury__bool__bool__type_ctor_info_bool_0))
  },
  /* row 1 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 7)),
    ((MR_Box) (&canonical__canonical__type_ctor_info_merge_info_0)),
    ((MR_Box) (&canonical__set_ordlist__pti_set_ordlist_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&canonical__list__pti_list_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_initial_deep_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_initial_deep_0)),
    ((MR_Box) (&canonical__canonical__type_ctor_info_redirect_0)),
    ((MR_Box) (&canonical__canonical__type_ctor_info_redirect_0))
  },
};

static /* final */ const MR_Box canonical_scalar_common_5[3][7] = {
  /* row 0 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 4)),
    ((MR_Box) (&profile__profile__type_ctor_info_initial_deep_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&canonical__tree234__pti_tree234_2__plain_profile__type_ctor_info_proc_static_ptr_0__plain_list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&canonical__tree234__pti_tree234_2__plain_profile__type_ctor_info_proc_static_ptr_0__plain_list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0))
  },
  /* row 1 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 4)),
    ((MR_Box) (&profile__profile__type_ctor_info_initial_deep_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0)),
    ((MR_Box) (&canonical__tree234__pti_tree234_2__plain_profile__type_ctor_info_proc_static_ptr_0__plain_list__ti_list_1profile__type_ctor_info_call_site_dynamic_ptr_0)),
    ((MR_Box) (&canonical__tree234__pti_tree234_2__plain_profile__type_ctor_info_proc_static_ptr_0__plain_list__ti_list_1profile__type_ctor_info_call_site_dynamic_ptr_0))
  },
  /* row 2 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 4)),
    ((MR_Box) (&canonical__canonical__type_ctor_info_merge_info_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&canonical__set_ordlist__pti_set_ordlist_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&canonical__set_ordlist__pti_set_ordlist_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0))
  },
};

static /* final */ const MR_Box canonical_scalar_common_6[1][4] = {
  /* row 0 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 1)),
    ((MR_Box) (&canonical__list__pti_list_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0))
  },
};

static /* final */ const MR_Box canonical_scalar_common_7[6][5] = {
  /* row 0 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 2)),
    ((MR_Box) (&canonical__array__pti_array_1__plain_profile__type_ctor_info_call_site_dynamic_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0))
  },
  /* row 1 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 2)),
    ((MR_Box) (&canonical__array__pti_array_1__plain_profile__type_ctor_info_proc_dynamic_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0))
  },
  /* row 2 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 2)),
    ((MR_Box) (&canonical__list__pti_list_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&canonical__list__pti_list_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0))
  },
  /* row 3 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 2)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_0)),
    ((MR_Box) (&canonical__array__pti_array_1__plain_profile__type_ctor_info_call_site_array_slot_0))
  },
  /* row 4 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 2)),
    ((MR_Box) (&canonical__list__pti_list_1__plain_profile__type_ctor_info_call_site_dynamic_ptr_0)),
    ((MR_Box) (&canonical__list__pti_list_1__plain_profile__type_ctor_info_call_site_dynamic_ptr_0))
  },
  /* row 5 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 2)),
    ((MR_Box) (&profile__profile__type_ctor_info_call_site_dynamic_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0))
  },
};

static /* final */ const MR_Box canonical_scalar_common_8[1][13] = {
  /* row 0 */
  {
    NULL,
    ((MR_Box) (NULL)),
    ((MR_Box) ((MR_Integer) 10)),
    ((MR_Box) (&canonical__canonical__type_ctor_info_merge_info_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&canonical__set_ordlist__pti_set_ordlist_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0)),
    ((MR_Box) (&canonical__list__pti_list_1__plain_profile__type_ctor_info_call_site_dynamic_ptr_0)),
    ((MR_Box) (&canonical__list__pti_list_1__plain_profile__type_ctor_info_call_site_dynamic_ptr_0)),
    ((MR_Box) (&canonical__list__pti_list_1__plain_profile__type_ctor_info_call_site_dynamic_ptr_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_initial_deep_0)),
    ((MR_Box) (&profile__profile__type_ctor_info_initial_deep_0)),
    ((MR_Box) (&canonical__canonical__type_ctor_info_redirect_0)),
    ((MR_Box) (&canonical__canonical__type_ctor_info_redirect_0))
  },
};



#include "array.mh"
#include "bitmap.mh"
#include "io.mh"
#include "profile.mh"
#include "string.mh"
#include "time.mh"



static const MR_FA_PseudoTypeInfo_Struct1 canonical__list__pti_list_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0 = {
  &mercury__list__list__type_ctor_info_list_1,
  {
    (MR_PseudoTypeInfo) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0)
  }
};

static const MR_FA_PseudoTypeInfo_Struct1 canonical__set_ordlist__pti_set_ordlist_1__plain_profile__type_ctor_info_proc_dynamic_ptr_0 = {
  &mercury__set_ordlist__set_ordlist__type_ctor_info_set_ordlist_1,
  {
    (MR_PseudoTypeInfo) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0)
  }
};

static const MR_FA_TypeInfo_Struct1 canonical__list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0 = {
  &mercury__list__list__type_ctor_info_list_1,
  {
    (MR_TypeInfo) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0)
  }
};

static const MR_FA_PseudoTypeInfo_Struct2 canonical__pair__pti_pair_2__plain_profile__type_ctor_info_proc_static_ptr_0__plain_list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0 = {
  &mercury__pair__pair__type_ctor_info_pair_2,
  {
    (MR_PseudoTypeInfo) (&profile__profile__type_ctor_info_proc_static_ptr_0),
    (MR_PseudoTypeInfo) (&canonical__list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0)
  }
};

static const MR_FA_PseudoTypeInfo_Struct2 canonical__tree234__pti_tree234_2__plain_profile__type_ctor_info_proc_static_ptr_0__plain_list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0 = {
  &mercury__tree234__tree234__type_ctor_info_tree234_2,
  {
    (MR_PseudoTypeInfo) (&profile__profile__type_ctor_info_proc_static_ptr_0),
    (MR_PseudoTypeInfo) (&canonical__list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0)
  }
};

static const MR_FA_PseudoTypeInfo_Struct1 canonical__array__pti_array_1__plain_profile__type_ctor_info_call_site_dynamic_0 = {
  &mercury__array__array__type_ctor_info_array_1,
  {
    (MR_PseudoTypeInfo) (&profile__profile__type_ctor_info_call_site_dynamic_0)
  }
};

static const MR_FA_PseudoTypeInfo_Struct1 canonical__array__pti_array_1__plain_profile__type_ctor_info_call_site_array_slot_0 = {
  &mercury__array__array__type_ctor_info_array_1,
  {
    (MR_PseudoTypeInfo) (&profile__profile__type_ctor_info_call_site_array_slot_0)
  }
};

static const MR_FA_PseudoTypeInfo_Struct1 canonical__array__pti_array_1__plain_profile__type_ctor_info_proc_dynamic_0 = {
  &mercury__array__array__type_ctor_info_array_1,
  {
    (MR_PseudoTypeInfo) (&profile__profile__type_ctor_info_proc_dynamic_0)
  }
};

static const MR_FA_PseudoTypeInfo_Struct1 canonical__list__pti_list_1__plain_profile__type_ctor_info_call_site_dynamic_ptr_0 = {
  &mercury__list__list__type_ctor_info_list_1,
  {
    (MR_PseudoTypeInfo) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0)
  }
};

static const MR_FA_TypeInfo_Struct1 canonical__list__ti_list_1profile__type_ctor_info_call_site_dynamic_ptr_0 = {
  &mercury__list__list__type_ctor_info_list_1,
  {
    (MR_TypeInfo) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0)
  }
};

static const MR_FA_PseudoTypeInfo_Struct2 canonical__tree234__pti_tree234_2__plain_profile__type_ctor_info_proc_static_ptr_0__plain_list__ti_list_1profile__type_ctor_info_call_site_dynamic_ptr_0 = {
  &mercury__tree234__tree234__type_ctor_info_tree234_2,
  {
    (MR_PseudoTypeInfo) (&profile__profile__type_ctor_info_proc_static_ptr_0),
    (MR_PseudoTypeInfo) (&canonical__list__ti_list_1profile__type_ctor_info_call_site_dynamic_ptr_0)
  }
};

static const MR_FA_PseudoTypeInfo_Struct1 canonical__array__pti_array_1__plain_profile__type_ctor_info_call_site_dynamic_ptr_0 = {
  &mercury__array__array__type_ctor_info_array_1,
  {
    (MR_PseudoTypeInfo) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0)
  }
};

static const MR_FA_TypeInfo_Struct1 canonical__array__ti_array_1list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0 = {
  &mercury__array__array__type_ctor_info_array_1,
  {
    (MR_TypeInfo) (&canonical__list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0)
  }
};

static const MR_FA_TypeInfo_Struct1 canonical__array__ti_array_1profile__type_ctor_info_clique_ptr_0 = {
  &mercury__array__array__type_ctor_info_array_1,
  {
    (MR_TypeInfo) (&profile__profile__type_ctor_info_clique_ptr_0)
  }
};

static const MR_PseudoTypeInfo canonical__canonical__field_types_merge_info_0_0[2] = {
  (MR_PseudoTypeInfo) (&canonical__array__ti_array_1list__ti_list_1profile__type_ctor_info_proc_dynamic_ptr_0),
  (MR_PseudoTypeInfo) (&canonical__array__ti_array_1profile__type_ctor_info_clique_ptr_0)
};

static const MR_ConstString canonical__canonical__field_names_merge_info_0_0[2] = {
  (MR_String) "merge_clique_members",
  (MR_String) "merge_clique_index"
};

static const MR_DuFunctorDesc canonical__canonical__du_functor_desc_merge_info_0_0 = {
  (MR_String) "merge_info",
  INT16_C(2),
  UINT16_C(0),
  MR_SECTAG_NONE,
  UINT8_C(0),
  (MR_Integer) -1,
  INT32_C(0),
  canonical__canonical__field_types_merge_info_0_0,
  canonical__canonical__field_names_merge_info_0_0,
  NULL,
  NULL,
  MR_FUNCTOR_SUBTYPE_NONE,
  UINT8_C(0)
};

static const MR_DuFunctorDescPtr canonical__canonical__du_stag_ordered_merge_info_0_0[1] = {
  &canonical__canonical__du_functor_desc_merge_info_0_0
};

static const MR_DuPtagLayout canonical__canonical__du_ptag_ordered_merge_info_0[1] = {
  {
    UINT32_C(1),
    MR_SECTAG_NONE,
    canonical__canonical__du_stag_ordered_merge_info_0_0,
    INT8_C(-1),
    UINT8_C(0),
    UINT8_C(1)
  }
};

static const MR_DuFunctorDescPtr canonical__canonical__du_name_ordered_merge_info_0[1] = {
  &canonical__canonical__du_functor_desc_merge_info_0_0
};

static const MR_Integer canonical__canonical__functor_number_map_merge_info_0[1] = {
  (MR_Integer) 0
};

const MR_TypeCtorInfo_Struct canonical__canonical__type_ctor_info_merge_info_0 = {
  (MR_Integer) 0,
  UINT8_C(18),
  INT8_C(1),
  MR_TYPECTOR_REP_DU,
  ((MR_Box) (canonical____Unify____merge_info_0_0_10001)),
  ((MR_Box) (canonical____Compare____merge_info_0_0_10001)),
  (MR_String) "canonical",
  (MR_String) "merge_info",
  {     canonical__canonical__du_name_ordered_merge_info_0 },
  {     canonical__canonical__du_ptag_ordered_merge_info_0 },
  (MR_Integer) 1,
  UINT16_C(12),
  canonical__canonical__functor_number_map_merge_info_0,

};

static const MR_FA_TypeInfo_Struct1 canonical__array__ti_array_1profile__type_ctor_info_call_site_dynamic_ptr_0 = {
  &mercury__array__array__type_ctor_info_array_1,
  {
    (MR_TypeInfo) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0)
  }
};

static const MR_FA_TypeInfo_Struct1 canonical__array__ti_array_1profile__type_ctor_info_proc_dynamic_ptr_0 = {
  &mercury__array__array__type_ctor_info_array_1,
  {
    (MR_TypeInfo) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0)
  }
};

static const MR_PseudoTypeInfo canonical__canonical__field_types_redirect_0_0[2] = {
  (MR_PseudoTypeInfo) (&canonical__array__ti_array_1profile__type_ctor_info_call_site_dynamic_ptr_0),
  (MR_PseudoTypeInfo) (&canonical__array__ti_array_1profile__type_ctor_info_proc_dynamic_ptr_0)
};

static const MR_ConstString canonical__canonical__field_names_redirect_0_0[2] = {
  (MR_String) "csd_redirect",
  (MR_String) "pd_redirect"
};

static const MR_DuFunctorDesc canonical__canonical__du_functor_desc_redirect_0_0 = {
  (MR_String) "redirect",
  INT16_C(2),
  UINT16_C(0),
  MR_SECTAG_NONE,
  UINT8_C(0),
  (MR_Integer) -1,
  INT32_C(0),
  canonical__canonical__field_types_redirect_0_0,
  canonical__canonical__field_names_redirect_0_0,
  NULL,
  NULL,
  MR_FUNCTOR_SUBTYPE_NONE,
  UINT8_C(0)
};

static const MR_DuFunctorDescPtr canonical__canonical__du_stag_ordered_redirect_0_0[1] = {
  &canonical__canonical__du_functor_desc_redirect_0_0
};

static const MR_DuPtagLayout canonical__canonical__du_ptag_ordered_redirect_0[1] = {
  {
    UINT32_C(1),
    MR_SECTAG_NONE,
    canonical__canonical__du_stag_ordered_redirect_0_0,
    INT8_C(-1),
    UINT8_C(0),
    UINT8_C(1)
  }
};

static const MR_DuFunctorDescPtr canonical__canonical__du_name_ordered_redirect_0[1] = {
  &canonical__canonical__du_functor_desc_redirect_0_0
};

static const MR_Integer canonical__canonical__functor_number_map_redirect_0[1] = {
  (MR_Integer) 0
};

const MR_TypeCtorInfo_Struct canonical__canonical__type_ctor_info_redirect_0 = {
  (MR_Integer) 0,
  UINT8_C(18),
  INT8_C(1),
  MR_TYPECTOR_REP_DU,
  ((MR_Box) (canonical____Unify____redirect_0_0_10001)),
  ((MR_Box) (canonical____Compare____redirect_0_0_10001)),
  (MR_String) "canonical",
  (MR_String) "redirect",
  {     canonical__canonical__du_name_ordered_redirect_0 },
  {     canonical__canonical__du_ptag_ordered_redirect_0 },
  (MR_Integer) 1,
  UINT16_C(12),
  canonical__canonical__functor_number_map_redirect_0,

};

static MR_bool MR_CALL 
canonical__IntroducedFrom__pred__merge_call_site_dynamics_2__420__1_2_p_0(
  MR_Word InClique_17,
  MR_Word HeadVar__2_43)
{
  {
    MR_bool succeeded;

    succeeded = mercury__builtin__unify_2_p_0((MR_Word) (&canonical_scalar_common_1[4]), ((MR_Box) (InClique_17)), ((MR_Box) (HeadVar__2_43)));
    return succeeded;
  }
}

static MR_bool MR_CALL 
canonical__IntroducedFrom__pred__merge_call_site_dynamics_2__415__1_2_p_0(
  MR_Word NotInClique_18,
  MR_Word HeadVar__2_38)
{
  {
    MR_bool succeeded;

    succeeded = mercury__builtin__unify_2_p_0((MR_Word) (&canonical_scalar_common_1[4]), ((MR_Box) (NotInClique_18)), ((MR_Box) (HeadVar__2_38)));
    return succeeded;
  }
}

static MR_bool MR_CALL 
canonical__IntroducedFrom__pred__merge_proc_dynamics__241__1_2_p_0(
  MR_Word InvalidPDPtrs_17,
  MR_Word HeadVar__2_36)
{
  {
    MR_bool succeeded;

    succeeded = mercury__builtin__unify_2_p_0((MR_Word) (&canonical_scalar_common_1[0]), ((MR_Box) (InvalidPDPtrs_17)), ((MR_Box) (HeadVar__2_36)));
    return succeeded;
  }
}

static void MR_CALL 
canonical__IntroducedFrom__pred__complete_clique__130__1_3_p_0(
  MR_Word HeadVar__1_22,
  MR_Word HeadVar__2_23,
  MR_Word * HeadVar__3_24)
{
  mercury__set__insert_list_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), HeadVar__1_22, HeadVar__2_23, HeadVar__3_24);
}

static void MR_CALL 
canonical____Compare____redirect_0_0(
  MR_Word * HeadVar__1_1,
  MR_Word HeadVar__2_2,
  MR_Word HeadVar__3_3)
{
  {
    MR_bool succeeded;
    MR_Integer CastX_9 = (MR_Integer) (HeadVar__2_2);
    MR_Integer CastY_10 = (MR_Integer) (HeadVar__3_3);

    succeeded = (CastX_9 == CastY_10);
    if (succeeded)
      *HeadVar__1_1 = (MR_Integer) 0;
    else
    {
      MR_ArrayPtr ArgX1_4 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__2_2, (MR_Integer) 0))));
      MR_ArrayPtr ArgY1_5 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__3_3, (MR_Integer) 0))));
      MR_ArrayPtr ArgX2_7 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__2_2, (MR_Integer) 1))));
      MR_ArrayPtr ArgY2_8 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__3_3, (MR_Integer) 1))));
      MR_Word SubResult1_6;

      mercury__builtin__compare_3_p_0((MR_Word) (&canonical_scalar_common_1[7]), &SubResult1_6, ((MR_Box) (ArgX1_4)), ((MR_Box) (ArgY1_5)));
      succeeded = (SubResult1_6 != (MR_Integer) 0);
      if (succeeded)
        *HeadVar__1_1 = SubResult1_6;
      else
        mercury__builtin__compare_3_p_0((MR_Word) (&canonical_scalar_common_1[6]), HeadVar__1_1, ((MR_Box) (ArgX2_7)), ((MR_Box) (ArgY2_8)));
    }
  }
}

static MR_bool MR_CALL 
canonical____Unify____redirect_0_0(
  MR_Word HeadVar__1_1,
  MR_Word HeadVar__2_2)
{
  {
    MR_bool succeeded;
    MR_Integer CastX_7 = (MR_Integer) (HeadVar__1_1);
    MR_Integer CastY_8 = (MR_Integer) (HeadVar__2_2);

    succeeded = (CastX_7 == CastY_8);
    if (succeeded)
      succeeded = MR_TRUE;
    else
    {
      MR_Word TypeCtorInfo_10_10;
      MR_ArrayPtr ArgX1_3 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__1_1, (MR_Integer) 0))));
      MR_ArrayPtr ArgY1_4 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__2_2, (MR_Integer) 0))));
      MR_ArrayPtr ArgX2_5 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__1_1, (MR_Integer) 1))));
      MR_ArrayPtr ArgY2_6 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__2_2, (MR_Integer) 1))));

      succeeded = mercury__array____Unify____array_1_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), (MR_ArrayPtr) (ArgX1_3), (MR_ArrayPtr) (ArgY1_4));
      if (succeeded)
      {
        TypeCtorInfo_10_10 = (MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0);
        succeeded = mercury__array____Unify____array_1_0(TypeCtorInfo_10_10, (MR_ArrayPtr) (ArgX2_5), (MR_ArrayPtr) (ArgY2_6));
      }
    }
    return succeeded;
  }
}

static void MR_CALL 
canonical____Compare____merge_info_0_0(
  MR_Word * HeadVar__1_1,
  MR_Word HeadVar__2_2,
  MR_Word HeadVar__3_3)
{
  {
    MR_bool succeeded;
    MR_Integer CastX_9 = (MR_Integer) (HeadVar__2_2);
    MR_Integer CastY_10 = (MR_Integer) (HeadVar__3_3);

    succeeded = (CastX_9 == CastY_10);
    if (succeeded)
      *HeadVar__1_1 = (MR_Integer) 0;
    else
    {
      MR_ArrayPtr ArgX1_4 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__2_2, (MR_Integer) 0))));
      MR_ArrayPtr ArgY1_5 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__3_3, (MR_Integer) 0))));
      MR_ArrayPtr ArgX2_7 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__2_2, (MR_Integer) 1))));
      MR_ArrayPtr ArgY2_8 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__3_3, (MR_Integer) 1))));
      MR_Word SubResult1_6;

      mercury__builtin__compare_3_p_0((MR_Word) (&canonical_scalar_common_1[8]), &SubResult1_6, ((MR_Box) (ArgX1_4)), ((MR_Box) (ArgY1_5)));
      succeeded = (SubResult1_6 != (MR_Integer) 0);
      if (succeeded)
        *HeadVar__1_1 = SubResult1_6;
      else
        mercury__builtin__compare_3_p_0((MR_Word) (&canonical_scalar_common_1[9]), HeadVar__1_1, ((MR_Box) (ArgX2_7)), ((MR_Box) (ArgY2_8)));
    }
  }
}

static MR_bool MR_CALL 
canonical____Unify____merge_info_0_0(
  MR_Word HeadVar__1_1,
  MR_Word HeadVar__2_2)
{
  {
    MR_bool succeeded;
    MR_Integer CastX_7 = (MR_Integer) (HeadVar__1_1);
    MR_Integer CastY_8 = (MR_Integer) (HeadVar__2_2);

    succeeded = (CastX_7 == CastY_8);
    if (succeeded)
      succeeded = MR_TRUE;
    else
    {
      MR_Word TypeCtorInfo_10_10;
      MR_ArrayPtr ArgX1_3 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__1_1, (MR_Integer) 0))));
      MR_ArrayPtr ArgY1_4 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__2_2, (MR_Integer) 0))));
      MR_ArrayPtr ArgX2_5 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__1_1, (MR_Integer) 1))));
      MR_ArrayPtr ArgY2_6 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), HeadVar__2_2, (MR_Integer) 1))));

      succeeded = mercury__array____Unify____array_1_0((MR_Word) (&canonical_scalar_common_1[0]), (MR_ArrayPtr) (ArgX1_3), (MR_ArrayPtr) (ArgY1_4));
      if (succeeded)
      {
        TypeCtorInfo_10_10 = (MR_Word) (&profile__profile__type_ctor_info_clique_ptr_0);
        succeeded = mercury__array____Unify____array_1_0(TypeCtorInfo_10_10, (MR_ArrayPtr) (ArgX2_5), (MR_ArrayPtr) (ArgY2_6));
      }
    }
    return succeeded;
  }
}

static void MR_CALL 
canonical__subst_in_slot_3_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv0_OldRedirect_6;

    canonical__lookup_csd_redirect_3_p_0(((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)), &conv0_OldRedirect_6);
    *wrapper_arg_2 = ((MR_Box) (conv0_OldRedirect_6));
  }
}

static void MR_CALL 
canonical__subst_in_slot_3_p_0(
  MR_Word Redirect_1,
  MR_Word HeadVar__2_2,
  MR_Word * HeadVar__3_3)
{
  {
    MR_ArrayPtr Var_22 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), Redirect_1, (MR_Integer) 0))));

    if (((MR_tag((MR_Word) HeadVar__2_2)) == (MR_Integer) 1))
    {
      MR_Word IsZeroed_9 = ((MR_Unsigned) ((MR_hl_field(MR_mktag(1), HeadVar__2_2, (MR_Integer) 0))) & (MR_Integer) 1);
      MR_ArrayPtr CSDPtrs0_10 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(1), HeadVar__2_2, (MR_Integer) 1))));
      MR_ArrayPtr CSDPtrs_11;
      MR_Word Var_12;
      MR_ArrayPtr Var_13;
      MR_Box conv1_Var_13;
      MR_ArrayPtr conv2_CSDPtrs_11;

      {
        Var_12 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), Var_12, 0) = ((MR_Box) (&canonical_scalar_common_3[10]));
        MR_hl_field(MR_mktag(0), Var_12, 1) = ((MR_Box) (canonical__subst_in_slot_3_p_0_1));
        MR_hl_field(MR_mktag(0), Var_12, 2) = ((MR_Box) ((MR_Integer) 1));
        MR_hl_field(MR_mktag(0), Var_12, 3) = ((MR_Box) (Var_22));
      }
      conv1_Var_13 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[7]), ((MR_Box) (CSDPtrs0_10)));
      Var_13 = ((MR_ArrayPtr) (conv1_Var_13));
      mercury__array__map_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), (MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), Var_12, (MR_ArrayPtr) (Var_13), &conv2_CSDPtrs_11);
      CSDPtrs_11 = (MR_ArrayPtr) (conv2_CSDPtrs_11);
      {
        MR_Word base;
        base = (MR_Word) MR_mkword(MR_mktag(1), MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL));
        *HeadVar__3_3 = base;
        MR_hl_field(MR_mktag(1), base, 0) = (MR_Box) ((MR_Unsigned) (IsZeroed_9));
        MR_hl_field(MR_mktag(1), base, 1) = ((MR_Box) (CSDPtrs_11));
      }
    }
    else
    {
      MR_Word CSDPtr0_5 = ((MR_Word) ((MR_hl_field(MR_mktag(0), HeadVar__2_2, (MR_Integer) 0))));
      MR_Word CSDPtr_6;
      MR_Integer CSDI_26 = (MR_Integer) (CSDPtr0_5);
      MR_Box conv3_CSDPtr_6;

      mercury__array__lookup_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), (MR_ArrayPtr) (Var_22), CSDI_26, &conv3_CSDPtr_6);
      CSDPtr_6 = ((MR_Word) (conv3_CSDPtr_6));
      {
        MR_Word base;
        base = (MR_Word) MR_new_object(MR_Word, (1 * sizeof(MR_Word)), NULL, NULL);
        *HeadVar__3_3 = base;
        MR_hl_field(MR_mktag(0), base, 0) = ((MR_Box) (CSDPtr_6));
      }
    }
  }
}

static void MR_CALL 
canonical__subst_in_proc_dynamic_3_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv0_HeadVar__3_3;

    canonical__subst_in_slot_3_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)), &conv0_HeadVar__3_3);
    *wrapper_arg_2 = ((MR_Box) (conv0_HeadVar__3_3));
  }
}

static void MR_CALL 
canonical__subst_in_proc_dynamic_3_p_0(
  MR_Word Redirect_4,
  MR_Word STATE_VARIABLE_PD_0_10,
  MR_Word * STATE_VARIABLE_PD_11)
{
  {
    MR_Word PDPtr_6 = ((MR_Word) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_PD_0_10, (MR_Integer) 0))));
    MR_ArrayPtr Slots0_7 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_PD_0_10, (MR_Integer) 1))));
    MR_Word MaybeCPs_8 = ((MR_Word) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_PD_0_10, (MR_Integer) 2))));
    MR_ArrayPtr Slots_9;
    MR_Word Var_12;
    MR_ArrayPtr Var_13;
    MR_Box conv1_Var_13;
    MR_ArrayPtr conv2_Slots_9;

    {
      Var_12 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), Var_12, 0) = ((MR_Box) (&canonical_scalar_common_3[9]));
      MR_hl_field(MR_mktag(0), Var_12, 1) = ((MR_Box) (canonical__subst_in_proc_dynamic_3_p_0_1));
      MR_hl_field(MR_mktag(0), Var_12, 2) = ((MR_Box) ((MR_Integer) 1));
      MR_hl_field(MR_mktag(0), Var_12, 3) = ((MR_Box) (Redirect_4));
    }
    conv1_Var_13 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[2]), ((MR_Box) (Slots0_7)));
    Var_13 = ((MR_ArrayPtr) (conv1_Var_13));
    mercury__array__map_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_array_slot_0), (MR_Word) (&profile__profile__type_ctor_info_call_site_array_slot_0), Var_12, (MR_ArrayPtr) (Var_13), &conv2_Slots_9);
    Slots_9 = (MR_ArrayPtr) (conv2_Slots_9);
    {
      MR_Word base;
      base = (MR_Word) MR_new_object(MR_Word, (3 * sizeof(MR_Word)), NULL, NULL);
      *STATE_VARIABLE_PD_11 = base;
      MR_hl_field(MR_mktag(0), base, 0) = ((MR_Box) (PDPtr_6));
      MR_hl_field(MR_mktag(0), base, 1) = ((MR_Box) (Slots_9));
      MR_hl_field(MR_mktag(0), base, 2) = ((MR_Box) (MaybeCPs_8));
    }
  }
}

static void MR_CALL 
canonical__subst_in_call_site_dynamic_3_p_0(
  MR_Word Redirect_4,
  MR_Word STATE_VARIABLE_CSD_0_11,
  MR_Word * STATE_VARIABLE_CSD_12)
{
  {
    MR_Word Caller0_6 = ((MR_Word) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_CSD_0_11, (MR_Integer) 0))));
    MR_Word Callee0_7 = ((MR_Word) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_CSD_0_11, (MR_Integer) 1))));
    MR_Word Own_8 = ((MR_Word) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_CSD_0_11, (MR_Integer) 2))));
    MR_Word Caller_9;
    MR_Word Callee_10;
    MR_ArrayPtr Var_13 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), Redirect_4, (MR_Integer) 1))));
    MR_ArrayPtr Var_14;
    MR_Integer PDI_21 = (MR_Integer) (Caller0_6);
    MR_Integer PDI_26;
    MR_Box conv0_Caller_9;
    MR_Box conv1_Callee_10;

    mercury__array__lookup_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), (MR_ArrayPtr) (Var_13), PDI_21, &conv0_Caller_9);
    Caller_9 = ((MR_Word) (conv0_Caller_9));
    Var_14 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), Redirect_4, (MR_Integer) 1))));
    PDI_26 = (MR_Integer) (Callee0_7);
    mercury__array__lookup_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), (MR_ArrayPtr) (Var_14), PDI_26, &conv1_Callee_10);
    Callee_10 = ((MR_Word) (conv1_Callee_10));
    {
      MR_Word base;
      base = (MR_Word) MR_new_object(MR_Word, (3 * sizeof(MR_Word)), NULL, NULL);
      *STATE_VARIABLE_CSD_12 = base;
      MR_hl_field(MR_mktag(0), base, 0) = ((MR_Box) (Caller_9));
      MR_hl_field(MR_mktag(0), base, 1) = ((MR_Box) (Callee_10));
      MR_hl_field(MR_mktag(0), base, 2) = ((MR_Box) (Own_8));
    }
  }
}

static void MR_CALL 
canonical__lookup_csd_redirect_3_p_0(
  MR_ArrayPtr CallSiteRedirect0_4,
  MR_Word CSDPtr_5,
  MR_Word * OldRedirect_6)
{
  {
    MR_Integer CSDI_7 = (MR_Integer) (CSDPtr_5);
    MR_Box conv0_OldRedirect_6;

    mercury__array__lookup_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), (MR_ArrayPtr) (CallSiteRedirect0_4), CSDI_7, &conv0_OldRedirect_6);
    *OldRedirect_6 = ((MR_Word) (conv0_OldRedirect_6));
  }
}

static void MR_CALL 
canonical__cluster_csds_by_ps_4_p_0(
  MR_Word InitDeep_5,
  MR_Word CSDPtr_6,
  MR_Word STATE_VARIABLE_ProcMap_0_15,
  MR_Word * STATE_VARIABLE_ProcMap_16)
{
  {
    MR_bool succeeded;
    MR_ArrayPtr CallSiteDynamics_8 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep_5, (MR_Integer) 2))));

    succeeded = profile__valid_call_site_dynamic_ptr_raw_2_p_0(CallSiteDynamics_8, CSDPtr_6);
    if (succeeded)
    {
      MR_Word CSD_9;
      MR_Word PDPtr_10;
      MR_ArrayPtr ProcDynamics_11;
      MR_Word PSPtr_13;
      MR_Word CSDPtrs0_14;
      MR_Box conv0_CSDPtrs0_14;

      profile__lookup_call_site_dynamics_3_p_0(CallSiteDynamics_8, CSDPtr_6, &CSD_9);
      PDPtr_10 = ((MR_Word) ((MR_hl_field(MR_mktag(0), CSD_9, (MR_Integer) 1))));
      ProcDynamics_11 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep_5, (MR_Integer) 3))));
      succeeded = profile__valid_proc_dynamic_ptr_raw_2_p_0(ProcDynamics_11, PDPtr_10);
      if (succeeded)
      {
        MR_Word PD_12;

        profile__lookup_proc_dynamics_3_p_0(ProcDynamics_11, PDPtr_10, &PD_12);
        PSPtr_13 = ((MR_Word) ((MR_hl_field(MR_mktag(0), PD_12, (MR_Integer) 0))));
      }
      else
        PSPtr_13 = (MR_Word) (((MR_Box) ((MR_Integer) 0)));
      succeeded = mercury__map__search_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_static_ptr_0), (MR_Word) (&canonical_scalar_common_1[4]), STATE_VARIABLE_ProcMap_0_15, ((MR_Box) (PSPtr_13)), &conv0_CSDPtrs0_14);
      if (succeeded)
      {
        CSDPtrs0_14 = ((MR_Word) (conv0_CSDPtrs0_14));
        succeeded = MR_TRUE;
      }
      if (succeeded)
      {
        MR_Word Var_18;

        {
          Var_18 = (MR_Word) MR_mkword(MR_mktag(1), MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL));
          MR_hl_field(MR_mktag(1), Var_18, 0) = ((MR_Box) (CSDPtr_6));
          MR_hl_field(MR_mktag(1), Var_18, 1) = ((MR_Box) (CSDPtrs0_14));
        }
        mercury__map__det_update_4_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_static_ptr_0), (MR_Word) (&canonical_scalar_common_1[4]), ((MR_Box) (PSPtr_13)), ((MR_Box) (Var_18)), STATE_VARIABLE_ProcMap_0_15, STATE_VARIABLE_ProcMap_16);
      }
      else
      {
        MR_Word Var_20;

        {
          Var_20 = (MR_Word) MR_mkword(MR_mktag(1), MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL));
          MR_hl_field(MR_mktag(1), Var_20, 0) = ((MR_Box) (CSDPtr_6));
          MR_hl_field(MR_mktag(1), Var_20, 1) = ((MR_Box) ((MR_Unsigned) 0U));
        }
        mercury__map__det_insert_4_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_static_ptr_0), (MR_Word) (&canonical_scalar_common_1[4]), ((MR_Box) (PSPtr_13)), ((MR_Box) (Var_20)), STATE_VARIABLE_ProcMap_0_15, STATE_VARIABLE_ProcMap_16);
      }
    }
    else
      *STATE_VARIABLE_ProcMap_16 = STATE_VARIABLE_ProcMap_0_15;
  }
}

static void MR_CALL 
canonical__cluster_pds_by_ps_4_p_0(
  MR_Word InitDeep_5,
  MR_Word PDPtr_6,
  MR_Word STATE_VARIABLE_ProcMap_0_12,
  MR_Word * STATE_VARIABLE_ProcMap_13)
{
  {
    MR_bool succeeded;
    MR_ArrayPtr ProcDynamics_8 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep_5, (MR_Integer) 3))));

    succeeded = profile__valid_proc_dynamic_ptr_raw_2_p_0(ProcDynamics_8, PDPtr_6);
    if (succeeded)
    {
      MR_Word PD_9;
      MR_Word PSPtr_10;
      MR_Word PDPtrs0_11;
      MR_Box conv0_PDPtrs0_11;

      profile__lookup_proc_dynamics_3_p_0(ProcDynamics_8, PDPtr_6, &PD_9);
      PSPtr_10 = ((MR_Word) ((MR_hl_field(MR_mktag(0), PD_9, (MR_Integer) 0))));
      succeeded = mercury__map__search_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_static_ptr_0), (MR_Word) (&canonical_scalar_common_1[0]), STATE_VARIABLE_ProcMap_0_12, ((MR_Box) (PSPtr_10)), &conv0_PDPtrs0_11);
      if (succeeded)
      {
        PDPtrs0_11 = ((MR_Word) (conv0_PDPtrs0_11));
        succeeded = MR_TRUE;
      }
      if (succeeded)
      {
        MR_Word Var_14;

        {
          Var_14 = (MR_Word) MR_mkword(MR_mktag(1), MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL));
          MR_hl_field(MR_mktag(1), Var_14, 0) = ((MR_Box) (PDPtr_6));
          MR_hl_field(MR_mktag(1), Var_14, 1) = ((MR_Box) (PDPtrs0_11));
        }
        mercury__map__det_update_4_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_static_ptr_0), (MR_Word) (&canonical_scalar_common_1[0]), ((MR_Box) (PSPtr_10)), ((MR_Box) (Var_14)), STATE_VARIABLE_ProcMap_0_12, STATE_VARIABLE_ProcMap_13);
      }
      else
      {
        MR_Word Var_16;

        {
          Var_16 = (MR_Word) MR_mkword(MR_mktag(1), MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL));
          MR_hl_field(MR_mktag(1), Var_16, 0) = ((MR_Box) (PDPtr_6));
          MR_hl_field(MR_mktag(1), Var_16, 1) = ((MR_Box) ((MR_Unsigned) 0U));
        }
        mercury__map__det_insert_4_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_static_ptr_0), (MR_Word) (&canonical_scalar_common_1[0]), ((MR_Box) (PSPtr_10)), ((MR_Box) (Var_16)), STATE_VARIABLE_ProcMap_0_12, STATE_VARIABLE_ProcMap_13);
      }
    }
    else
      *STATE_VARIABLE_ProcMap_13 = STATE_VARIABLE_ProcMap_0_12;
  }
}

static MR_bool MR_CALL 
canonical__two_or_more_1_p_0(
  MR_Word HeadVar__1_1)
{
  {
    MR_bool succeeded = (HeadVar__1_1 != (MR_Word) ((MR_Unsigned) 0U));
    MR_Word Var_5;

    if (succeeded)
    {
      Var_5 = ((MR_Word) ((MR_hl_field(MR_mktag(1), HeadVar__1_1, (MR_Integer) 1))));
      succeeded = (Var_5 != (MR_Word) ((MR_Unsigned) 0U));
      if (succeeded)
      {
      }
    }
    return succeeded;
  }
}

static void MR_CALL 
canonical__union_cliques_4_p_0(
  MR_Word MergeInfo_5,
  MR_Word PDPtr_6,
  MR_Word STATE_VARIABLE_CliqueUnion_0_10,
  MR_Word * STATE_VARIABLE_CliqueUnion_11)
{
  {
    MR_bool succeeded;
    MR_Integer Var_12 = (MR_Integer) (PDPtr_6);

    succeeded = (Var_12 == (MR_Integer) 0);
    if (succeeded)
      *STATE_VARIABLE_CliqueUnion_11 = STATE_VARIABLE_CliqueUnion_0_10;
    else
    {
      MR_Word CliquePtr_8;
      MR_Word Members_9;
      MR_ArrayPtr Var_13 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), MergeInfo_5, (MR_Integer) 1))));
      MR_ArrayPtr Var_14;

      profile__lookup_clique_index_3_p_0(Var_13, PDPtr_6, &CliquePtr_8);
      Var_14 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), MergeInfo_5, (MR_Integer) 0))));
      profile__lookup_clique_members_3_p_0(Var_14, CliquePtr_8, &Members_9);
      mercury__set__insert_list_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), Members_9, STATE_VARIABLE_CliqueUnion_0_10, STATE_VARIABLE_CliqueUnion_11);
    }
  }
}

static MR_bool MR_CALL 
canonical__merge_multi_slot_cluster_10_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1)
{
  {
    MR_bool succeeded;
    MR_Box closure = closure_arg;

    succeeded = profile__valid_call_site_dynamic_ptr_raw_2_p_0(((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)));
    return succeeded;
  }
}

static void MR_CALL 
canonical__merge_multi_slot_cluster_10_p_0(
  MR_Word MergeInfo_11,
  MR_Word ParentPDPtr_12,
  MR_Word Clique_13,
  MR_Word ClusterCSDPtrs_14,
  MR_Word PrimeCSDPtrs0_15,
  MR_Word * PrimeCSDPtrs_16,
  MR_Word InitDeep0_17,
  MR_Word * InitDeep_18,
  MR_Word Redirect0_19,
  MR_Word * Redirect_20)
{
  {
    MR_bool succeeded;
    MR_Word PrimeCSDPtr_21;
    MR_ArrayPtr CallSiteDynamics0_33 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep0_17, (MR_Integer) 2))));
    MR_Word ValidCSDPtrs_34;
    MR_Word Var_42;

    {
      Var_42 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), Var_42, 0) = ((MR_Box) (&canonical_scalar_common_7[0]));
      MR_hl_field(MR_mktag(0), Var_42, 1) = ((MR_Box) (canonical__merge_multi_slot_cluster_10_p_0_1));
      MR_hl_field(MR_mktag(0), Var_42, 2) = ((MR_Box) ((MR_Integer) 1));
      MR_hl_field(MR_mktag(0), Var_42, 3) = ((MR_Box) (CallSiteDynamics0_33));
    }
    mercury__list__filter_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), Var_42, ClusterCSDPtrs_14, &ValidCSDPtrs_34);
    if ((ValidCSDPtrs_34 == (MR_Word) ((MR_Unsigned) 0U)))
    {
      PrimeCSDPtr_21 = (MR_Word) (((MR_Box) ((MR_Integer) 0)));
      *InitDeep_18 = InitDeep0_17;
      *Redirect_20 = Redirect0_19;
    }
    else
    {
      MR_Word LaterCSDPtrs_36;
      MR_Word FirstCSD0_37;
      MR_Word FirstCSD_38;
      MR_ArrayPtr CallSiteDynamics_39;
      MR_ArrayPtr Var_43;
      MR_Word STATE_VARIABLE_InitDeep_32_44;
      MR_Word Var_54;
      MR_Word Var_55;
      MR_Box conv0_Var_43;
      MR_Word Var_56;
      MR_Word Var_57;
      MR_ArrayPtr Var_59;
      MR_ArrayPtr Var_60;
      MR_ArrayPtr Var_61;

      PrimeCSDPtr_21 = ((MR_Word) ((MR_hl_field(MR_mktag(1), ValidCSDPtrs_34, (MR_Integer) 0))));
      LaterCSDPtrs_36 = ((MR_Word) ((MR_hl_field(MR_mktag(1), ValidCSDPtrs_34, (MR_Integer) 1))));
      profile__lookup_call_site_dynamics_3_p_0(CallSiteDynamics0_33, PrimeCSDPtr_21, &FirstCSD0_37);
      Var_54 = ((MR_Word) ((MR_hl_field(MR_mktag(0), FirstCSD0_37, (MR_Integer) 1))));
      Var_55 = ((MR_Word) ((MR_hl_field(MR_mktag(0), FirstCSD0_37, (MR_Integer) 2))));
      {
        FirstCSD_38 = (MR_Word) MR_new_object(MR_Word, (3 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), FirstCSD_38, 0) = ((MR_Box) (ParentPDPtr_12));
        MR_hl_field(MR_mktag(0), FirstCSD_38, 1) = ((MR_Box) (Var_54));
        MR_hl_field(MR_mktag(0), FirstCSD_38, 2) = ((MR_Box) (Var_55));
      }
      conv0_Var_43 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[5]), ((MR_Box) (CallSiteDynamics0_33)));
      Var_43 = ((MR_ArrayPtr) (conv0_Var_43));
      profile__update_call_site_dynamics_4_p_0(PrimeCSDPtr_21, FirstCSD_38, Var_43, &CallSiteDynamics_39);
      Var_56 = ((MR_Word) ((MR_hl_field(MR_mktag(0), InitDeep0_17, (MR_Integer) 0))));
      Var_57 = ((MR_Word) ((MR_hl_field(MR_mktag(0), InitDeep0_17, (MR_Integer) 1))));
      Var_59 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep0_17, (MR_Integer) 3))));
      Var_60 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep0_17, (MR_Integer) 4))));
      Var_61 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep0_17, (MR_Integer) 5))));
      {
        STATE_VARIABLE_InitDeep_32_44 = (MR_Word) MR_new_object(MR_Word, (6 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_32_44, 0) = ((MR_Box) (Var_56));
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_32_44, 1) = ((MR_Box) (Var_57));
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_32_44, 2) = ((MR_Box) (CallSiteDynamics_39));
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_32_44, 3) = ((MR_Box) (Var_59));
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_32_44, 4) = ((MR_Box) (Var_60));
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_32_44, 5) = ((MR_Box) (Var_61));
      }
      if ((LaterCSDPtrs_36 == (MR_Word) ((MR_Unsigned) 0U)))
      {
        *InitDeep_18 = STATE_VARIABLE_InitDeep_32_44;
        *Redirect_20 = Redirect0_19;
      }
      else
        canonical__merge_call_site_dynamics_2_8_p_0(MergeInfo_11, Clique_13, PrimeCSDPtr_21, LaterCSDPtrs_36, STATE_VARIABLE_InitDeep_32_44, InitDeep_18, Redirect0_19, Redirect_20);
    }
    {
      MR_Word base;
      base = (MR_Word) MR_mkword(MR_mktag(1), MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL));
      *PrimeCSDPtrs_16 = base;
      MR_hl_field(MR_mktag(1), base, 0) = ((MR_Box) (PrimeCSDPtr_21));
      MR_hl_field(MR_mktag(1), base, 1) = ((MR_Box) (PrimeCSDPtrs0_15));
    }
  }
}

static void MR_CALL 
canonical__accumulate_csd_owns_3_p_0(
  MR_Word CSD_4,
  MR_Word Own0_5,
  MR_Word * Own_6)
{
  {
    MR_Word Var_7 = ((MR_Word) ((MR_hl_field(MR_mktag(0), CSD_4, (MR_Integer) 2))));

    *Own_6 = measurements__add_own_to_own_2_f_0(Own0_5, Var_7);
  }
}

static void MR_CALL 
canonical__merge_proc_dynamics_ignore_chosen_7_p_0_4(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2)
{
  {
    MR_Box closure = closure_arg;
    MR_ArrayPtr conv1_HeadVar__2_2;

    profile__extract_pd_sites_2_p_0(((MR_Word) (wrapper_arg_1)), &conv1_HeadVar__2_2);
    *wrapper_arg_2 = ((MR_Box) (conv1_HeadVar__2_2));
  }
}

static void MR_CALL 
canonical__merge_proc_dynamics_ignore_chosen_7_p_0_3(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv0_HeadVar__3_3;

    profile__lookup_proc_dynamics_3_p_0(((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)), &conv0_HeadVar__3_3);
    *wrapper_arg_2 = ((MR_Box) (conv0_HeadVar__3_3));
  }
}

static MR_bool MR_CALL 
canonical__merge_proc_dynamics_ignore_chosen_7_p_0_2(
  MR_Box closure_arg)
{
  {
    MR_bool succeeded;
    MR_Box closure = closure_arg;

    succeeded = canonical__IntroducedFrom__pred__merge_proc_dynamics__241__1_2_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 4)))));
    return succeeded;
  }
}

static MR_bool MR_CALL 
canonical__merge_proc_dynamics_ignore_chosen_7_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1)
{
  {
    MR_bool succeeded;
    MR_Box closure = closure_arg;

    succeeded = profile__valid_proc_dynamic_ptr_raw_2_p_0(((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)));
    return succeeded;
  }
}

static void MR_CALL 
canonical__merge_proc_dynamics_ignore_chosen_7_p_0(
  MR_Word MergeInfo_8,
  MR_Word Clique_9,
  MR_Word CandidatePDPtrs_10,
  MR_Word STATE_VARIABLE_InitDeep_0_14,
  MR_Word * STATE_VARIABLE_InitDeep_15,
  MR_Word STATE_VARIABLE_Redirect_0_16,
  MR_Word * STATE_VARIABLE_Redirect_17)
{
  {
    MR_bool succeeded;
    MR_ArrayPtr ProcDynamics0_30 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_0_14, (MR_Integer) 3))));
    MR_Word ValidPDPtrs_31;
    MR_Word InvalidPDPtrs_32;
    MR_Word Var_44;
    MR_Word Var_45;

    {
      Var_44 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), Var_44, 0) = ((MR_Box) (&canonical_scalar_common_7[1]));
      MR_hl_field(MR_mktag(0), Var_44, 1) = ((MR_Box) (canonical__merge_proc_dynamics_ignore_chosen_7_p_0_1));
      MR_hl_field(MR_mktag(0), Var_44, 2) = ((MR_Box) ((MR_Integer) 1));
      MR_hl_field(MR_mktag(0), Var_44, 3) = ((MR_Box) (ProcDynamics0_30));
    }
    mercury__list__filter_4_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), Var_44, CandidatePDPtrs_10, &ValidPDPtrs_31, &InvalidPDPtrs_32);
    {
      Var_45 = (MR_Word) MR_new_object(MR_Word, (5 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), Var_45, 0) = ((MR_Box) (&canonical_scalar_common_7[2]));
      MR_hl_field(MR_mktag(0), Var_45, 1) = ((MR_Box) (canonical__merge_proc_dynamics_ignore_chosen_7_p_0_2));
      MR_hl_field(MR_mktag(0), Var_45, 2) = ((MR_Box) ((MR_Integer) 2));
      MR_hl_field(MR_mktag(0), Var_45, 3) = ((MR_Box) (InvalidPDPtrs_32));
      MR_hl_field(MR_mktag(0), Var_45, 4) = ((MR_Box) ((MR_Unsigned) 0U));
    }
    mercury__require__require_2_p_0(Var_45, (MR_String) "merge_proc_dynamics: invalid pdptrs");
    if ((ValidPDPtrs_31 == (MR_Word) ((MR_Unsigned) 0U)))
      {
        mercury__require__unexpected_2_p_0((MR_String) "predicate \140canonical.merge_proc_dynamics\'/8", (MR_String) "no valid pdptrs");
        return;
      }
    else
    {
      MR_Word _ChosenPDPtr_13 = ((MR_Word) ((MR_hl_field(MR_mktag(1), ValidPDPtrs_31, (MR_Integer) 0))));
      MR_Word RestPDPtrs_34 = ((MR_Word) ((MR_hl_field(MR_mktag(1), ValidPDPtrs_31, (MR_Integer) 1))));
      MR_Word PrimePD0_35;
      MR_Word RestPDs_36;
      MR_Word RestSites_37;
      MR_ArrayPtr PrimeSites0_38;
      MR_Integer MaxSiteNum_39;
      MR_ArrayPtr PrimeSites_40;
      MR_Word PrimePD_41;
      MR_ArrayPtr ProcDynamics1_42;
      MR_ArrayPtr ProcDynamics_43;
      MR_Word STATE_VARIABLE_Redirect_39_50;
      MR_Word Var_51;
      MR_ArrayPtr Var_53;
      MR_Word STATE_VARIABLE_InitDeep_43_54;
      MR_ArrayPtr Var_56;
      MR_Box conv2_Var_53;
      MR_Word Var_65;
      MR_Word Var_67;
      MR_Box conv3_Var_56;
      MR_Word Var_73;
      MR_Word Var_74;
      MR_ArrayPtr Var_75;
      MR_ArrayPtr Var_77;
      MR_ArrayPtr Var_78;

      canonical__record_pd_redirect_4_p_0(RestPDPtrs_34, _ChosenPDPtr_13, STATE_VARIABLE_Redirect_0_16, &STATE_VARIABLE_Redirect_39_50);
      profile__lookup_proc_dynamics_3_p_0(ProcDynamics0_30, _ChosenPDPtr_13, &PrimePD0_35);
      {
        Var_51 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), Var_51, 0) = ((MR_Box) (&canonical_scalar_common_3[5]));
        MR_hl_field(MR_mktag(0), Var_51, 1) = ((MR_Box) (canonical__merge_proc_dynamics_ignore_chosen_7_p_0_3));
        MR_hl_field(MR_mktag(0), Var_51, 2) = ((MR_Box) ((MR_Integer) 1));
        MR_hl_field(MR_mktag(0), Var_51, 3) = ((MR_Box) (ProcDynamics0_30));
      }
      mercury__list__map_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), (MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_0), Var_51, RestPDPtrs_34, &RestPDs_36);
      mercury__list__map_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_0), (MR_Word) (&canonical_scalar_common_1[2]), (MR_Word) (&canonical_scalar_common_2[9]), RestPDs_36, &RestSites_37);
      PrimeSites0_38 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), PrimePD0_35, (MR_Integer) 1))));
      mercury__array__max_2_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_array_slot_0), (MR_ArrayPtr) (PrimeSites0_38), &MaxSiteNum_39);
      conv2_Var_53 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[2]), ((MR_Box) (PrimeSites0_38)));
      Var_53 = ((MR_ArrayPtr) (conv2_Var_53));
      canonical__merge_proc_dynamic_slots_11_p_0(MergeInfo_8, MaxSiteNum_39, Clique_9, _ChosenPDPtr_13, Var_53, RestSites_37, &PrimeSites_40, STATE_VARIABLE_InitDeep_0_14, &STATE_VARIABLE_InitDeep_43_54, STATE_VARIABLE_Redirect_39_50, STATE_VARIABLE_Redirect_17);
      Var_65 = ((MR_Word) ((MR_hl_field(MR_mktag(0), PrimePD0_35, (MR_Integer) 0))));
      Var_67 = ((MR_Word) ((MR_hl_field(MR_mktag(0), PrimePD0_35, (MR_Integer) 2))));
      {
        PrimePD_41 = (MR_Word) MR_new_object(MR_Word, (3 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), PrimePD_41, 0) = ((MR_Box) (Var_65));
        MR_hl_field(MR_mktag(0), PrimePD_41, 1) = ((MR_Box) (PrimeSites_40));
        MR_hl_field(MR_mktag(0), PrimePD_41, 2) = ((MR_Box) (Var_67));
      }
      ProcDynamics1_42 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_43_54, (MR_Integer) 3))));
      conv3_Var_56 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[3]), ((MR_Box) (ProcDynamics1_42)));
      Var_56 = ((MR_ArrayPtr) (conv3_Var_56));
      profile__update_proc_dynamics_4_p_0(_ChosenPDPtr_13, PrimePD_41, Var_56, &ProcDynamics_43);
      Var_73 = ((MR_Word) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_43_54, (MR_Integer) 0))));
      Var_74 = ((MR_Word) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_43_54, (MR_Integer) 1))));
      Var_75 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_43_54, (MR_Integer) 2))));
      Var_77 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_43_54, (MR_Integer) 4))));
      Var_78 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_43_54, (MR_Integer) 5))));
      {
        MR_Word base;
        base = (MR_Word) MR_new_object(MR_Word, (6 * sizeof(MR_Word)), NULL, NULL);
        *STATE_VARIABLE_InitDeep_15 = base;
        MR_hl_field(MR_mktag(0), base, 0) = ((MR_Box) (Var_73));
        MR_hl_field(MR_mktag(0), base, 1) = ((MR_Box) (Var_74));
        MR_hl_field(MR_mktag(0), base, 2) = ((MR_Box) (Var_75));
        MR_hl_field(MR_mktag(0), base, 3) = ((MR_Box) (ProcDynamics_43));
        MR_hl_field(MR_mktag(0), base, 4) = ((MR_Box) (Var_77));
        MR_hl_field(MR_mktag(0), base, 5) = ((MR_Box) (Var_78));
      }
    }
  }
}

static void MR_CALL 
canonical__merge_call_site_dynamics_descendants_8_p_0_3(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv2_STATE_VARIABLE_CliqueUnion_11;

    canonical__union_cliques_4_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)), ((MR_Word) (wrapper_arg_2)), &conv2_STATE_VARIABLE_CliqueUnion_11);
    *wrapper_arg_3 = ((MR_Box) (conv2_STATE_VARIABLE_CliqueUnion_11));
  }
}

static void MR_CALL 
canonical__merge_call_site_dynamics_descendants_8_p_0_2(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv1_HeadVar__2_2;

    profile__extract_csd_callee_2_p_0(((MR_Word) (wrapper_arg_1)), &conv1_HeadVar__2_2);
    *wrapper_arg_2 = ((MR_Box) (conv1_HeadVar__2_2));
  }
}

static void MR_CALL 
canonical__merge_call_site_dynamics_descendants_8_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv0_HeadVar__3_3;

    profile__lookup_call_site_dynamics_3_p_0(((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)), &conv0_HeadVar__3_3);
    *wrapper_arg_2 = ((MR_Box) (conv0_HeadVar__3_3));
  }
}

static void MR_CALL 
canonical__merge_call_site_dynamics_descendants_8_p_0(
  MR_Word MergeInfo_9,
  MR_Word PrimeCSDPtr_10,
  MR_Word RestCSDPtrs_11,
  MR_Word * ChosenPDPtr_12,
  MR_Word STATE_VARIABLE_InitDeep_0_22,
  MR_Word * STATE_VARIABLE_InitDeep_23,
  MR_Word STATE_VARIABLE_Redirect_0_24,
  MR_Word * STATE_VARIABLE_Redirect_25)
{
  {
    MR_ArrayPtr CallSiteDynamics_15 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_0_22, (MR_Integer) 2))));
    MR_Word PrimeCSD_16;
    MR_Word PrimeCSDCallee_17;
    MR_Word RestCSDs_18;
    MR_Word RestCSDCallees_19;
    MR_Word PDPtrs_20;
    MR_Word CliqueUnion_21;
    MR_Word Var_26;
    MR_Word Var_28;
    MR_Word Var_29;
    MR_Box conv3_CliqueUnion_21;

    profile__lookup_call_site_dynamics_3_p_0(CallSiteDynamics_15, PrimeCSDPtr_10, &PrimeCSD_16);
    profile__extract_csd_callee_2_p_0(PrimeCSD_16, &PrimeCSDCallee_17);
    {
      Var_26 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), Var_26, 0) = ((MR_Box) (&canonical_scalar_common_3[8]));
      MR_hl_field(MR_mktag(0), Var_26, 1) = ((MR_Box) (canonical__merge_call_site_dynamics_descendants_8_p_0_1));
      MR_hl_field(MR_mktag(0), Var_26, 2) = ((MR_Box) ((MR_Integer) 1));
      MR_hl_field(MR_mktag(0), Var_26, 3) = ((MR_Box) (CallSiteDynamics_15));
    }
    mercury__list__map_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), (MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_0), Var_26, RestCSDPtrs_11, &RestCSDs_18);
    mercury__list__map_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_0), (MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), (MR_Word) (&canonical_scalar_common_2[8]), RestCSDs_18, &RestCSDCallees_19);
    {
      PDPtrs_20 = (MR_Word) MR_mkword(MR_mktag(1), MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL));
      MR_hl_field(MR_mktag(1), PDPtrs_20, 0) = ((MR_Box) (PrimeCSDCallee_17));
      MR_hl_field(MR_mktag(1), PDPtrs_20, 1) = ((MR_Box) (RestCSDCallees_19));
    }
    {
      Var_28 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), Var_28, 0) = ((MR_Box) (&canonical_scalar_common_5[2]));
      MR_hl_field(MR_mktag(0), Var_28, 1) = ((MR_Box) (canonical__merge_call_site_dynamics_descendants_8_p_0_3));
      MR_hl_field(MR_mktag(0), Var_28, 2) = ((MR_Box) ((MR_Integer) 1));
      MR_hl_field(MR_mktag(0), Var_28, 3) = ((MR_Box) (MergeInfo_9));
    }
    Var_29 = mercury__set__init_0_f_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0));
    mercury__list__foldl_4_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), (MR_Word) (&canonical_scalar_common_1[1]), Var_28, PDPtrs_20, ((MR_Box) (Var_29)), &conv3_CliqueUnion_21);
    CliqueUnion_21 = ((MR_Word) (conv3_CliqueUnion_21));
    canonical__merge_proc_dynamics_8_p_0(MergeInfo_9, CliqueUnion_21, PDPtrs_20, ChosenPDPtr_12, STATE_VARIABLE_InitDeep_0_22, STATE_VARIABLE_InitDeep_23, STATE_VARIABLE_Redirect_0_24, STATE_VARIABLE_Redirect_25);
  }
}

static void MR_CALL 
canonical__merge_proc_dynamic_slots_11_p_0_2(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3,
  MR_Box wrapper_arg_4,
  MR_Box * wrapper_arg_5,
  MR_Box wrapper_arg_6,
  MR_Box * wrapper_arg_7)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv5_PrimeCSDPtrs_16;
    MR_Word conv4_InitDeep_18;
    MR_Word conv3_Redirect_20;

    canonical__merge_multi_slot_cluster_10_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 4)))), ((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 5)))), ((MR_Word) (wrapper_arg_1)), ((MR_Word) (wrapper_arg_2)), &conv5_PrimeCSDPtrs_16, ((MR_Word) (wrapper_arg_4)), &conv4_InitDeep_18, ((MR_Word) (wrapper_arg_6)), &conv3_Redirect_20);
    *wrapper_arg_3 = ((MR_Box) (conv5_PrimeCSDPtrs_16));
    *wrapper_arg_5 = ((MR_Box) (conv4_InitDeep_18));
    *wrapper_arg_7 = ((MR_Box) (conv3_Redirect_20));
  }
}

static void MR_CALL 
canonical__merge_proc_dynamic_slots_11_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv1_STATE_VARIABLE_ProcMap_16;

    canonical__cluster_csds_by_ps_4_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)), ((MR_Word) (wrapper_arg_2)), &conv1_STATE_VARIABLE_ProcMap_16);
    *wrapper_arg_3 = ((MR_Box) (conv1_STATE_VARIABLE_ProcMap_16));
  }
}

static void MR_CALL 
canonical__merge_proc_dynamic_slots_11_p_0(
  MR_Word MergeInfo_12,
  MR_Integer SlotNum_13,
  MR_Word Clique_14,
  MR_Word PrimePDPtr_15,
  MR_ArrayPtr STATE_VARIABLE_PrimeSiteArray_0_28,
  MR_Word RestSiteArrays_17,
  MR_ArrayPtr * STATE_VARIABLE_PrimeSiteArray_29,
  MR_Word STATE_VARIABLE_InitDeep_0_30,
  MR_Word * STATE_VARIABLE_InitDeep_31,
  MR_Word STATE_VARIABLE_Redirect_0_32,
  MR_Word * STATE_VARIABLE_Redirect_33)
{
  while (MR_TRUE)
  {
    MR_bool succeeded = (SlotNum_13 >= (MR_Integer) 0);

    // setup for model_det tailcalls optimized into a loop
    ;
    if (succeeded)
    {
      MR_Word PrimeSite0_20;
      MR_Word STATE_VARIABLE_InitDeep_39_39;
      MR_Word STATE_VARIABLE_Redirect_40_40;
      MR_ArrayPtr STATE_VARIABLE_PrimeSiteArray_42_42;
      MR_Integer Var_43;
      MR_Box conv0_PrimeSite0_20;
      MR_Integer next_value_of_SlotNum_13;
      MR_ArrayPtr next_value_of_STATE_VARIABLE_PrimeSiteArray_0_28;
      MR_Word next_value_of_STATE_VARIABLE_InitDeep_0_30;
      MR_Word next_value_of_STATE_VARIABLE_Redirect_0_32;

      mercury__array__lookup_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_array_slot_0), (MR_ArrayPtr) (STATE_VARIABLE_PrimeSiteArray_0_28), SlotNum_13, &conv0_PrimeSite0_20);
      PrimeSite0_20 = ((MR_Word) (conv0_PrimeSite0_20));
      if (((MR_tag((MR_Word) PrimeSite0_20)) == (MR_Integer) 1))
      {
        MR_Word IsZeroed_23 = ((MR_Unsigned) ((MR_hl_field(MR_mktag(1), PrimeSite0_20, (MR_Integer) 0))) & (MR_Integer) 1);
        MR_ArrayPtr PrimeCSDPtrArray0_24 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(1), PrimeSite0_20, (MR_Integer) 1))));
        MR_Word PrimeCSDPtrList0_25;
        MR_Word PrimeCSDPtrList_26;
        MR_ArrayPtr PrimeCSDPtrArray_27;
        MR_Word Var_37;
        MR_Word RestCSDPtrLists_63;
        MR_Word AllCSDPtrs_64;
        MR_Word ProcMap0_65;
        MR_Word ProcMap_66;
        MR_Word CSDPtrsClusters_67;
        MR_Word Var_68;
        MR_Word Var_69;
        MR_Word Var_70;
        MR_Box conv2_ProcMap_66;
        MR_Box conv8_PrimeCSDPtrList_26;
        MR_Box conv7_STATE_VARIABLE_InitDeep_39_39;
        MR_Box conv6_STATE_VARIABLE_Redirect_40_40;
        MR_ArrayPtr conv9_PrimeCSDPtrArray_27;
        MR_ArrayPtr conv10_STATE_VARIABLE_PrimeSiteArray_42_42;

        mercury__array__to_list_2_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), (MR_ArrayPtr) (PrimeCSDPtrArray0_24), &PrimeCSDPtrList0_25);
        canonical__lookup_multi_sites_3_p_0(RestSiteArrays_17, SlotNum_13, &RestCSDPtrLists_63);
        {
          Var_68 = (MR_Word) MR_mkword(MR_mktag(1), MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL));
          MR_hl_field(MR_mktag(1), Var_68, 0) = ((MR_Box) (PrimeCSDPtrList0_25));
          MR_hl_field(MR_mktag(1), Var_68, 1) = ((MR_Box) (RestCSDPtrLists_63));
        }
        mercury__list__condense_2_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), Var_68, &AllCSDPtrs_64);
        mercury__map__init_1_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_static_ptr_0), (MR_Word) (&canonical_scalar_common_1[4]), &ProcMap0_65);
        {
          Var_69 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
          MR_hl_field(MR_mktag(0), Var_69, 0) = ((MR_Box) (&canonical_scalar_common_5[1]));
          MR_hl_field(MR_mktag(0), Var_69, 1) = ((MR_Box) (canonical__merge_proc_dynamic_slots_11_p_0_1));
          MR_hl_field(MR_mktag(0), Var_69, 2) = ((MR_Box) ((MR_Integer) 1));
          MR_hl_field(MR_mktag(0), Var_69, 3) = ((MR_Box) (STATE_VARIABLE_InitDeep_0_30));
        }
        mercury__list__foldl_4_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), (MR_Word) (&canonical_scalar_common_2[2]), Var_69, AllCSDPtrs_64, ((MR_Box) (ProcMap0_65)), &conv2_ProcMap_66);
        ProcMap_66 = ((MR_Word) (conv2_ProcMap_66));
        mercury__map__values_2_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_static_ptr_0), (MR_Word) (&canonical_scalar_common_1[4]), ProcMap_66, &CSDPtrsClusters_67);
        {
          Var_70 = (MR_Word) MR_new_object(MR_Word, (6 * sizeof(MR_Word)), NULL, NULL);
          MR_hl_field(MR_mktag(0), Var_70, 0) = ((MR_Box) (&canonical_scalar_common_8[0]));
          MR_hl_field(MR_mktag(0), Var_70, 1) = ((MR_Box) (canonical__merge_proc_dynamic_slots_11_p_0_2));
          MR_hl_field(MR_mktag(0), Var_70, 2) = ((MR_Box) ((MR_Integer) 3));
          MR_hl_field(MR_mktag(0), Var_70, 3) = ((MR_Box) (MergeInfo_12));
          MR_hl_field(MR_mktag(0), Var_70, 4) = ((MR_Box) (PrimePDPtr_15));
          MR_hl_field(MR_mktag(0), Var_70, 5) = ((MR_Box) (Clique_14));
        }
        mercury__list__foldl3_8_p_0((MR_Word) (&canonical_scalar_common_1[4]), (MR_Word) (&canonical_scalar_common_1[4]), (MR_Word) (&profile__profile__type_ctor_info_initial_deep_0), (MR_Word) (&canonical__canonical__type_ctor_info_redirect_0), Var_70, CSDPtrsClusters_67, ((MR_Box) ((MR_Unsigned) 0U)), &conv8_PrimeCSDPtrList_26, ((MR_Box) (STATE_VARIABLE_InitDeep_0_30)), &conv7_STATE_VARIABLE_InitDeep_39_39, ((MR_Box) (STATE_VARIABLE_Redirect_0_32)), &conv6_STATE_VARIABLE_Redirect_40_40);
        PrimeCSDPtrList_26 = ((MR_Word) (conv8_PrimeCSDPtrList_26));
        STATE_VARIABLE_InitDeep_39_39 = ((MR_Word) (conv7_STATE_VARIABLE_InitDeep_39_39));
        STATE_VARIABLE_Redirect_40_40 = ((MR_Word) (conv6_STATE_VARIABLE_Redirect_40_40));
        conv9_PrimeCSDPtrArray_27 = mercury__array__array_1_f_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), PrimeCSDPtrList_26);
        PrimeCSDPtrArray_27 = (MR_ArrayPtr) (conv9_PrimeCSDPtrArray_27);
        {
          Var_37 = (MR_Word) MR_mkword(MR_mktag(1), MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL));
          MR_hl_field(MR_mktag(1), Var_37, 0) = (MR_Box) ((MR_Unsigned) (IsZeroed_23));
          MR_hl_field(MR_mktag(1), Var_37, 1) = ((MR_Box) (PrimeCSDPtrArray_27));
        }
        mercury__array__set_4_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_array_slot_0), SlotNum_13, ((MR_Box) (Var_37)), (MR_ArrayPtr) (STATE_VARIABLE_PrimeSiteArray_0_28), &conv10_STATE_VARIABLE_PrimeSiteArray_42_42);
        STATE_VARIABLE_PrimeSiteArray_42_42 = (MR_ArrayPtr) (conv10_STATE_VARIABLE_PrimeSiteArray_42_42);
      }
      else
      {
        MR_Word PrimeCSDPtr0_21 = ((MR_Word) ((MR_hl_field(MR_mktag(0), PrimeSite0_20, (MR_Integer) 0))));
        MR_Word PrimeCSDPtr_22;
        MR_Word Var_41;
        MR_ArrayPtr conv11_STATE_VARIABLE_PrimeSiteArray_42_42;

        canonical__merge_proc_dynamic_normal_slot_11_p_0(MergeInfo_12, SlotNum_13, Clique_14, PrimePDPtr_15, PrimeCSDPtr0_21, RestSiteArrays_17, &PrimeCSDPtr_22, STATE_VARIABLE_InitDeep_0_30, &STATE_VARIABLE_InitDeep_39_39, STATE_VARIABLE_Redirect_0_32, &STATE_VARIABLE_Redirect_40_40);
        {
          Var_41 = (MR_Word) MR_new_object(MR_Word, (1 * sizeof(MR_Word)), NULL, NULL);
          MR_hl_field(MR_mktag(0), Var_41, 0) = ((MR_Box) (PrimeCSDPtr_22));
        }
        mercury__array__set_4_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_array_slot_0), SlotNum_13, ((MR_Box) (Var_41)), (MR_ArrayPtr) (STATE_VARIABLE_PrimeSiteArray_0_28), &conv11_STATE_VARIABLE_PrimeSiteArray_42_42);
        STATE_VARIABLE_PrimeSiteArray_42_42 = (MR_ArrayPtr) (conv11_STATE_VARIABLE_PrimeSiteArray_42_42);
      }
      Var_43 = (MR_Integer) ((MR_Unsigned) SlotNum_13 - (MR_Unsigned) 1);
      // direct tailcall eliminated
      ;
      next_value_of_SlotNum_13 = Var_43;
      next_value_of_STATE_VARIABLE_PrimeSiteArray_0_28 = STATE_VARIABLE_PrimeSiteArray_42_42;
      next_value_of_STATE_VARIABLE_InitDeep_0_30 = STATE_VARIABLE_InitDeep_39_39;
      next_value_of_STATE_VARIABLE_Redirect_0_32 = STATE_VARIABLE_Redirect_40_40;
      SlotNum_13 = next_value_of_SlotNum_13;
      STATE_VARIABLE_PrimeSiteArray_0_28 = next_value_of_STATE_VARIABLE_PrimeSiteArray_0_28;
      STATE_VARIABLE_InitDeep_0_30 = next_value_of_STATE_VARIABLE_InitDeep_0_30;
      STATE_VARIABLE_Redirect_0_32 = next_value_of_STATE_VARIABLE_Redirect_0_32;
      continue;
    }
    else
    {
      *STATE_VARIABLE_Redirect_33 = STATE_VARIABLE_Redirect_0_32;
      *STATE_VARIABLE_InitDeep_31 = STATE_VARIABLE_InitDeep_0_30;
      *STATE_VARIABLE_PrimeSiteArray_29 = STATE_VARIABLE_PrimeSiteArray_0_28;
    }
    break;
  }
}

static void MR_CALL 
canonical__merge_call_site_dynamics_2_8_p_0_6(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv4_HeadVar__3_3;

    profile__lookup_call_site_dynamics_3_p_0(((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)), &conv4_HeadVar__3_3);
    *wrapper_arg_2 = ((MR_Box) (conv4_HeadVar__3_3));
  }
}

static MR_bool MR_CALL 
canonical__merge_call_site_dynamics_2_8_p_0_5(
  MR_Box closure_arg)
{
  {
    MR_bool succeeded;
    MR_Box closure = closure_arg;

    succeeded = canonical__IntroducedFrom__pred__merge_call_site_dynamics_2__420__1_2_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 4)))));
    return succeeded;
  }
}

static void MR_CALL 
canonical__merge_call_site_dynamics_2_8_p_0_4(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv1_HeadVar__3_3;

    profile__lookup_call_site_dynamics_3_p_0(((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)), &conv1_HeadVar__3_3);
    *wrapper_arg_2 = ((MR_Box) (conv1_HeadVar__3_3));
  }
}

static MR_bool MR_CALL 
canonical__merge_call_site_dynamics_2_8_p_0_3(
  MR_Box closure_arg)
{
  {
    MR_bool succeeded;
    MR_Box closure = closure_arg;

    succeeded = canonical__IntroducedFrom__pred__merge_call_site_dynamics_2__415__1_2_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 4)))));
    return succeeded;
  }
}

static void MR_CALL 
canonical__merge_call_site_dynamics_2_8_p_0_2(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv0_Own_6;

    canonical__accumulate_csd_owns_3_p_0(((MR_Word) (wrapper_arg_1)), ((MR_Word) (wrapper_arg_2)), &conv0_Own_6);
    *wrapper_arg_3 = ((MR_Box) (conv0_Own_6));
  }
}

static MR_bool MR_CALL 
canonical__merge_call_site_dynamics_2_8_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1)
{
  {
    MR_bool succeeded;
    MR_Box closure = closure_arg;

    succeeded = canonical__callee_in_clique_3_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 4)))), ((MR_Word) (wrapper_arg_1)));
    return succeeded;
  }
}

static void MR_CALL 
canonical__merge_call_site_dynamics_2_8_p_0(
  MR_Word MergeInfo_9,
  MR_Word Clique_10,
  MR_Word PrimeCSDPtr_11,
  MR_Word RestCSDPtrs_12,
  MR_Word InitDeep0_13,
  MR_Word * InitDeep_14,
  MR_Word Redirect0_15,
  MR_Word * Redirect_16)
{
  {
    MR_bool succeeded;
    MR_Word InClique_17;
    MR_Word NotInClique_18;
    MR_Word Redirect1_20;
    MR_Word Var_35;

    {
      Var_35 = (MR_Word) MR_new_object(MR_Word, (5 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), Var_35, 0) = ((MR_Box) (&canonical_scalar_common_3[6]));
      MR_hl_field(MR_mktag(0), Var_35, 1) = ((MR_Box) (canonical__merge_call_site_dynamics_2_8_p_0_1));
      MR_hl_field(MR_mktag(0), Var_35, 2) = ((MR_Box) ((MR_Integer) 2));
      MR_hl_field(MR_mktag(0), Var_35, 3) = ((MR_Box) (InitDeep0_13));
      MR_hl_field(MR_mktag(0), Var_35, 4) = ((MR_Box) (Clique_10));
    }
    mercury__list__filter_4_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), Var_35, RestCSDPtrs_12, &InClique_17, &NotInClique_18);
    canonical__record_csd_redirect_4_p_0(RestCSDPtrs_12, PrimeCSDPtr_11, Redirect0_15, &Redirect1_20);
    succeeded = canonical__callee_in_clique_3_p_0(InitDeep0_13, Clique_10, PrimeCSDPtr_11);
    if (succeeded)
    {
      MR_ArrayPtr CallSiteDynamics0_21;
      MR_Word PrimeCSD0_22;
      MR_Word RestCSDs_23;
      MR_Word PrimeOwn0_24;
      MR_Word PrimeOwn1_25;
      MR_Word PrimeCSD1_26;
      MR_ArrayPtr CallSiteDynamics1_27;
      MR_Word Var_36;
      MR_String Var_37;
      MR_Word Var_46;
      MR_ArrayPtr Var_48;
      MR_Word Var_50;
      MR_Word Var_51;
      MR_ArrayPtr Var_52;
      MR_ArrayPtr Var_53;
      MR_ArrayPtr Var_54;
      MR_Word Var_55;
      MR_Word Var_56;
      MR_Box conv2_PrimeOwn1_25;
      MR_Box conv3_Var_48;

      {
        Var_36 = (MR_Word) MR_new_object(MR_Word, (5 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), Var_36, 0) = ((MR_Box) (&canonical_scalar_common_7[4]));
        MR_hl_field(MR_mktag(0), Var_36, 1) = ((MR_Box) (canonical__merge_call_site_dynamics_2_8_p_0_3));
        MR_hl_field(MR_mktag(0), Var_36, 2) = ((MR_Box) ((MR_Integer) 2));
        MR_hl_field(MR_mktag(0), Var_36, 3) = ((MR_Box) (NotInClique_18));
        MR_hl_field(MR_mktag(0), Var_36, 4) = ((MR_Box) ((MR_Unsigned) 0U));
      }
      Var_37 = mercury__string__f_43_43_2_f_0((MR_String) "merge_proc_dynamic_normal_slot: prime in clique, ", (MR_String) "others not in clique");
      mercury__require__require_2_p_0(Var_36, Var_37);
      Var_50 = ((MR_Word) ((MR_hl_field(MR_mktag(0), InitDeep0_13, (MR_Integer) 0))));
      Var_51 = ((MR_Word) ((MR_hl_field(MR_mktag(0), InitDeep0_13, (MR_Integer) 1))));
      CallSiteDynamics0_21 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep0_13, (MR_Integer) 2))));
      Var_52 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep0_13, (MR_Integer) 3))));
      Var_53 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep0_13, (MR_Integer) 4))));
      Var_54 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep0_13, (MR_Integer) 5))));
      profile__lookup_call_site_dynamics_3_p_0(CallSiteDynamics0_21, PrimeCSDPtr_11, &PrimeCSD0_22);
      {
        Var_46 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), Var_46, 0) = ((MR_Box) (&canonical_scalar_common_3[8]));
        MR_hl_field(MR_mktag(0), Var_46, 1) = ((MR_Box) (canonical__merge_call_site_dynamics_2_8_p_0_4));
        MR_hl_field(MR_mktag(0), Var_46, 2) = ((MR_Box) ((MR_Integer) 1));
        MR_hl_field(MR_mktag(0), Var_46, 3) = ((MR_Box) (CallSiteDynamics0_21));
      }
      mercury__list__map_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), (MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_0), Var_46, RestCSDPtrs_12, &RestCSDs_23);
      Var_55 = ((MR_Word) ((MR_hl_field(MR_mktag(0), PrimeCSD0_22, (MR_Integer) 0))));
      Var_56 = ((MR_Word) ((MR_hl_field(MR_mktag(0), PrimeCSD0_22, (MR_Integer) 1))));
      PrimeOwn0_24 = ((MR_Word) ((MR_hl_field(MR_mktag(0), PrimeCSD0_22, (MR_Integer) 2))));
      mercury__list__foldl_4_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_0), (MR_Word) (&measurements__measurements__type_ctor_info_own_prof_info_0), (MR_Word) (&canonical_scalar_common_2[7]), RestCSDs_23, ((MR_Box) (PrimeOwn0_24)), &conv2_PrimeOwn1_25);
      PrimeOwn1_25 = ((MR_Word) (conv2_PrimeOwn1_25));
      {
        PrimeCSD1_26 = (MR_Word) MR_new_object(MR_Word, (3 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), PrimeCSD1_26, 0) = ((MR_Box) (Var_55));
        MR_hl_field(MR_mktag(0), PrimeCSD1_26, 1) = ((MR_Box) (Var_56));
        MR_hl_field(MR_mktag(0), PrimeCSD1_26, 2) = ((MR_Box) (PrimeOwn1_25));
      }
      conv3_Var_48 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[5]), ((MR_Box) (CallSiteDynamics0_21)));
      Var_48 = ((MR_ArrayPtr) (conv3_Var_48));
      profile__update_call_site_dynamics_4_p_0(PrimeCSDPtr_11, PrimeCSD1_26, Var_48, &CallSiteDynamics1_27);
      {
        MR_Word base;
        base = (MR_Word) MR_new_object(MR_Word, (6 * sizeof(MR_Word)), NULL, NULL);
        *InitDeep_14 = base;
        MR_hl_field(MR_mktag(0), base, 0) = ((MR_Box) (Var_50));
        MR_hl_field(MR_mktag(0), base, 1) = ((MR_Box) (Var_51));
        MR_hl_field(MR_mktag(0), base, 2) = ((MR_Box) (CallSiteDynamics1_27));
        MR_hl_field(MR_mktag(0), base, 3) = ((MR_Box) (Var_52));
        MR_hl_field(MR_mktag(0), base, 4) = ((MR_Box) (Var_53));
        MR_hl_field(MR_mktag(0), base, 5) = ((MR_Box) (Var_54));
      }
      *Redirect_16 = Redirect1_20;
    }
    else
    {
      MR_Word ChosenPDPtr_29;
      MR_Word InitDeep2_30;
      MR_ArrayPtr CallSiteDynamics2_31;
      MR_Word PrimeCSD2_32;
      MR_Word PrimeCSD_33;
      MR_ArrayPtr CallSiteDynamics_34;
      MR_Word Var_41;
      MR_String Var_42;
      MR_ArrayPtr Var_49;
      MR_Word Var_66;
      MR_Word Var_67;
      MR_ArrayPtr Var_68;
      MR_ArrayPtr Var_69;
      MR_ArrayPtr Var_70;
      MR_ArrayPtr CallSiteDynamics0_121;
      MR_Word PrimeCSD0_122;
      MR_Word RestCSDs_123;
      MR_Word PrimeOwn0_124;
      MR_Word PrimeOwn1_125;
      MR_Word PrimeCSD1_126;
      MR_ArrayPtr CallSiteDynamics1_127;
      MR_Word InitDeep1_128;
      MR_Word Var_129;
      MR_ArrayPtr Var_130;
      MR_Word Var_131;
      MR_Word Var_132;
      MR_ArrayPtr Var_133;
      MR_ArrayPtr Var_134;
      MR_ArrayPtr Var_135;
      MR_Word Var_136;
      MR_Word Var_137;
      MR_Box conv5_PrimeOwn1_125;
      MR_Box conv6_Var_130;
      MR_Word Var_71;
      MR_Word Var_73;
      MR_Box conv7_Var_49;

      {
        Var_41 = (MR_Word) MR_new_object(MR_Word, (5 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), Var_41, 0) = ((MR_Box) (&canonical_scalar_common_7[4]));
        MR_hl_field(MR_mktag(0), Var_41, 1) = ((MR_Box) (canonical__merge_call_site_dynamics_2_8_p_0_5));
        MR_hl_field(MR_mktag(0), Var_41, 2) = ((MR_Box) ((MR_Integer) 2));
        MR_hl_field(MR_mktag(0), Var_41, 3) = ((MR_Box) (InClique_17));
        MR_hl_field(MR_mktag(0), Var_41, 4) = ((MR_Box) ((MR_Unsigned) 0U));
      }
      Var_42 = mercury__string__f_43_43_2_f_0((MR_String) "merge_proc_dynamic_normal_slot: prime not in clique, ", (MR_String) "others in clique");
      mercury__require__require_2_p_0(Var_41, Var_42);
      Var_131 = ((MR_Word) ((MR_hl_field(MR_mktag(0), InitDeep0_13, (MR_Integer) 0))));
      Var_132 = ((MR_Word) ((MR_hl_field(MR_mktag(0), InitDeep0_13, (MR_Integer) 1))));
      CallSiteDynamics0_121 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep0_13, (MR_Integer) 2))));
      Var_133 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep0_13, (MR_Integer) 3))));
      Var_134 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep0_13, (MR_Integer) 4))));
      Var_135 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep0_13, (MR_Integer) 5))));
      profile__lookup_call_site_dynamics_3_p_0(CallSiteDynamics0_121, PrimeCSDPtr_11, &PrimeCSD0_122);
      {
        Var_129 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), Var_129, 0) = ((MR_Box) (&canonical_scalar_common_3[8]));
        MR_hl_field(MR_mktag(0), Var_129, 1) = ((MR_Box) (canonical__merge_call_site_dynamics_2_8_p_0_6));
        MR_hl_field(MR_mktag(0), Var_129, 2) = ((MR_Box) ((MR_Integer) 1));
        MR_hl_field(MR_mktag(0), Var_129, 3) = ((MR_Box) (CallSiteDynamics0_121));
      }
      mercury__list__map_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), (MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_0), Var_129, RestCSDPtrs_12, &RestCSDs_123);
      Var_136 = ((MR_Word) ((MR_hl_field(MR_mktag(0), PrimeCSD0_122, (MR_Integer) 0))));
      Var_137 = ((MR_Word) ((MR_hl_field(MR_mktag(0), PrimeCSD0_122, (MR_Integer) 1))));
      PrimeOwn0_124 = ((MR_Word) ((MR_hl_field(MR_mktag(0), PrimeCSD0_122, (MR_Integer) 2))));
      mercury__list__foldl_4_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_0), (MR_Word) (&measurements__measurements__type_ctor_info_own_prof_info_0), (MR_Word) (&canonical_scalar_common_2[7]), RestCSDs_123, ((MR_Box) (PrimeOwn0_124)), &conv5_PrimeOwn1_125);
      PrimeOwn1_125 = ((MR_Word) (conv5_PrimeOwn1_125));
      {
        PrimeCSD1_126 = (MR_Word) MR_new_object(MR_Word, (3 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), PrimeCSD1_126, 0) = ((MR_Box) (Var_136));
        MR_hl_field(MR_mktag(0), PrimeCSD1_126, 1) = ((MR_Box) (Var_137));
        MR_hl_field(MR_mktag(0), PrimeCSD1_126, 2) = ((MR_Box) (PrimeOwn1_125));
      }
      conv6_Var_130 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[5]), ((MR_Box) (CallSiteDynamics0_121)));
      Var_130 = ((MR_ArrayPtr) (conv6_Var_130));
      profile__update_call_site_dynamics_4_p_0(PrimeCSDPtr_11, PrimeCSD1_126, Var_130, &CallSiteDynamics1_127);
      {
        InitDeep1_128 = (MR_Word) MR_new_object(MR_Word, (6 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), InitDeep1_128, 0) = ((MR_Box) (Var_131));
        MR_hl_field(MR_mktag(0), InitDeep1_128, 1) = ((MR_Box) (Var_132));
        MR_hl_field(MR_mktag(0), InitDeep1_128, 2) = ((MR_Box) (CallSiteDynamics1_127));
        MR_hl_field(MR_mktag(0), InitDeep1_128, 3) = ((MR_Box) (Var_133));
        MR_hl_field(MR_mktag(0), InitDeep1_128, 4) = ((MR_Box) (Var_134));
        MR_hl_field(MR_mktag(0), InitDeep1_128, 5) = ((MR_Box) (Var_135));
      }
      canonical__merge_call_site_dynamics_descendants_8_p_0(MergeInfo_9, PrimeCSDPtr_11, RestCSDPtrs_12, &ChosenPDPtr_29, InitDeep1_128, &InitDeep2_30, Redirect1_20, Redirect_16);
      Var_66 = ((MR_Word) ((MR_hl_field(MR_mktag(0), InitDeep2_30, (MR_Integer) 0))));
      Var_67 = ((MR_Word) ((MR_hl_field(MR_mktag(0), InitDeep2_30, (MR_Integer) 1))));
      CallSiteDynamics2_31 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep2_30, (MR_Integer) 2))));
      Var_68 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep2_30, (MR_Integer) 3))));
      Var_69 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep2_30, (MR_Integer) 4))));
      Var_70 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep2_30, (MR_Integer) 5))));
      profile__lookup_call_site_dynamics_3_p_0(CallSiteDynamics2_31, PrimeCSDPtr_11, &PrimeCSD2_32);
      Var_71 = ((MR_Word) ((MR_hl_field(MR_mktag(0), PrimeCSD2_32, (MR_Integer) 0))));
      Var_73 = ((MR_Word) ((MR_hl_field(MR_mktag(0), PrimeCSD2_32, (MR_Integer) 2))));
      {
        PrimeCSD_33 = (MR_Word) MR_new_object(MR_Word, (3 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), PrimeCSD_33, 0) = ((MR_Box) (Var_71));
        MR_hl_field(MR_mktag(0), PrimeCSD_33, 1) = ((MR_Box) (ChosenPDPtr_29));
        MR_hl_field(MR_mktag(0), PrimeCSD_33, 2) = ((MR_Box) (Var_73));
      }
      conv7_Var_49 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[5]), ((MR_Box) (CallSiteDynamics2_31)));
      Var_49 = ((MR_ArrayPtr) (conv7_Var_49));
      profile__update_call_site_dynamics_4_p_0(PrimeCSDPtr_11, PrimeCSD_33, Var_49, &CallSiteDynamics_34);
      {
        MR_Word base;
        base = (MR_Word) MR_new_object(MR_Word, (6 * sizeof(MR_Word)), NULL, NULL);
        *InitDeep_14 = base;
        MR_hl_field(MR_mktag(0), base, 0) = ((MR_Box) (Var_66));
        MR_hl_field(MR_mktag(0), base, 1) = ((MR_Box) (Var_67));
        MR_hl_field(MR_mktag(0), base, 2) = ((MR_Box) (CallSiteDynamics_34));
        MR_hl_field(MR_mktag(0), base, 3) = ((MR_Box) (Var_68));
        MR_hl_field(MR_mktag(0), base, 4) = ((MR_Box) (Var_69));
        MR_hl_field(MR_mktag(0), base, 5) = ((MR_Box) (Var_70));
      }
    }
  }
}

static MR_bool MR_CALL 
canonical__merge_proc_dynamic_normal_slot_11_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1)
{
  {
    MR_bool succeeded;
    MR_Box closure = closure_arg;

    succeeded = profile__valid_call_site_dynamic_ptr_raw_2_p_0(((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)));
    return succeeded;
  }
}

static void MR_CALL 
canonical__merge_proc_dynamic_normal_slot_11_p_0(
  MR_Word MergeInfo_12,
  MR_Integer SlotNum_13,
  MR_Word Clique_14,
  MR_Word PrimePDPtr_15,
  MR_Word PrimeCSDPtr0_16,
  MR_Word RestSiteArrays_17,
  MR_Word * PrimeCSDPtr_18,
  MR_Word STATE_VARIABLE_InitDeep_0_22,
  MR_Word * STATE_VARIABLE_InitDeep_23,
  MR_Word STATE_VARIABLE_Redirect_0_24,
  MR_Word * STATE_VARIABLE_Redirect_25)
{
  {
    MR_bool succeeded;
    MR_Word RestCSDPtrs_21;
    MR_Word Var_26;
    MR_ArrayPtr CallSiteDynamics0_40;
    MR_Word ValidCSDPtrs_41;
    MR_Word Var_49;

    canonical__lookup_normal_sites_3_p_0(RestSiteArrays_17, SlotNum_13, &RestCSDPtrs_21);
    {
      Var_26 = (MR_Word) MR_mkword(MR_mktag(1), MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL));
      MR_hl_field(MR_mktag(1), Var_26, 0) = ((MR_Box) (PrimeCSDPtr0_16));
      MR_hl_field(MR_mktag(1), Var_26, 1) = ((MR_Box) (RestCSDPtrs_21));
    }
    CallSiteDynamics0_40 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_0_22, (MR_Integer) 2))));
    {
      Var_49 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), Var_49, 0) = ((MR_Box) (&canonical_scalar_common_7[0]));
      MR_hl_field(MR_mktag(0), Var_49, 1) = ((MR_Box) (canonical__merge_proc_dynamic_normal_slot_11_p_0_1));
      MR_hl_field(MR_mktag(0), Var_49, 2) = ((MR_Box) ((MR_Integer) 1));
      MR_hl_field(MR_mktag(0), Var_49, 3) = ((MR_Box) (CallSiteDynamics0_40));
    }
    mercury__list__filter_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), Var_49, Var_26, &ValidCSDPtrs_41);
    if ((ValidCSDPtrs_41 == (MR_Word) ((MR_Unsigned) 0U)))
    {
      *PrimeCSDPtr_18 = (MR_Word) (((MR_Box) ((MR_Integer) 0)));
      *STATE_VARIABLE_InitDeep_23 = STATE_VARIABLE_InitDeep_0_22;
      *STATE_VARIABLE_Redirect_25 = STATE_VARIABLE_Redirect_0_24;
    }
    else
    {
      MR_Word LaterCSDPtrs_43;
      MR_Word FirstCSD0_44;
      MR_Word FirstCSD_45;
      MR_ArrayPtr CallSiteDynamics_46;
      MR_ArrayPtr Var_50;
      MR_Word STATE_VARIABLE_InitDeep_32_51;
      MR_Word Var_61;
      MR_Word Var_62;
      MR_Box conv0_Var_50;
      MR_Word Var_63;
      MR_Word Var_64;
      MR_ArrayPtr Var_66;
      MR_ArrayPtr Var_67;
      MR_ArrayPtr Var_68;

      *PrimeCSDPtr_18 = ((MR_Word) ((MR_hl_field(MR_mktag(1), ValidCSDPtrs_41, (MR_Integer) 0))));
      LaterCSDPtrs_43 = ((MR_Word) ((MR_hl_field(MR_mktag(1), ValidCSDPtrs_41, (MR_Integer) 1))));
      profile__lookup_call_site_dynamics_3_p_0(CallSiteDynamics0_40, *PrimeCSDPtr_18, &FirstCSD0_44);
      Var_61 = ((MR_Word) ((MR_hl_field(MR_mktag(0), FirstCSD0_44, (MR_Integer) 1))));
      Var_62 = ((MR_Word) ((MR_hl_field(MR_mktag(0), FirstCSD0_44, (MR_Integer) 2))));
      {
        FirstCSD_45 = (MR_Word) MR_new_object(MR_Word, (3 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), FirstCSD_45, 0) = ((MR_Box) (PrimePDPtr_15));
        MR_hl_field(MR_mktag(0), FirstCSD_45, 1) = ((MR_Box) (Var_61));
        MR_hl_field(MR_mktag(0), FirstCSD_45, 2) = ((MR_Box) (Var_62));
      }
      conv0_Var_50 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[5]), ((MR_Box) (CallSiteDynamics0_40)));
      Var_50 = ((MR_ArrayPtr) (conv0_Var_50));
      profile__update_call_site_dynamics_4_p_0(*PrimeCSDPtr_18, FirstCSD_45, Var_50, &CallSiteDynamics_46);
      Var_63 = ((MR_Word) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_0_22, (MR_Integer) 0))));
      Var_64 = ((MR_Word) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_0_22, (MR_Integer) 1))));
      Var_66 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_0_22, (MR_Integer) 3))));
      Var_67 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_0_22, (MR_Integer) 4))));
      Var_68 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_0_22, (MR_Integer) 5))));
      {
        STATE_VARIABLE_InitDeep_32_51 = (MR_Word) MR_new_object(MR_Word, (6 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_32_51, 0) = ((MR_Box) (Var_63));
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_32_51, 1) = ((MR_Box) (Var_64));
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_32_51, 2) = ((MR_Box) (CallSiteDynamics_46));
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_32_51, 3) = ((MR_Box) (Var_66));
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_32_51, 4) = ((MR_Box) (Var_67));
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_32_51, 5) = ((MR_Box) (Var_68));
      }
      if ((LaterCSDPtrs_43 == (MR_Word) ((MR_Unsigned) 0U)))
      {
        *STATE_VARIABLE_InitDeep_23 = STATE_VARIABLE_InitDeep_32_51;
        *STATE_VARIABLE_Redirect_25 = STATE_VARIABLE_Redirect_0_24;
      }
      else
        canonical__merge_call_site_dynamics_2_8_p_0(MergeInfo_12, Clique_14, *PrimeCSDPtr_18, LaterCSDPtrs_43, STATE_VARIABLE_InitDeep_32_51, STATE_VARIABLE_InitDeep_23, STATE_VARIABLE_Redirect_0_24, STATE_VARIABLE_Redirect_25);
    }
  }
}

static void MR_CALL 
canonical__merge_proc_dynamics_8_p_0_4(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2)
{
  {
    MR_Box closure = closure_arg;
    MR_ArrayPtr conv1_HeadVar__2_2;

    profile__extract_pd_sites_2_p_0(((MR_Word) (wrapper_arg_1)), &conv1_HeadVar__2_2);
    *wrapper_arg_2 = ((MR_Box) (conv1_HeadVar__2_2));
  }
}

static void MR_CALL 
canonical__merge_proc_dynamics_8_p_0_3(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv0_HeadVar__3_3;

    profile__lookup_proc_dynamics_3_p_0(((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)), &conv0_HeadVar__3_3);
    *wrapper_arg_2 = ((MR_Box) (conv0_HeadVar__3_3));
  }
}

static MR_bool MR_CALL 
canonical__merge_proc_dynamics_8_p_0_2(
  MR_Box closure_arg)
{
  {
    MR_bool succeeded;
    MR_Box closure = closure_arg;

    succeeded = canonical__IntroducedFrom__pred__merge_proc_dynamics__241__1_2_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 4)))));
    return succeeded;
  }
}

static MR_bool MR_CALL 
canonical__merge_proc_dynamics_8_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1)
{
  {
    MR_bool succeeded;
    MR_Box closure = closure_arg;

    succeeded = profile__valid_proc_dynamic_ptr_raw_2_p_0(((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)));
    return succeeded;
  }
}

static void MR_CALL 
canonical__merge_proc_dynamics_8_p_0(
  MR_Word MergeInfo_9,
  MR_Word Clique_10,
  MR_Word CandidatePDPtrs_11,
  MR_Word * ChosenPDPtr_12,
  MR_Word STATE_VARIABLE_InitDeep_0_29,
  MR_Word * STATE_VARIABLE_InitDeep_30,
  MR_Word STATE_VARIABLE_Redirect_0_31,
  MR_Word * STATE_VARIABLE_Redirect_32)
{
  {
    MR_bool succeeded;
    MR_ArrayPtr ProcDynamics0_15 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_0_29, (MR_Integer) 3))));
    MR_Word ValidPDPtrs_16;
    MR_Word InvalidPDPtrs_17;
    MR_Word Var_33;
    MR_Word Var_34;

    {
      Var_33 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), Var_33, 0) = ((MR_Box) (&canonical_scalar_common_7[1]));
      MR_hl_field(MR_mktag(0), Var_33, 1) = ((MR_Box) (canonical__merge_proc_dynamics_8_p_0_1));
      MR_hl_field(MR_mktag(0), Var_33, 2) = ((MR_Box) ((MR_Integer) 1));
      MR_hl_field(MR_mktag(0), Var_33, 3) = ((MR_Box) (ProcDynamics0_15));
    }
    mercury__list__filter_4_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), Var_33, CandidatePDPtrs_11, &ValidPDPtrs_16, &InvalidPDPtrs_17);
    {
      Var_34 = (MR_Word) MR_new_object(MR_Word, (5 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), Var_34, 0) = ((MR_Box) (&canonical_scalar_common_7[2]));
      MR_hl_field(MR_mktag(0), Var_34, 1) = ((MR_Box) (canonical__merge_proc_dynamics_8_p_0_2));
      MR_hl_field(MR_mktag(0), Var_34, 2) = ((MR_Box) ((MR_Integer) 2));
      MR_hl_field(MR_mktag(0), Var_34, 3) = ((MR_Box) (InvalidPDPtrs_17));
      MR_hl_field(MR_mktag(0), Var_34, 4) = ((MR_Box) ((MR_Unsigned) 0U));
    }
    mercury__require__require_2_p_0(Var_34, (MR_String) "merge_proc_dynamics: invalid pdptrs");
    if ((ValidPDPtrs_16 == (MR_Word) ((MR_Unsigned) 0U)))
      {
        mercury__require__unexpected_2_p_0((MR_String) "predicate \140canonical.merge_proc_dynamics\'/8", (MR_String) "no valid pdptrs");
        return;
      }
    else
    {
      MR_Word RestPDPtrs_19;
      MR_Word PrimePD0_20;
      MR_Word RestPDs_21;
      MR_Word RestSites_22;
      MR_ArrayPtr PrimeSites0_23;
      MR_Integer MaxSiteNum_24;
      MR_ArrayPtr PrimeSites_25;
      MR_Word PrimePD_26;
      MR_ArrayPtr ProcDynamics1_27;
      MR_ArrayPtr ProcDynamics_28;
      MR_Word STATE_VARIABLE_Redirect_39_39;
      MR_Word Var_40;
      MR_ArrayPtr Var_42;
      MR_Word STATE_VARIABLE_InitDeep_43_43;
      MR_ArrayPtr Var_45;
      MR_Box conv2_Var_42;
      MR_Word Var_54;
      MR_Word Var_56;
      MR_Box conv3_Var_45;
      MR_Word Var_62;
      MR_Word Var_63;
      MR_ArrayPtr Var_64;
      MR_ArrayPtr Var_66;
      MR_ArrayPtr Var_67;

      *ChosenPDPtr_12 = ((MR_Word) ((MR_hl_field(MR_mktag(1), ValidPDPtrs_16, (MR_Integer) 0))));
      RestPDPtrs_19 = ((MR_Word) ((MR_hl_field(MR_mktag(1), ValidPDPtrs_16, (MR_Integer) 1))));
      canonical__record_pd_redirect_4_p_0(RestPDPtrs_19, *ChosenPDPtr_12, STATE_VARIABLE_Redirect_0_31, &STATE_VARIABLE_Redirect_39_39);
      profile__lookup_proc_dynamics_3_p_0(ProcDynamics0_15, *ChosenPDPtr_12, &PrimePD0_20);
      {
        Var_40 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), Var_40, 0) = ((MR_Box) (&canonical_scalar_common_3[5]));
        MR_hl_field(MR_mktag(0), Var_40, 1) = ((MR_Box) (canonical__merge_proc_dynamics_8_p_0_3));
        MR_hl_field(MR_mktag(0), Var_40, 2) = ((MR_Box) ((MR_Integer) 1));
        MR_hl_field(MR_mktag(0), Var_40, 3) = ((MR_Box) (ProcDynamics0_15));
      }
      mercury__list__map_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), (MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_0), Var_40, RestPDPtrs_19, &RestPDs_21);
      mercury__list__map_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_0), (MR_Word) (&canonical_scalar_common_1[2]), (MR_Word) (&canonical_scalar_common_2[6]), RestPDs_21, &RestSites_22);
      PrimeSites0_23 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), PrimePD0_20, (MR_Integer) 1))));
      mercury__array__max_2_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_array_slot_0), (MR_ArrayPtr) (PrimeSites0_23), &MaxSiteNum_24);
      conv2_Var_42 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[2]), ((MR_Box) (PrimeSites0_23)));
      Var_42 = ((MR_ArrayPtr) (conv2_Var_42));
      canonical__merge_proc_dynamic_slots_11_p_0(MergeInfo_9, MaxSiteNum_24, Clique_10, *ChosenPDPtr_12, Var_42, RestSites_22, &PrimeSites_25, STATE_VARIABLE_InitDeep_0_29, &STATE_VARIABLE_InitDeep_43_43, STATE_VARIABLE_Redirect_39_39, STATE_VARIABLE_Redirect_32);
      Var_54 = ((MR_Word) ((MR_hl_field(MR_mktag(0), PrimePD0_20, (MR_Integer) 0))));
      Var_56 = ((MR_Word) ((MR_hl_field(MR_mktag(0), PrimePD0_20, (MR_Integer) 2))));
      {
        PrimePD_26 = (MR_Word) MR_new_object(MR_Word, (3 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), PrimePD_26, 0) = ((MR_Box) (Var_54));
        MR_hl_field(MR_mktag(0), PrimePD_26, 1) = ((MR_Box) (PrimeSites_25));
        MR_hl_field(MR_mktag(0), PrimePD_26, 2) = ((MR_Box) (Var_56));
      }
      ProcDynamics1_27 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_43_43, (MR_Integer) 3))));
      conv3_Var_45 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[3]), ((MR_Box) (ProcDynamics1_27)));
      Var_45 = ((MR_ArrayPtr) (conv3_Var_45));
      profile__update_proc_dynamics_4_p_0(*ChosenPDPtr_12, PrimePD_26, Var_45, &ProcDynamics_28);
      Var_62 = ((MR_Word) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_43_43, (MR_Integer) 0))));
      Var_63 = ((MR_Word) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_43_43, (MR_Integer) 1))));
      Var_64 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_43_43, (MR_Integer) 2))));
      Var_66 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_43_43, (MR_Integer) 4))));
      Var_67 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_43_43, (MR_Integer) 5))));
      {
        MR_Word base;
        base = (MR_Word) MR_new_object(MR_Word, (6 * sizeof(MR_Word)), NULL, NULL);
        *STATE_VARIABLE_InitDeep_30 = base;
        MR_hl_field(MR_mktag(0), base, 0) = ((MR_Box) (Var_62));
        MR_hl_field(MR_mktag(0), base, 1) = ((MR_Box) (Var_63));
        MR_hl_field(MR_mktag(0), base, 2) = ((MR_Box) (Var_64));
        MR_hl_field(MR_mktag(0), base, 3) = ((MR_Box) (ProcDynamics_28));
        MR_hl_field(MR_mktag(0), base, 4) = ((MR_Box) (Var_66));
        MR_hl_field(MR_mktag(0), base, 5) = ((MR_Box) (Var_67));
      }
    }
  }
}

static void MR_CALL 
canonical__record_csd_redirect_4_p_0(
  MR_Word RestCSDPtrs_5,
  MR_Word PrimeCSDPtr_6,
  MR_Word STATE_VARIABLE_Redirect_0_11,
  MR_Word * STATE_VARIABLE_Redirect_12)
{
  {
    MR_bool succeeded;
    MR_Word OldRedirect_10;
    MR_ArrayPtr Var_22 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_Redirect_0_11, (MR_Integer) 0))));
    MR_Integer CSDI_33 = (MR_Integer) (PrimeCSDPtr_6);
    MR_Box conv0_OldRedirect_10;
    MR_Integer Var_23;

    mercury__array__lookup_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), (MR_ArrayPtr) (Var_22), CSDI_33, &conv0_OldRedirect_10);
    OldRedirect_10 = ((MR_Word) (conv0_OldRedirect_10));
    Var_23 = (MR_Integer) (OldRedirect_10);
    succeeded = (Var_23 == (MR_Integer) 0);
    if (succeeded)
      canonical__record_csd_redirect_2_4_p_0(RestCSDPtrs_5, PrimeCSDPtr_6, STATE_VARIABLE_Redirect_0_11, STATE_VARIABLE_Redirect_12);
    else
      {
        mercury__require__unexpected_2_p_0((MR_String) "predicate \140canonical.record_csd_redirect\'/4", (MR_String) "prime is redirected");
        return;
      }
  }
}

static void MR_CALL 
canonical__record_csd_redirect_2_4_p_0(
  MR_Word HeadVar__1_1,
  MR_Word PrimeCSDPtr_2,
  MR_Word STATE_VARIABLE_Redirect_0_3,
  MR_Word * STATE_VARIABLE_Redirect_4)
{
  while (MR_TRUE)
  {
    MR_bool succeeded;

    // setup for model_det tailcalls optimized into a loop
    ;
    if ((HeadVar__1_1 == (MR_Word) ((MR_Unsigned) 0U)))
      *STATE_VARIABLE_Redirect_4 = STATE_VARIABLE_Redirect_0_3;
    else
    {
      MR_Word RestCSDPtr_9 = ((MR_Word) ((MR_hl_field(MR_mktag(1), HeadVar__1_1, (MR_Integer) 0))));
      MR_Word RestCSDPtrs_10 = ((MR_Word) ((MR_hl_field(MR_mktag(1), HeadVar__1_1, (MR_Integer) 1))));
      MR_ArrayPtr CallSiteRedirect0_13 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_Redirect_0_3, (MR_Integer) 0))));
      MR_Word OldRedirect_14;
      MR_ArrayPtr CallSiteRedirect_15;
      MR_Word STATE_VARIABLE_Redirect_22_22;
      MR_Integer CSDI_31 = (MR_Integer) (RestCSDPtr_9);
      MR_Box conv0_OldRedirect_14;
      MR_Integer Var_18;
      MR_ArrayPtr Var_26;
      MR_Word next_value_of_HeadVar__1_1;
      MR_Word next_value_of_STATE_VARIABLE_Redirect_0_3;

      mercury__array__lookup_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), (MR_ArrayPtr) (CallSiteRedirect0_13), CSDI_31, &conv0_OldRedirect_14);
      OldRedirect_14 = ((MR_Word) (conv0_OldRedirect_14));
      Var_18 = (MR_Integer) (OldRedirect_14);
      succeeded = (Var_18 == (MR_Integer) 0);
      if (succeeded)
      {
        MR_ArrayPtr Var_19;
        MR_Integer CSDI_37;
        MR_Box conv1_Var_19;
        MR_ArrayPtr conv2_CallSiteRedirect_15;

        conv1_Var_19 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[7]), ((MR_Box) (CallSiteRedirect0_13)));
        Var_19 = ((MR_ArrayPtr) (conv1_Var_19));
        CSDI_37 = (MR_Integer) (RestCSDPtr_9);
        mercury__array__set_4_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), CSDI_37, ((MR_Box) (PrimeCSDPtr_2)), (MR_ArrayPtr) (Var_19), &conv2_CallSiteRedirect_15);
        CallSiteRedirect_15 = (MR_ArrayPtr) (conv2_CallSiteRedirect_15);
      }
      else
        {
          mercury__require__unexpected_2_p_0((MR_String) "predicate \140canonical.record_csd_redirect_2\'/4", (MR_String) "already redirected");
          return;
        }
      Var_26 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_Redirect_0_3, (MR_Integer) 1))));
      {
        STATE_VARIABLE_Redirect_22_22 = (MR_Word) MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_Redirect_22_22, 0) = ((MR_Box) (CallSiteRedirect_15));
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_Redirect_22_22, 1) = ((MR_Box) (Var_26));
      }
      // direct tailcall eliminated
      ;
      next_value_of_HeadVar__1_1 = RestCSDPtrs_10;
      next_value_of_STATE_VARIABLE_Redirect_0_3 = STATE_VARIABLE_Redirect_22_22;
      HeadVar__1_1 = next_value_of_HeadVar__1_1;
      STATE_VARIABLE_Redirect_0_3 = next_value_of_STATE_VARIABLE_Redirect_0_3;
      continue;
    }
    break;
  }
}

static void MR_CALL 
canonical__record_pd_redirect_4_p_0(
  MR_Word RestPDPtrs_5,
  MR_Word PrimePDPtr_6,
  MR_Word STATE_VARIABLE_Redirect_0_11,
  MR_Word * STATE_VARIABLE_Redirect_12)
{
  {
    MR_bool succeeded;
    MR_Word OldRedirect_10;
    MR_ArrayPtr Var_22 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_Redirect_0_11, (MR_Integer) 1))));
    MR_Integer PDI_33 = (MR_Integer) (PrimePDPtr_6);
    MR_Box conv0_OldRedirect_10;
    MR_Integer Var_23;

    mercury__array__lookup_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), (MR_ArrayPtr) (Var_22), PDI_33, &conv0_OldRedirect_10);
    OldRedirect_10 = ((MR_Word) (conv0_OldRedirect_10));
    Var_23 = (MR_Integer) (OldRedirect_10);
    succeeded = (Var_23 == (MR_Integer) 0);
    if (succeeded)
      canonical__record_pd_redirect_2_4_p_0(RestPDPtrs_5, PrimePDPtr_6, STATE_VARIABLE_Redirect_0_11, STATE_VARIABLE_Redirect_12);
    else
      {
        mercury__require__unexpected_2_p_0((MR_String) "predicate \140canonical.record_pd_redirect\'/4", (MR_String) "prime is redirected");
        return;
      }
  }
}

static void MR_CALL 
canonical__record_pd_redirect_2_4_p_0(
  MR_Word HeadVar__1_1,
  MR_Word PrimePDPtr_2,
  MR_Word STATE_VARIABLE_Redirect_0_3,
  MR_Word * STATE_VARIABLE_Redirect_4)
{
  while (MR_TRUE)
  {
    MR_bool succeeded;

    // setup for model_det tailcalls optimized into a loop
    ;
    if ((HeadVar__1_1 == (MR_Word) ((MR_Unsigned) 0U)))
      *STATE_VARIABLE_Redirect_4 = STATE_VARIABLE_Redirect_0_3;
    else
    {
      MR_Word RestPDPtr_9 = ((MR_Word) ((MR_hl_field(MR_mktag(1), HeadVar__1_1, (MR_Integer) 0))));
      MR_Word RestPDPtrs_10 = ((MR_Word) ((MR_hl_field(MR_mktag(1), HeadVar__1_1, (MR_Integer) 1))));
      MR_ArrayPtr ProcRedirect0_13 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_Redirect_0_3, (MR_Integer) 1))));
      MR_Word OldRedirect_14;
      MR_ArrayPtr ProcRedirect_15;
      MR_Word STATE_VARIABLE_Redirect_22_22;
      MR_Integer PDI_31 = (MR_Integer) (RestPDPtr_9);
      MR_Box conv0_OldRedirect_14;
      MR_Integer Var_18;
      MR_ArrayPtr Var_25;
      MR_Word next_value_of_HeadVar__1_1;
      MR_Word next_value_of_STATE_VARIABLE_Redirect_0_3;

      mercury__array__lookup_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), (MR_ArrayPtr) (ProcRedirect0_13), PDI_31, &conv0_OldRedirect_14);
      OldRedirect_14 = ((MR_Word) (conv0_OldRedirect_14));
      Var_18 = (MR_Integer) (OldRedirect_14);
      succeeded = (Var_18 == (MR_Integer) 0);
      if (succeeded)
      {
        MR_ArrayPtr Var_19;
        MR_Integer PDI_37;
        MR_Box conv1_Var_19;
        MR_ArrayPtr conv2_ProcRedirect_15;

        conv1_Var_19 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[6]), ((MR_Box) (ProcRedirect0_13)));
        Var_19 = ((MR_ArrayPtr) (conv1_Var_19));
        PDI_37 = (MR_Integer) (RestPDPtr_9);
        mercury__array__set_4_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), PDI_37, ((MR_Box) (PrimePDPtr_2)), (MR_ArrayPtr) (Var_19), &conv2_ProcRedirect_15);
        ProcRedirect_15 = (MR_ArrayPtr) (conv2_ProcRedirect_15);
      }
      else
        {
          mercury__require__unexpected_2_p_0((MR_String) "predicate \140canonical.record_pd_redirect_2\'/4", (MR_String) "already redirected");
          return;
        }
      Var_25 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_Redirect_0_3, (MR_Integer) 0))));
      {
        STATE_VARIABLE_Redirect_22_22 = (MR_Word) MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_Redirect_22_22, 0) = ((MR_Box) (Var_25));
        MR_hl_field(MR_mktag(0), STATE_VARIABLE_Redirect_22_22, 1) = ((MR_Box) (ProcRedirect_15));
      }
      // direct tailcall eliminated
      ;
      next_value_of_HeadVar__1_1 = RestPDPtrs_10;
      next_value_of_STATE_VARIABLE_Redirect_0_3 = STATE_VARIABLE_Redirect_22_22;
      HeadVar__1_1 = next_value_of_HeadVar__1_1;
      STATE_VARIABLE_Redirect_0_3 = next_value_of_STATE_VARIABLE_Redirect_0_3;
      continue;
    }
    break;
  }
}

static MR_bool MR_CALL 
canonical__callee_in_clique_3_p_0(
  MR_Word InitDeep_4,
  MR_Word Clique_5,
  MR_Word CSDPtr_6)
{
  {
    MR_bool succeeded;
    MR_Word CSD_7;
    MR_Word CalleePDPtr_8;
    MR_ArrayPtr Var_9 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep_4, (MR_Integer) 2))));

    profile__lookup_call_site_dynamics_3_p_0(Var_9, CSDPtr_6, &CSD_7);
    CalleePDPtr_8 = ((MR_Word) ((MR_hl_field(MR_mktag(0), CSD_7, (MR_Integer) 1))));
    succeeded = mercury__set__member_2_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), ((MR_Box) (CalleePDPtr_8)), Clique_5);
    return succeeded;
  }
}

static void MR_CALL 
canonical__lookup_pd_site_3_p_0(
  MR_Word InitDeep_4,
  MR_Word PDPtr_5,
  MR_ArrayPtr * Sites_6)
{
  {
    MR_Word PD_7;
    MR_ArrayPtr Var_8 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep_4, (MR_Integer) 3))));

    profile__lookup_proc_dynamics_3_p_0(Var_8, PDPtr_5, &PD_7);
    *Sites_6 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), PD_7, (MR_Integer) 1))));
  }
}

static void MR_CALL 
canonical__complete_clique_ps_7_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2)
{
  {
    MR_Box closure = closure_arg;
    MR_ArrayPtr conv0_Sites_6;

    canonical__lookup_pd_site_3_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)), &conv0_Sites_6);
    *wrapper_arg_2 = ((MR_Box) (conv0_Sites_6));
  }
}

static void MR_CALL 
canonical__complete_clique_ps_7_p_0(
  MR_Word InitDeep_8,
  MR_Word Clique_9,
  MR_Word HeadVar__3_3,
  MR_Word STATE_VARIABLE_ProcMap_0_19,
  MR_Word * STATE_VARIABLE_ProcMap_20,
  MR_Word STATE_VARIABLE_AddedPD_0_21,
  MR_Word * STATE_VARIABLE_AddedPD_22)
{
  {
    MR_bool succeeded;
    MR_Word PSPtr_10 = ((MR_Word) ((MR_hl_field(MR_mktag(0), HeadVar__3_3, (MR_Integer) 0))));
    MR_Word PDPtrs_11 = ((MR_Word) ((MR_hl_field(MR_mktag(0), HeadVar__3_3, (MR_Integer) 1))));
    MR_Word Var_23;

    succeeded = (PDPtrs_11 != (MR_Word) ((MR_Unsigned) 0U));
    if (succeeded)
    {
      Var_23 = ((MR_Word) ((MR_hl_field(MR_mktag(1), PDPtrs_11, (MR_Integer) 1))));
      succeeded = (Var_23 != (MR_Word) ((MR_Unsigned) 0U));
      if (succeeded)
      {
      }
    }
    if (succeeded)
    {
      MR_Word PS_17;
      MR_Word PDSites_18;
      MR_ArrayPtr Var_24 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep_8, (MR_Integer) 5))));
      MR_Word Var_25;
      MR_Integer Var_26;
      MR_ArrayPtr Var_27;
      MR_ArrayPtr Var_30;

      profile__lookup_proc_statics_3_p_0(Var_24, PSPtr_10, &PS_17);
      {
        Var_25 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), Var_25, 0) = ((MR_Box) (&canonical_scalar_common_3[4]));
        MR_hl_field(MR_mktag(0), Var_25, 1) = ((MR_Box) (canonical__complete_clique_ps_7_p_0_1));
        MR_hl_field(MR_mktag(0), Var_25, 2) = ((MR_Box) ((MR_Integer) 1));
        MR_hl_field(MR_mktag(0), Var_25, 3) = ((MR_Box) (InitDeep_8));
      }
      mercury__list__map_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), (MR_Word) (&canonical_scalar_common_1[2]), Var_25, PDPtrs_11, &PDSites_18);
      Var_30 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), PS_17, (MR_Integer) 8))));
      Var_26 = mercury__array__max_1_f_0((MR_Word) (&profile__profile__type_ctor_info_call_site_static_ptr_0), (MR_ArrayPtr) (Var_30));
      Var_27 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), PS_17, (MR_Integer) 8))));
      canonical__complete_clique_slots_9_p_0(Var_26, InitDeep_8, Clique_9, Var_27, PDSites_18, STATE_VARIABLE_ProcMap_0_19, STATE_VARIABLE_ProcMap_20, STATE_VARIABLE_AddedPD_0_21, STATE_VARIABLE_AddedPD_22);
    }
    else
    {
      *STATE_VARIABLE_AddedPD_22 = STATE_VARIABLE_AddedPD_0_21;
      *STATE_VARIABLE_ProcMap_20 = STATE_VARIABLE_ProcMap_0_19;
    }
  }
}

static void MR_CALL 
canonical__complete_clique_slots_9_p_0_3(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv2_STATE_VARIABLE_ProcMap_13;

    canonical__cluster_pds_by_ps_4_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)), ((MR_Word) (wrapper_arg_2)), &conv2_STATE_VARIABLE_ProcMap_13);
    *wrapper_arg_3 = ((MR_Box) (conv2_STATE_VARIABLE_ProcMap_13));
  }
}

static void MR_CALL 
canonical__complete_clique_slots_9_p_0_2(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv1_HeadVar__3_3;

    profile__extract_csdptr_callee_3_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)), &conv1_HeadVar__3_3);
    *wrapper_arg_2 = ((MR_Box) (conv1_HeadVar__3_3));
  }
}

static MR_bool MR_CALL 
canonical__complete_clique_slots_9_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1)
{
  {
    MR_bool succeeded;
    MR_Box closure = closure_arg;

    succeeded = profile__valid_call_site_dynamic_ptr_raw_2_p_0(((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)));
    return succeeded;
  }
}

static void MR_CALL 
canonical__complete_clique_slots_9_p_0(
  MR_Integer SlotNum_10,
  MR_Word InitDeep_11,
  MR_Word Clique_12,
  MR_ArrayPtr PSSites_13,
  MR_Word PDSites_14,
  MR_Word STATE_VARIABLE_ProcMap_0_29,
  MR_Word * STATE_VARIABLE_ProcMap_30,
  MR_Word STATE_VARIABLE_AddedPD_0_31,
  MR_Word * STATE_VARIABLE_AddedPD_32)
{
  while (MR_TRUE)
  {
    MR_bool succeeded = (SlotNum_10 >= (MR_Integer) 0);

    // setup for model_det tailcalls optimized into a loop
    ;
    if (succeeded)
    {
      MR_Word CSSPtr_17;
      MR_Word CSS_18;
      MR_Word CSDPtrs_21;
      MR_Word ValidCSDPtrs_23;
      MR_Word CalleePDPtrs_24;
      MR_Word CalleePDPtrSet_25;
      MR_Word Common_26;
      MR_ArrayPtr Var_34;
      MR_Word Var_36;
      MR_ArrayPtr Var_37;
      MR_Word Var_38;
      MR_Word STATE_VARIABLE_AddedPD_39_39;
      MR_Word STATE_VARIABLE_ProcMap_41_41;
      MR_Integer Var_43;
      MR_Box conv0_CSSPtr_17;
      MR_Word Var_35;
      MR_Integer next_value_of_SlotNum_10;
      MR_Word next_value_of_STATE_VARIABLE_ProcMap_0_29;
      MR_Word next_value_of_STATE_VARIABLE_AddedPD_0_31;

      mercury__array__lookup_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_static_ptr_0), (MR_ArrayPtr) (PSSites_13), SlotNum_10, &conv0_CSSPtr_17);
      CSSPtr_17 = ((MR_Word) (conv0_CSSPtr_17));
      Var_34 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep_11, (MR_Integer) 4))));
      profile__lookup_call_site_statics_3_p_0(Var_34, CSSPtr_17, &CSS_18);
      Var_35 = ((MR_Word) ((MR_hl_field(MR_mktag(0), CSS_18, (MR_Integer) 2))));
      succeeded = ((MR_tag((MR_Word) Var_35)) == (MR_Integer) 1);
      if (succeeded)
        canonical__lookup_normal_sites_3_p_0(PDSites_14, SlotNum_10, &CSDPtrs_21);
      else
      {
        MR_Word CSDPtrLists_22;

        canonical__lookup_multi_sites_3_p_0(PDSites_14, SlotNum_10, &CSDPtrLists_22);
        mercury__list__condense_2_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), CSDPtrLists_22, &CSDPtrs_21);
      }
      Var_37 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), InitDeep_11, (MR_Integer) 2))));
      {
        Var_36 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), Var_36, 0) = ((MR_Box) (&canonical_scalar_common_7[0]));
        MR_hl_field(MR_mktag(0), Var_36, 1) = ((MR_Box) (canonical__complete_clique_slots_9_p_0_1));
        MR_hl_field(MR_mktag(0), Var_36, 2) = ((MR_Box) ((MR_Integer) 1));
        MR_hl_field(MR_mktag(0), Var_36, 3) = ((MR_Box) (Var_37));
      }
      mercury__list__filter_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), Var_36, CSDPtrs_21, &ValidCSDPtrs_23);
      {
        Var_38 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
        MR_hl_field(MR_mktag(0), Var_38, 0) = ((MR_Box) (&canonical_scalar_common_3[3]));
        MR_hl_field(MR_mktag(0), Var_38, 1) = ((MR_Box) (canonical__complete_clique_slots_9_p_0_2));
        MR_hl_field(MR_mktag(0), Var_38, 2) = ((MR_Box) ((MR_Integer) 1));
        MR_hl_field(MR_mktag(0), Var_38, 3) = ((MR_Box) (InitDeep_11));
      }
      mercury__list__map_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), (MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), Var_38, ValidCSDPtrs_23, &CalleePDPtrs_24);
      CalleePDPtrSet_25 = mercury__set__list_to_set_1_f_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), CalleePDPtrs_24);
      mercury__set__intersect_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), CalleePDPtrSet_25, Clique_12, &Common_26);
      succeeded = mercury__set__is_empty_1_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), Common_26);
      if (succeeded)
      {
        STATE_VARIABLE_AddedPD_39_39 = STATE_VARIABLE_AddedPD_0_31;
        STATE_VARIABLE_ProcMap_41_41 = STATE_VARIABLE_ProcMap_0_29;
      }
      else
      {
        MR_Word NewMembers_27;

        mercury__set__difference_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), CalleePDPtrSet_25, Clique_12, &NewMembers_27);
        succeeded = mercury__set__is_empty_1_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), NewMembers_27);
        if (succeeded)
        {
          STATE_VARIABLE_AddedPD_39_39 = (MR_Integer) 0;
          STATE_VARIABLE_ProcMap_41_41 = STATE_VARIABLE_ProcMap_0_29;
        }
        else
        {
          MR_Word NewMemberList_28;
          MR_Word Var_40;
          MR_Box conv3_STATE_VARIABLE_ProcMap_41_41;

          mercury__set__to_sorted_list_2_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), NewMembers_27, &NewMemberList_28);
          {
            Var_40 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
            MR_hl_field(MR_mktag(0), Var_40, 0) = ((MR_Box) (&canonical_scalar_common_5[0]));
            MR_hl_field(MR_mktag(0), Var_40, 1) = ((MR_Box) (canonical__complete_clique_slots_9_p_0_3));
            MR_hl_field(MR_mktag(0), Var_40, 2) = ((MR_Box) ((MR_Integer) 1));
            MR_hl_field(MR_mktag(0), Var_40, 3) = ((MR_Box) (InitDeep_11));
          }
          mercury__list__foldl_4_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), (MR_Word) (&canonical_scalar_common_2[0]), Var_40, NewMemberList_28, ((MR_Box) (STATE_VARIABLE_ProcMap_0_29)), &conv3_STATE_VARIABLE_ProcMap_41_41);
          STATE_VARIABLE_ProcMap_41_41 = ((MR_Word) (conv3_STATE_VARIABLE_ProcMap_41_41));
          STATE_VARIABLE_AddedPD_39_39 = (MR_Integer) 1;
        }
      }
      Var_43 = (MR_Integer) ((MR_Unsigned) SlotNum_10 - (MR_Unsigned) 1);
      // direct tailcall eliminated
      ;
      next_value_of_SlotNum_10 = Var_43;
      next_value_of_STATE_VARIABLE_ProcMap_0_29 = STATE_VARIABLE_ProcMap_41_41;
      next_value_of_STATE_VARIABLE_AddedPD_0_31 = STATE_VARIABLE_AddedPD_39_39;
      SlotNum_10 = next_value_of_SlotNum_10;
      STATE_VARIABLE_ProcMap_0_29 = next_value_of_STATE_VARIABLE_ProcMap_0_29;
      STATE_VARIABLE_AddedPD_0_31 = next_value_of_STATE_VARIABLE_AddedPD_0_31;
      continue;
    }
    else
    {
      *STATE_VARIABLE_AddedPD_32 = STATE_VARIABLE_AddedPD_0_31;
      *STATE_VARIABLE_ProcMap_30 = STATE_VARIABLE_ProcMap_0_29;
    }
    break;
  }
}

static void MR_CALL 
canonical__lookup_multi_sites_3_p_0(
  MR_Word HeadVar__1_1,
  MR_Integer SlotNum_2,
  MR_Word * HeadVar__3_3)
{
  if ((HeadVar__1_1 == (MR_Word) ((MR_Unsigned) 0U)))
    *HeadVar__3_3 = (MR_Word) ((MR_Unsigned) 0U);
  else
  {
    MR_ArrayPtr RestArray_5 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(1), HeadVar__1_1, (MR_Integer) 0))));
    MR_Word RestArrays_6 = ((MR_Word) ((MR_hl_field(MR_mktag(1), HeadVar__1_1, (MR_Integer) 1))));
    MR_Word CSDList_8;
    MR_Word CSDLists_9;
    MR_Word Slot_10;
    MR_Box conv0_Slot_10;

    mercury__array__lookup_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_array_slot_0), (MR_ArrayPtr) (RestArray_5), SlotNum_2, &conv0_Slot_10);
    Slot_10 = ((MR_Word) (conv0_Slot_10));
    if (((MR_tag((MR_Word) Slot_10)) == (MR_Integer) 1))
    {
      MR_ArrayPtr CSDArray_13 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(1), Slot_10, (MR_Integer) 1))));

      mercury__array__to_list_2_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), (MR_ArrayPtr) (CSDArray_13), &CSDList_8);
    }
    else
      {
        mercury__require__unexpected_2_p_0((MR_String) "predicate \140canonical.lookup_multi_sites\'/3", (MR_String) "found normal");
        return;
      }
    canonical__lookup_multi_sites_3_p_0(RestArrays_6, SlotNum_2, &CSDLists_9);
    {
      MR_Word base;
      base = (MR_Word) MR_mkword(MR_mktag(1), MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL));
      *HeadVar__3_3 = base;
      MR_hl_field(MR_mktag(1), base, 0) = ((MR_Box) (CSDList_8));
      MR_hl_field(MR_mktag(1), base, 1) = ((MR_Box) (CSDLists_9));
    }
  }
}

static void MR_CALL 
canonical__lookup_normal_sites_3_p_0(
  MR_Word HeadVar__1_1,
  MR_Integer SlotNum_2,
  MR_Word * HeadVar__3_3)
{
  if ((HeadVar__1_1 == (MR_Word) ((MR_Unsigned) 0U)))
    *HeadVar__3_3 = (MR_Word) ((MR_Unsigned) 0U);
  else
  {
    MR_ArrayPtr RestArray_5 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(1), HeadVar__1_1, (MR_Integer) 0))));
    MR_Word RestArrays_6 = ((MR_Word) ((MR_hl_field(MR_mktag(1), HeadVar__1_1, (MR_Integer) 1))));
    MR_Word CSDPtr_8;
    MR_Word CSDPtrs_9;
    MR_Word Slot_10;
    MR_Box conv0_Slot_10;

    mercury__array__lookup_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_array_slot_0), (MR_ArrayPtr) (RestArray_5), SlotNum_2, &conv0_Slot_10);
    Slot_10 = ((MR_Word) (conv0_Slot_10));
    if (((MR_tag((MR_Word) Slot_10)) == (MR_Integer) 1))
      {
        mercury__require__unexpected_2_p_0((MR_String) "predicate \140canonical.lookup_normal_sites\'/3", (MR_String) "found slot_multi");
        return;
      }
    else
      CSDPtr_8 = ((MR_Word) ((MR_hl_field(MR_mktag(0), Slot_10, (MR_Integer) 0))));
    canonical__lookup_normal_sites_3_p_0(RestArrays_6, SlotNum_2, &CSDPtrs_9);
    {
      MR_Word base;
      base = (MR_Word) MR_mkword(MR_mktag(1), MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL));
      *HeadVar__3_3 = base;
      MR_hl_field(MR_mktag(1), base, 0) = ((MR_Box) (CSDPtr_8));
      MR_hl_field(MR_mktag(1), base, 1) = ((MR_Box) (CSDPtrs_9));
    }
  }
}

static void MR_CALL 
canonical__canonicalize_cliques_2_p_0_2(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv7_STATE_VARIABLE_PD_11;

    canonical__subst_in_proc_dynamic_3_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)), &conv7_STATE_VARIABLE_PD_11);
    *wrapper_arg_2 = ((MR_Box) (conv7_STATE_VARIABLE_PD_11));
  }
}

static void MR_CALL 
canonical__canonicalize_cliques_2_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box * wrapper_arg_2)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv4_STATE_VARIABLE_CSD_12;

    canonical__subst_in_call_site_dynamic_3_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)), &conv4_STATE_VARIABLE_CSD_12);
    *wrapper_arg_2 = ((MR_Box) (conv4_STATE_VARIABLE_CSD_12));
  }
}

void MR_CALL 
canonical__canonicalize_cliques_2_p_0(
  MR_Word STATE_VARIABLE_InitDeep_0_16,
  MR_Word * STATE_VARIABLE_InitDeep_17)
{
  {
    MR_Integer MaxCSDs_4;
    MR_Integer MaxPDs_5;
    MR_Integer NumCSDs_6;
    MR_Integer NumPDs_7;
    MR_Word CliqueList_8;
    MR_ArrayPtr Cliques_9;
    MR_ArrayPtr CliqueIndex_10;
    MR_Word MergeInfo_11;
    MR_ArrayPtr CSDRedirect0_12;
    MR_ArrayPtr PDRedirect0_13;
    MR_Word Redirect0_14;
    MR_Word Redirect1_15;
    MR_ArrayPtr Var_18 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_0_16, (MR_Integer) 2))));
    MR_ArrayPtr Var_19;
    MR_Word STATE_VARIABLE_InitDeep_26_26;
    MR_ArrayPtr CSDredirect0_48;
    MR_ArrayPtr PDredirect0_49;
    MR_Word Stats_50;
    MR_Word Root0_51;
    MR_ArrayPtr CSDs0_52;
    MR_ArrayPtr PDs0_53;
    MR_ArrayPtr CSSs_54;
    MR_ArrayPtr PSs_55;
    MR_Integer NumCSD_56;
    MR_ArrayPtr CSDredirect_57;
    MR_Integer NumPD_58;
    MR_ArrayPtr PDredirect_59;
    MR_Word Redirect_60;
    MR_ArrayPtr CSDs1_61;
    MR_ArrayPtr PDs1_62;
    MR_ArrayPtr CSDs_63;
    MR_ArrayPtr PDs_64;
    MR_Word Root_65;
    MR_ArrayPtr Var_68;
    MR_ArrayPtr Var_71;
    MR_Word Var_72;
    MR_ArrayPtr Var_73;
    MR_Word Var_74;
    MR_ArrayPtr Var_75;
    MR_Integer PDI_90;
    MR_ArrayPtr conv0_CSDRedirect0_12;
    MR_ArrayPtr conv1_PDRedirect0_13;
    MR_Box conv2_Var_68;
    MR_Box conv3_Var_71;
    MR_Box conv5_Var_73;
    MR_ArrayPtr conv6_CSDs1_61;
    MR_Box conv8_Var_75;
    MR_ArrayPtr conv9_PDs1_62;
    MR_ArrayPtr conv10_CSDs_63;
    MR_ArrayPtr conv11_PDs_64;
    MR_Box conv12_Root_65;

    MaxCSDs_4 = mercury__array__max_1_f_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_0), (MR_ArrayPtr) (Var_18));
    Var_19 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_0_16, (MR_Integer) 3))));
    MaxPDs_5 = mercury__array__max_1_f_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_0), (MR_ArrayPtr) (Var_19));
    NumCSDs_6 = (MR_Integer) ((MR_Unsigned) MaxCSDs_4 + (MR_Unsigned) 1);
    NumPDs_7 = (MR_Integer) ((MR_Unsigned) MaxPDs_5 + (MR_Unsigned) 1);
    callgraph__find_cliques_2_p_0(STATE_VARIABLE_InitDeep_0_16, &CliqueList_8);
    callgraph__make_clique_indexes_4_p_0(NumPDs_7, CliqueList_8, &Cliques_9, &CliqueIndex_10);
    {
      MergeInfo_11 = (MR_Word) MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), MergeInfo_11, 0) = ((MR_Box) (Cliques_9));
      MR_hl_field(MR_mktag(0), MergeInfo_11, 1) = ((MR_Box) (CliqueIndex_10));
    }
    conv0_CSDRedirect0_12 = mercury__array__init_2_f_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), NumCSDs_6, ((MR_Box) (((MR_Box) ((MR_Integer) 0)))));
    CSDRedirect0_12 = (MR_ArrayPtr) (conv0_CSDRedirect0_12);
    conv1_PDRedirect0_13 = mercury__array__init_2_f_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), NumPDs_7, ((MR_Box) (((MR_Box) ((MR_Integer) 0)))));
    PDRedirect0_13 = (MR_ArrayPtr) (conv1_PDRedirect0_13);
    {
      Redirect0_14 = (MR_Word) MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), Redirect0_14, 0) = ((MR_Box) (CSDRedirect0_12));
      MR_hl_field(MR_mktag(0), Redirect0_14, 1) = ((MR_Box) (PDRedirect0_13));
    }
    canonical__merge_cliques_6_p_0(CliqueList_8, MergeInfo_11, STATE_VARIABLE_InitDeep_0_16, &STATE_VARIABLE_InitDeep_26_26, Redirect0_14, &Redirect1_15);
    CSDredirect0_48 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), Redirect1_15, (MR_Integer) 0))));
    PDredirect0_49 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), Redirect1_15, (MR_Integer) 1))));
    Stats_50 = ((MR_Word) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_26_26, (MR_Integer) 0))));
    Root0_51 = ((MR_Word) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_26_26, (MR_Integer) 1))));
    CSDs0_52 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_26_26, (MR_Integer) 2))));
    PDs0_53 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_26_26, (MR_Integer) 3))));
    CSSs_54 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_26_26, (MR_Integer) 4))));
    PSs_55 = ((MR_ArrayPtr) ((MR_hl_field(MR_mktag(0), STATE_VARIABLE_InitDeep_26_26, (MR_Integer) 5))));
    conv2_Var_68 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[7]), ((MR_Box) (CSDredirect0_48)));
    Var_68 = ((MR_ArrayPtr) (conv2_Var_68));
    canonical__compact_csd_redirect_6_p_0((MR_Integer) 1, (MR_Integer) 1, NumCSDs_6, &NumCSD_56, Var_68, &CSDredirect_57);
    conv3_Var_71 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[6]), ((MR_Box) (PDredirect0_49)));
    Var_71 = ((MR_ArrayPtr) (conv3_Var_71));
    canonical__compact_pd_redirect_6_p_0((MR_Integer) 1, (MR_Integer) 1, NumPDs_7, &NumPD_58, Var_71, &PDredirect_59);
    {
      Redirect_60 = (MR_Word) MR_new_object(MR_Word, (2 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), Redirect_60, 0) = ((MR_Box) (CSDredirect_57));
      MR_hl_field(MR_mktag(0), Redirect_60, 1) = ((MR_Box) (PDredirect_59));
    }
    {
      Var_72 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), Var_72, 0) = ((MR_Box) (&canonical_scalar_common_3[1]));
      MR_hl_field(MR_mktag(0), Var_72, 1) = ((MR_Box) (canonical__canonicalize_cliques_2_p_0_1));
      MR_hl_field(MR_mktag(0), Var_72, 2) = ((MR_Box) ((MR_Integer) 1));
      MR_hl_field(MR_mktag(0), Var_72, 3) = ((MR_Box) (Redirect_60));
    }
    conv5_Var_73 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[5]), ((MR_Box) (CSDs0_52)));
    Var_73 = ((MR_ArrayPtr) (conv5_Var_73));
    array_util__array_map_from_1_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_0), Var_72, (MR_ArrayPtr) (Var_73), &conv6_CSDs1_61);
    CSDs1_61 = (MR_ArrayPtr) (conv6_CSDs1_61);
    {
      Var_74 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), Var_74, 0) = ((MR_Box) (&canonical_scalar_common_3[2]));
      MR_hl_field(MR_mktag(0), Var_74, 1) = ((MR_Box) (canonical__canonicalize_cliques_2_p_0_2));
      MR_hl_field(MR_mktag(0), Var_74, 2) = ((MR_Box) ((MR_Integer) 1));
      MR_hl_field(MR_mktag(0), Var_74, 3) = ((MR_Box) (Redirect_60));
    }
    conv8_Var_75 = array_util__u_1_f_0((MR_Word) (&canonical_scalar_common_1[3]), ((MR_Box) (PDs0_53)));
    Var_75 = ((MR_ArrayPtr) (conv8_Var_75));
    array_util__array_map_from_1_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_0), Var_74, (MR_ArrayPtr) (Var_75), &conv9_PDs1_62);
    PDs1_62 = (MR_ArrayPtr) (conv9_PDs1_62);
    mercury__array__shrink_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_0), NumCSD_56, (MR_ArrayPtr) (CSDs1_61), &conv10_CSDs_63);
    CSDs_63 = (MR_ArrayPtr) (conv10_CSDs_63);
    mercury__array__shrink_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_0), NumPD_58, (MR_ArrayPtr) (PDs1_62), &conv11_PDs_64);
    PDs_64 = (MR_ArrayPtr) (conv11_PDs_64);
    PDI_90 = (MR_Integer) (Root0_51);
    mercury__array__lookup_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), (MR_ArrayPtr) (PDredirect_59), PDI_90, &conv12_Root_65);
    Root_65 = ((MR_Word) (conv12_Root_65));
    {
      MR_Word base;
      base = (MR_Word) MR_new_object(MR_Word, (6 * sizeof(MR_Word)), NULL, NULL);
      *STATE_VARIABLE_InitDeep_17 = base;
      MR_hl_field(MR_mktag(0), base, 0) = ((MR_Box) (Stats_50));
      MR_hl_field(MR_mktag(0), base, 1) = ((MR_Box) (Root_65));
      MR_hl_field(MR_mktag(0), base, 2) = ((MR_Box) (CSDs_63));
      MR_hl_field(MR_mktag(0), base, 3) = ((MR_Box) (PDs_64));
      MR_hl_field(MR_mktag(0), base, 4) = ((MR_Box) (CSSs_54));
      MR_hl_field(MR_mktag(0), base, 5) = ((MR_Box) (PSs_55));
    }
  }
}

static void MR_CALL 
canonical__compact_pd_redirect_6_p_0(
  MR_Integer CurOld_7,
  MR_Integer CurNew_8,
  MR_Integer MaxOld_9,
  MR_Integer * NumNew_10,
  MR_ArrayPtr STATE_VARIABLE_PDredirect_0_13,
  MR_ArrayPtr * STATE_VARIABLE_PDredirect_14)
{
  while (MR_TRUE)
  {
    MR_bool succeeded = (CurOld_7 > MaxOld_9);

    // setup for model_det tailcalls optimized into a loop
    ;
    if (succeeded)
    {
      *NumNew_10 = CurNew_8;
      *STATE_VARIABLE_PDredirect_14 = STATE_VARIABLE_PDredirect_0_13;
    }
    else
    {
      MR_Word Redirect0_12;
      MR_Box conv0_Redirect0_12;
      MR_Integer Var_15;

      mercury__array__lookup_3_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), (MR_ArrayPtr) (STATE_VARIABLE_PDredirect_0_13), CurOld_7, &conv0_Redirect0_12);
      Redirect0_12 = ((MR_Word) (conv0_Redirect0_12));
      Var_15 = (MR_Integer) (Redirect0_12);
      succeeded = (Var_15 == (MR_Integer) 0);
      if (succeeded)
      {
        MR_Word Var_16 = (MR_Word) (CurNew_8);
        MR_ArrayPtr STATE_VARIABLE_PDredirect_17_17;
        MR_Integer Var_18;
        MR_Integer Var_19;
        MR_ArrayPtr conv1_STATE_VARIABLE_PDredirect_17_17;
        MR_Integer next_value_of_CurOld_7;
        MR_Integer next_value_of_CurNew_8;
        MR_ArrayPtr next_value_of_STATE_VARIABLE_PDredirect_0_13;

        mercury__array__set_4_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), CurOld_7, ((MR_Box) (Var_16)), (MR_ArrayPtr) (STATE_VARIABLE_PDredirect_0_13), &conv1_STATE_VARIABLE_PDredirect_17_17);
        STATE_VARIABLE_PDredirect_17_17 = (MR_ArrayPtr) (conv1_STATE_VARIABLE_PDredirect_17_17);
        Var_18 = (MR_Integer) ((MR_Unsigned) CurOld_7 + (MR_Unsigned) 1);
        Var_19 = (MR_Integer) ((MR_Unsigned) CurNew_8 + (MR_Unsigned) 1);
        // direct tailcall eliminated
        ;
        next_value_of_CurOld_7 = Var_18;
        next_value_of_CurNew_8 = Var_19;
        next_value_of_STATE_VARIABLE_PDredirect_0_13 = STATE_VARIABLE_PDredirect_17_17;
        CurOld_7 = next_value_of_CurOld_7;
        CurNew_8 = next_value_of_CurNew_8;
        STATE_VARIABLE_PDredirect_0_13 = next_value_of_STATE_VARIABLE_PDredirect_0_13;
        continue;
      }
      else
      {
        MR_Integer Var_23 = (MR_Integer) ((MR_Unsigned) CurOld_7 + (MR_Unsigned) 1);
        MR_Integer next_value_of_CurOld_7 = Var_23;

        // direct tailcall eliminated
        ;
        CurOld_7 = next_value_of_CurOld_7;
        continue;
      }
    }
    break;
  }
}

static void MR_CALL 
canonical__compact_csd_redirect_6_p_0(
  MR_Integer CurOld_7,
  MR_Integer CurNew_8,
  MR_Integer MaxOld_9,
  MR_Integer * NumNew_10,
  MR_ArrayPtr STATE_VARIABLE_CSDredirect_0_13,
  MR_ArrayPtr * STATE_VARIABLE_CSDredirect_14)
{
  while (MR_TRUE)
  {
    MR_bool succeeded = (CurOld_7 > MaxOld_9);

    // setup for model_det tailcalls optimized into a loop
    ;
    if (succeeded)
    {
      *NumNew_10 = CurNew_8;
      *STATE_VARIABLE_CSDredirect_14 = STATE_VARIABLE_CSDredirect_0_13;
    }
    else
    {
      MR_Word Redirect0_12;
      MR_Box conv0_Redirect0_12;
      MR_Integer Var_15;

      mercury__array__lookup_3_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), (MR_ArrayPtr) (STATE_VARIABLE_CSDredirect_0_13), CurOld_7, &conv0_Redirect0_12);
      Redirect0_12 = ((MR_Word) (conv0_Redirect0_12));
      Var_15 = (MR_Integer) (Redirect0_12);
      succeeded = (Var_15 == (MR_Integer) 0);
      if (succeeded)
      {
        MR_Word Var_16 = (MR_Word) (CurNew_8);
        MR_ArrayPtr STATE_VARIABLE_CSDredirect_17_17;
        MR_Integer Var_18;
        MR_Integer Var_19;
        MR_ArrayPtr conv1_STATE_VARIABLE_CSDredirect_17_17;
        MR_Integer next_value_of_CurOld_7;
        MR_Integer next_value_of_CurNew_8;
        MR_ArrayPtr next_value_of_STATE_VARIABLE_CSDredirect_0_13;

        mercury__array__set_4_p_0((MR_Word) (&profile__profile__type_ctor_info_call_site_dynamic_ptr_0), CurOld_7, ((MR_Box) (Var_16)), (MR_ArrayPtr) (STATE_VARIABLE_CSDredirect_0_13), &conv1_STATE_VARIABLE_CSDredirect_17_17);
        STATE_VARIABLE_CSDredirect_17_17 = (MR_ArrayPtr) (conv1_STATE_VARIABLE_CSDredirect_17_17);
        Var_18 = (MR_Integer) ((MR_Unsigned) CurOld_7 + (MR_Unsigned) 1);
        Var_19 = (MR_Integer) ((MR_Unsigned) CurNew_8 + (MR_Unsigned) 1);
        // direct tailcall eliminated
        ;
        next_value_of_CurOld_7 = Var_18;
        next_value_of_CurNew_8 = Var_19;
        next_value_of_STATE_VARIABLE_CSDredirect_0_13 = STATE_VARIABLE_CSDredirect_17_17;
        CurOld_7 = next_value_of_CurOld_7;
        CurNew_8 = next_value_of_CurNew_8;
        STATE_VARIABLE_CSDredirect_0_13 = next_value_of_STATE_VARIABLE_CSDredirect_0_13;
        continue;
      }
      else
      {
        MR_Integer Var_23 = (MR_Integer) ((MR_Unsigned) CurOld_7 + (MR_Unsigned) 1);
        MR_Integer next_value_of_CurOld_7 = Var_23;

        // direct tailcall eliminated
        ;
        CurOld_7 = next_value_of_CurOld_7;
        continue;
      }
    }
    break;
  }
}

static void MR_CALL 
canonical__merge_cliques_6_p_0_4(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3,
  MR_Box wrapper_arg_4,
  MR_Box * wrapper_arg_5)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv3_STATE_VARIABLE_InitDeep_15;
    MR_Word conv2_STATE_VARIABLE_Redirect_17;

    canonical__merge_proc_dynamics_ignore_chosen_7_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 4)))), ((MR_Word) (wrapper_arg_1)), ((MR_Word) (wrapper_arg_2)), &conv3_STATE_VARIABLE_InitDeep_15, ((MR_Word) (wrapper_arg_4)), &conv2_STATE_VARIABLE_Redirect_17);
    *wrapper_arg_3 = ((MR_Box) (conv3_STATE_VARIABLE_InitDeep_15));
    *wrapper_arg_5 = ((MR_Box) (conv2_STATE_VARIABLE_Redirect_17));
  }
}

static MR_bool MR_CALL 
canonical__merge_cliques_6_p_0_3(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1)
{
  {
    MR_bool succeeded;
    MR_Box closure = closure_arg;

    succeeded = canonical__two_or_more_1_p_0(((MR_Word) (wrapper_arg_1)));
    return succeeded;
  }
}

static MR_bool MR_CALL 
canonical__merge_cliques_6_p_0_2(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1)
{
  {
    MR_bool succeeded;
    MR_Box closure = closure_arg;

    succeeded = canonical__two_or_more_1_p_0(((MR_Word) (wrapper_arg_1)));
    return succeeded;
  }
}

static void MR_CALL 
canonical__merge_cliques_6_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv0_STATE_VARIABLE_ProcMap_13;

    canonical__cluster_pds_by_ps_4_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) (wrapper_arg_1)), ((MR_Word) (wrapper_arg_2)), &conv0_STATE_VARIABLE_ProcMap_13);
    *wrapper_arg_3 = ((MR_Box) (conv0_STATE_VARIABLE_ProcMap_13));
  }
}

static void MR_CALL 
canonical__merge_cliques_6_p_0(
  MR_Word HeadVar__1_1,
  MR_Word MergeInfo_2,
  MR_Word STATE_VARIABLE_InitDeep_0_3,
  MR_Word * STATE_VARIABLE_InitDeep_4,
  MR_Word STATE_VARIABLE_Redirect_0_5,
  MR_Word * STATE_VARIABLE_Redirect_6)
{
  while (MR_TRUE)
  {
    MR_bool succeeded;

    // setup for model_det tailcalls optimized into a loop
    ;
    if ((HeadVar__1_1 == (MR_Word) ((MR_Unsigned) 0U)))
    {
      *STATE_VARIABLE_Redirect_6 = STATE_VARIABLE_Redirect_0_5;
      *STATE_VARIABLE_InitDeep_4 = STATE_VARIABLE_InitDeep_0_3;
    }
    else
    {
      MR_Word Clique_14 = ((MR_Word) ((MR_hl_field(MR_mktag(1), HeadVar__1_1, (MR_Integer) 0))));
      MR_Word Cliques_15 = ((MR_Word) ((MR_hl_field(MR_mktag(1), HeadVar__1_1, (MR_Integer) 1))));
      MR_Word STATE_VARIABLE_InitDeep_23_23;
      MR_Word STATE_VARIABLE_Redirect_24_24;
      MR_Word next_value_of_HeadVar__1_1;
      MR_Word next_value_of_STATE_VARIABLE_InitDeep_0_3;
      MR_Word next_value_of_STATE_VARIABLE_Redirect_0_5;

      if ((Clique_14 == (MR_Word) ((MR_Unsigned) 0U)))
      {
        STATE_VARIABLE_InitDeep_23_23 = STATE_VARIABLE_InitDeep_0_3;
        STATE_VARIABLE_Redirect_24_24 = STATE_VARIABLE_Redirect_0_5;
      }
      else
      {
        MR_Word Var_73 = ((MR_Word) ((MR_hl_field(MR_mktag(1), Clique_14, (MR_Integer) 1))));

        if ((Var_73 == (MR_Word) ((MR_Unsigned) 0U)))
        {
          STATE_VARIABLE_InitDeep_23_23 = STATE_VARIABLE_InitDeep_0_3;
          STATE_VARIABLE_Redirect_24_24 = STATE_VARIABLE_Redirect_0_5;
        }
        else
        {
          MR_Word ProcMap0_39;
          MR_Word ProcMap1_40;
          MR_Word PDsList1_41;
          MR_Word ToMergePDsList1_42;
          MR_Word Var_50;
          MR_Box conv1_ProcMap1_40;

          mercury__map__init_1_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_static_ptr_0), (MR_Word) (&canonical_scalar_common_1[0]), &ProcMap0_39);
          {
            Var_50 = (MR_Word) MR_new_object(MR_Word, (4 * sizeof(MR_Word)), NULL, NULL);
            MR_hl_field(MR_mktag(0), Var_50, 0) = ((MR_Box) (&canonical_scalar_common_5[0]));
            MR_hl_field(MR_mktag(0), Var_50, 1) = ((MR_Box) (canonical__merge_cliques_6_p_0_1));
            MR_hl_field(MR_mktag(0), Var_50, 2) = ((MR_Box) ((MR_Integer) 1));
            MR_hl_field(MR_mktag(0), Var_50, 3) = ((MR_Box) (STATE_VARIABLE_InitDeep_0_3));
          }
          mercury__list__foldl_4_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0), (MR_Word) (&canonical_scalar_common_2[0]), Var_50, Clique_14, ((MR_Box) (ProcMap0_39)), &conv1_ProcMap1_40);
          ProcMap1_40 = ((MR_Word) (conv1_ProcMap1_40));
          mercury__map__values_2_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_static_ptr_0), (MR_Word) (&canonical_scalar_common_1[0]), ProcMap1_40, &PDsList1_41);
          mercury__list__filter_3_p_0((MR_Word) (&canonical_scalar_common_1[0]), (MR_Word) (&canonical_scalar_common_2[4]), PDsList1_41, &ToMergePDsList1_42);
          if ((ToMergePDsList1_42 == (MR_Word) ((MR_Unsigned) 0U)))
          {
            STATE_VARIABLE_InitDeep_23_23 = STATE_VARIABLE_InitDeep_0_3;
            STATE_VARIABLE_Redirect_24_24 = STATE_VARIABLE_Redirect_0_5;
          }
          else
          {
            MR_Word ProcMap_45;
            MR_Word Clique_46;
            MR_Word PDsList_47;
            MR_Word ToMergePDsList_48;
            MR_Word Var_53;
            MR_Box conv5_STATE_VARIABLE_InitDeep_23_23;
            MR_Box conv4_STATE_VARIABLE_Redirect_24_24;

            canonical__f_85_110_117_115_101_100_65_114_103_115_95_95_112_114_101_100_95_95_99_111_109_112_108_101_116_101_95_99_108_105_113_117_101_95_95_91_50_93_95_48_5_p_0(STATE_VARIABLE_InitDeep_0_3, ProcMap1_40, &ProcMap_45, &Clique_46);
            mercury__map__values_2_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_static_ptr_0), (MR_Word) (&canonical_scalar_common_1[0]), ProcMap_45, &PDsList_47);
            mercury__list__filter_3_p_0((MR_Word) (&canonical_scalar_common_1[0]), (MR_Word) (&canonical_scalar_common_2[5]), PDsList_47, &ToMergePDsList_48);
            {
              Var_53 = (MR_Word) MR_new_object(MR_Word, (5 * sizeof(MR_Word)), NULL, NULL);
              MR_hl_field(MR_mktag(0), Var_53, 0) = ((MR_Box) (&canonical_scalar_common_4[1]));
              MR_hl_field(MR_mktag(0), Var_53, 1) = ((MR_Box) (canonical__merge_cliques_6_p_0_4));
              MR_hl_field(MR_mktag(0), Var_53, 2) = ((MR_Box) ((MR_Integer) 2));
              MR_hl_field(MR_mktag(0), Var_53, 3) = ((MR_Box) (MergeInfo_2));
              MR_hl_field(MR_mktag(0), Var_53, 4) = ((MR_Box) (Clique_46));
            }
            mercury__list__foldl2_6_p_0((MR_Word) (&canonical_scalar_common_1[0]), (MR_Word) (&profile__profile__type_ctor_info_initial_deep_0), (MR_Word) (&canonical__canonical__type_ctor_info_redirect_0), Var_53, ToMergePDsList_48, ((MR_Box) (STATE_VARIABLE_InitDeep_0_3)), &conv5_STATE_VARIABLE_InitDeep_23_23, ((MR_Box) (STATE_VARIABLE_Redirect_0_5)), &conv4_STATE_VARIABLE_Redirect_24_24);
            STATE_VARIABLE_InitDeep_23_23 = ((MR_Word) (conv5_STATE_VARIABLE_InitDeep_23_23));
            STATE_VARIABLE_Redirect_24_24 = ((MR_Word) (conv4_STATE_VARIABLE_Redirect_24_24));
          }
        }
      }
      // direct tailcall eliminated
      ;
      next_value_of_HeadVar__1_1 = Cliques_15;
      next_value_of_STATE_VARIABLE_InitDeep_0_3 = STATE_VARIABLE_InitDeep_23_23;
      next_value_of_STATE_VARIABLE_Redirect_0_5 = STATE_VARIABLE_Redirect_24_24;
      HeadVar__1_1 = next_value_of_HeadVar__1_1;
      STATE_VARIABLE_InitDeep_0_3 = next_value_of_STATE_VARIABLE_InitDeep_0_3;
      STATE_VARIABLE_Redirect_0_5 = next_value_of_STATE_VARIABLE_Redirect_0_5;
      continue;
    }
    break;
  }
}

static void MR_CALL 
canonical__f_85_110_117_115_101_100_65_114_103_115_95_95_112_114_101_100_95_95_99_111_109_112_108_101_116_101_95_99_108_105_113_117_101_95_95_91_50_93_95_48_5_p_0_2(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3,
  MR_Box wrapper_arg_4,
  MR_Box * wrapper_arg_5)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv3_STATE_VARIABLE_ProcMap_20;
    MR_Word conv2_STATE_VARIABLE_AddedPD_22;

    canonical__complete_clique_ps_7_p_0(((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 3)))), ((MR_Word) ((MR_hl_field(MR_mktag(0), closure, (MR_Integer) 4)))), ((MR_Word) (wrapper_arg_1)), ((MR_Word) (wrapper_arg_2)), &conv3_STATE_VARIABLE_ProcMap_20, ((MR_Word) (wrapper_arg_4)), &conv2_STATE_VARIABLE_AddedPD_22);
    *wrapper_arg_3 = ((MR_Box) (conv3_STATE_VARIABLE_ProcMap_20));
    *wrapper_arg_5 = ((MR_Box) (conv2_STATE_VARIABLE_AddedPD_22));
  }
}

static void MR_CALL 
canonical__f_85_110_117_115_101_100_65_114_103_115_95_95_112_114_101_100_95_95_99_111_109_112_108_101_116_101_95_99_108_105_113_117_101_95_95_91_50_93_95_48_5_p_0_1(
  MR_Box closure_arg,
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box * wrapper_arg_3)
{
  {
    MR_Box closure = closure_arg;
    MR_Word conv0_HeadVar__3_24;

    canonical__IntroducedFrom__pred__complete_clique__130__1_3_p_0(((MR_Word) (wrapper_arg_1)), ((MR_Word) (wrapper_arg_2)), &conv0_HeadVar__3_24);
    *wrapper_arg_3 = ((MR_Box) (conv0_HeadVar__3_24));
  }
}

static void MR_CALL 
canonical__f_85_110_117_115_101_100_65_114_103_115_95_95_112_114_101_100_95_95_99_111_109_112_108_101_116_101_95_99_108_105_113_117_101_95_95_91_50_93_95_48_5_p_0(
  MR_Word InitDeep_6,
  MR_Word STATE_VARIABLE_ProcMap_0_13,
  MR_Word * STATE_VARIABLE_ProcMap_14,
  MR_Word * Clique_9)
{
  while (MR_TRUE)
  {
    MR_Word PDsList0_10;
    MR_Word Clique0_11;
    MR_Word AddedPD_12;
    MR_Word Var_16;
    MR_Word STATE_VARIABLE_ProcMap_17_17;
    MR_Word PSPDs0_37;
    MR_Word Var_38;
    MR_Box conv1_Clique0_11;
    MR_Box conv5_STATE_VARIABLE_ProcMap_17_17;
    MR_Box conv4_AddedPD_12;

    // setup for model_det tailcalls optimized into a loop
    ;
    mercury__map__values_2_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_static_ptr_0), (MR_Word) (&canonical_scalar_common_1[0]), STATE_VARIABLE_ProcMap_0_13, &PDsList0_10);
    Var_16 = mercury__set__init_0_f_0((MR_Word) (&profile__profile__type_ctor_info_proc_dynamic_ptr_0));
    mercury__list__foldl_4_p_0((MR_Word) (&canonical_scalar_common_1[0]), (MR_Word) (&canonical_scalar_common_1[1]), (MR_Word) (&canonical_scalar_common_2[3]), PDsList0_10, ((MR_Box) (Var_16)), &conv1_Clique0_11);
    Clique0_11 = ((MR_Word) (conv1_Clique0_11));
    mercury__map__to_assoc_list_2_p_0((MR_Word) (&profile__profile__type_ctor_info_proc_static_ptr_0), (MR_Word) (&canonical_scalar_common_1[0]), STATE_VARIABLE_ProcMap_0_13, &PSPDs0_37);
    {
      Var_38 = (MR_Word) MR_new_object(MR_Word, (5 * sizeof(MR_Word)), NULL, NULL);
      MR_hl_field(MR_mktag(0), Var_38, 0) = ((MR_Box) (&canonical_scalar_common_4[0]));
      MR_hl_field(MR_mktag(0), Var_38, 1) = ((MR_Box) (canonical__f_85_110_117_115_101_100_65_114_103_115_95_95_112_114_101_100_95_95_99_111_109_112_108_101_116_101_95_99_108_105_113_117_101_95_95_91_50_93_95_48_5_p_0_2));
      MR_hl_field(MR_mktag(0), Var_38, 2) = ((MR_Box) ((MR_Integer) 2));
      MR_hl_field(MR_mktag(0), Var_38, 3) = ((MR_Box) (InitDeep_6));
      MR_hl_field(MR_mktag(0), Var_38, 4) = ((MR_Box) (Clique0_11));
    }
    mercury__list__foldl2_6_p_0((MR_Word) (&canonical_scalar_common_2[1]), (MR_Word) (&canonical_scalar_common_2[0]), (MR_Word) (&mercury__bool__bool__type_ctor_info_bool_0), Var_38, PSPDs0_37, ((MR_Box) (STATE_VARIABLE_ProcMap_0_13)), &conv5_STATE_VARIABLE_ProcMap_17_17, ((MR_Box) ((MR_Integer) 0)), &conv4_AddedPD_12);
    STATE_VARIABLE_ProcMap_17_17 = ((MR_Word) (conv5_STATE_VARIABLE_ProcMap_17_17));
    AddedPD_12 = ((MR_Word) (conv4_AddedPD_12));
    switch (AddedPD_12) {
      default: /*NOTREACHED*/ MR_assert(0);
      case (MR_Integer) 0:
        {
          *Clique_9 = Clique0_11;
          *STATE_VARIABLE_ProcMap_14 = STATE_VARIABLE_ProcMap_17_17;
        }
        break;
      case (MR_Integer) 1:
        {
          MR_Word next_value_of_STATE_VARIABLE_ProcMap_0_13 = STATE_VARIABLE_ProcMap_17_17;

          // direct tailcall eliminated
          ;
          STATE_VARIABLE_ProcMap_0_13 = next_value_of_STATE_VARIABLE_ProcMap_0_13;
          continue;
        }
        break;
    }
    break;
  }
}

static MR_bool MR_CALL 
canonical____Unify____merge_info_0_0_10001(
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2)
{
  {
    MR_bool succeeded;

    succeeded = canonical____Unify____merge_info_0_0(((MR_Word) (wrapper_arg_1)), ((MR_Word) (wrapper_arg_2)));
    return succeeded;
  }
}

static void MR_CALL 
canonical____Compare____merge_info_0_0_10001(
  MR_Box * wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box wrapper_arg_3)
{
  {
    MR_Word conv0_HeadVar__1_1;

    canonical____Compare____merge_info_0_0(&conv0_HeadVar__1_1, ((MR_Word) (wrapper_arg_2)), ((MR_Word) (wrapper_arg_3)));
    *wrapper_arg_1 = ((MR_Box) (conv0_HeadVar__1_1));
  }
}

static MR_bool MR_CALL 
canonical____Unify____redirect_0_0_10001(
  MR_Box wrapper_arg_1,
  MR_Box wrapper_arg_2)
{
  {
    MR_bool succeeded;

    succeeded = canonical____Unify____redirect_0_0(((MR_Word) (wrapper_arg_1)), ((MR_Word) (wrapper_arg_2)));
    return succeeded;
  }
}

static void MR_CALL 
canonical____Compare____redirect_0_0_10001(
  MR_Box * wrapper_arg_1,
  MR_Box wrapper_arg_2,
  MR_Box wrapper_arg_3)
{
  {
    MR_Word conv0_HeadVar__1_1;

    canonical____Compare____redirect_0_0(&conv0_HeadVar__1_1, ((MR_Word) (wrapper_arg_2)), ((MR_Word) (wrapper_arg_3)));
    *wrapper_arg_1 = ((MR_Box) (conv0_HeadVar__1_1));
  }
}

void mercury__canonical__init(void)
{
}

void mercury__canonical__init_type_tables(void)
{
	static MR_bool initialised = MR_FALSE;
	if (initialised) return;
	initialised = MR_TRUE;

	MR_register_type_ctor_info(&canonical__canonical__type_ctor_info_merge_info_0);
	MR_register_type_ctor_info(&canonical__canonical__type_ctor_info_redirect_0);
}

void mercury__canonical__init_debugger(void)
{
	MR_fatal_error("debugger initialization in MLDS grade");
}

// Ensure everything is compiled with the same grade.
const char *mercury__canonical__grade_check(void)
{
    return &MR_GRADE_VAR;
}

// :- end_module canonical.
