+ lst_p stmt;
+ basic_block bb = GBB_BB (PBB_BLACK_BOX (pbb));
+
+ if (bb->loop_father == loop)
+ stmt = new_lst_stmt (pbb);
+ else if (flow_bb_inside_loop_p (loop, bb))
+ {
+ loop_p next = loop->inner;
+
+ while (next && !flow_bb_inside_loop_p (next, bb))
+ next = next->next;
+
+ stmt = loop_to_lst (next, bbs, i);
+ }
+ else
+ {
+ (*i)--;
+ return new_lst_loop (seq);
+ }
+
+ VEC_safe_push (lst_p, heap, seq, stmt);
+ }
+
+ return new_lst_loop (seq);
+}
+
+/* Reads the original scattering of the SCOP and returns an LST
+ representing it. */
+
+void
+scop_to_lst (scop_p scop)
+{
+ lst_p res;
+ int i, n = VEC_length (poly_bb_p, SCOP_BBS (scop));
+ VEC (lst_p, heap) *seq = VEC_alloc (lst_p, heap, 5);
+ sese region = SCOP_REGION (scop);
+
+ for (i = 0; i < n; i++)
+ {
+ poly_bb_p pbb = VEC_index (poly_bb_p, SCOP_BBS (scop), i);
+ loop_p loop = outermost_loop_in_sese (region, GBB_BB (PBB_BLACK_BOX (pbb)));
+
+ if (loop_in_sese_p (loop, region))
+ res = loop_to_lst (loop, SCOP_BBS (scop), &i);
+ else
+ res = new_lst_stmt (pbb);
+
+ VEC_safe_push (lst_p, heap, seq, res);
+ }
+
+ res = new_lst_loop (seq);
+ SCOP_ORIGINAL_SCHEDULE (scop) = res;
+ SCOP_TRANSFORMED_SCHEDULE (scop) = copy_lst (res);
+}
+
+/* Print to FILE on a new line COLUMN white spaces. */
+
+static void
+lst_indent_to (FILE *file, int column)
+{
+ int i;
+
+ if (column > 0)
+ fprintf (file, "\n#");
+
+ for (i = 0; i < column; i++)
+ fprintf (file, " ");
+}
+
+/* Print LST to FILE with INDENT spaces of indentation. */
+
+void
+print_lst (FILE *file, lst_p lst, int indent)
+{
+ if (!lst)
+ return;
+
+ lst_indent_to (file, indent);
+
+ if (LST_LOOP_P (lst))
+ {
+ int i;
+ lst_p l;
+
+ if (LST_LOOP_FATHER (lst))
+ fprintf (file, "%d (loop", lst_dewey_number (lst));
+ else
+ fprintf (file, "#(root");
+
+ FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l)
+ print_lst (file, l, indent + 2);
+
+ fprintf (file, ")");