+static cli_head_t *get_next_cli_head(const ir_node *irn, cli_iter_t *it) /* ...containing the node *irn */
+{
+ cli_head_t *head;
+ cli_element_t *element;
+
+ int is_dominated_by_max;
+ //int dominates_min;
+
+ if (it->curr_cli_head == NULL || it->curr_cli_head->next_cli_head == NULL) /* way back of recursion or this is the last clique */
+ {
+ it->curr_cli_head = NULL;
+ return NULL;
+ }
+
+ head = it->curr_cli_head->next_cli_head;
+
+ is_dominated_by_max = value_dominates(head->max, irn);
+ //dominates_min = value_dominates(irn, head->min);
+
+ if(head->min->node_nr == 2000)
+ assert("stop");
+
+ if ((is_dominated_by_max) || (irn == head->max)) /* node could be in clique */
+ {
+ /* check if node is in clique */
+ list_for_each_entry(cli_element_t, element, &head->list, list)
+ {
+ if (&element->list != &head->list)
+ {
+ if (element->irn == irn)
+ { /* node is in clique */
+ it->curr_cli_head = head;
+ it->curr_cli_element = (void *) head; /* needed because the next element is searched with list.next of it->curr_cli_element */
+ break;
+ }
+ }
+ }
+
+ if (it->curr_cli_head != head) /*node was not in clique */
+ {
+ it->curr_cli_head = head;
+ head = get_next_cli_head(irn, it);
+ }
+ }
+ else
+ {
+ it->curr_cli_head = head;
+ head = get_next_cli_head(irn, it);
+ }
+ return head;
+}
+
+static cli_element_t *get_next_element(const ir_node *irn, cli_iter_t *it) /* ... of the current clique, returns NULL if there were no more elements ..*/
+{
+ cli_element_t *element = it->curr_cli_element;
+ cli_head_t *head = it->curr_cli_head;
+
+ if (!head || it->curr_cli_element == NULL) /* way back of recursion or there are no more heads */
+ {
+ it->curr_cli_element = NULL;
+ return NULL;
+ }
+ else
+ {
+ element = list_entry(element->list.next, cli_element_t, list);
+
+ if (&element->list == &head->list) /* Clique has no more elements */
+ {
+ head = get_next_cli_head(irn, it);
+ element = get_next_element(irn, it);
+ }
+
+ if (element != NULL && element->irn == irn) /* the node you are searching neighbors for */
+ {
+ it->curr_cli_element = element;
+ element = get_next_element(irn, it);
+ }
+
+ it->curr_cli_element = element;
+
+ return element;
+ }
+}
+