+static int brute_force_minimize (sn_network_t *n_orig)
+{
+ int stage_index;
+ int comparator_index;
+
+ /* printf ("brute_force_minimize: Running full fledged brute force optimization.\n"); */
+
+ for (stage_index = 0;
+ stage_index < SN_NETWORK_STAGE_NUM (n_orig);
+ stage_index++)
+ {
+ sn_stage_t *s_orig;
+
+ s_orig = SN_NETWORK_STAGE_GET (n_orig, stage_index);
+
+ for (comparator_index = 0;
+ comparator_index < SN_STAGE_COMP_NUM (s_orig);
+ comparator_index++)
+ {
+ sn_network_t *n_copy;
+ sn_stage_t *s_copy;
+ int status;
+
+ n_copy = sn_network_clone (n_orig);
+ if (n_copy == NULL)
+ continue;
+
+ s_copy = SN_NETWORK_STAGE_GET (n_copy, stage_index);
+ sn_stage_comparator_remove (s_copy, comparator_index);
+
+ status = sn_network_brute_force_check (n_copy);
+ if (status == 0)
+ {
+ /*
+ printf ("brute_force_minimize: Removed a comparator "
+ "(stage %i, comparator %i).\n",
+ stage_index, comparator_index);
+ */
+ sn_stage_comparator_remove (s_orig, comparator_index);
+
+ comparator_index--;
+ }
+
+ sn_network_destroy (n_copy);
+ n_copy = NULL;
+ } /* for (comparator_index) */
+ } /* for (stage_index) */
+
+ /* FIXME: Remove this check after debugging. */
+ assert (sn_network_brute_force_check (n_orig) == 0);
+
+ return (0);
+} /* int brute_force_minimize */
+