+static void process(co2_t *env)
+{
+ affinity_node_t *a;
+ co2_cloud_t *pos;
+ co2_cloud_t **clouds;
+ int n_clouds;
+ int i;
+ int init_costs = 0;
+ int all_costs = 0;
+ int final_costs = 0;
+
+ n_clouds = 0;
+ co_gs_foreach_aff_node(env->co, a) {
+ co2_cloud_irn_t *ci = get_co2_cloud_irn(env, a->irn);
+
+ if (!ci->cloud) {
+ new_cloud(env, a);
+ n_clouds++;
+ }
+ }
+
+ i = 0;
+ clouds = XMALLOCN(co2_cloud_t*, n_clouds);
+ list_for_each_entry(co2_cloud_t, pos, &env->cloud_head, list)
+ clouds[i++] = pos;
+ qsort(clouds, n_clouds, sizeof(clouds[0]), cmp_clouds_gt);
+
+ for (i = 0; i < n_clouds; ++i) {
+ init_costs += cloud_costs(clouds[i]);
+
+ /* Process the cloud. */
+ process_cloud(clouds[i]);
+
+ all_costs += clouds[i]->costs;
+ final_costs += cloud_costs(clouds[i]);
+
+ /* Dump the IFG if the user demanded it. */
+ if (dump_flags & DUMP_CLOUD) {
+ char buf[256];
+ FILE *f;
+
+ ir_snprintf(buf, sizeof(buf), "ifg_%F_%s_cloud_%d.dot", env->co->irg, env->co->cls->name, i);
+ f = fopen(buf, "wt");
+ if (f != NULL) {
+ be_ifg_dump_dot(env->co->cenv->ifg, env->co->irg, f, &ifg_dot_cb, env);
+ fclose(f);
+ }
+ }
+ }
+
+ DB((env->dbg, LEVEL_1, "all costs: %d, init costs: %d, final costs: %d\n", all_costs, init_costs, final_costs));
+
+ xfree(clouds);
+}