         {
             [ visited get adjoin ]
             [ active get adjoin ]
-            [ dup successors>> [ visit-edge ] with each ]
+            [ dup successors>> active get '[ _ visit-edge ] with each ]
             [ active get delete ]
         } cleave
     ] if ;

    ] if ;

: process-loop-ends ( loop -- )
    [ ends>> keys <dlist> [ push-all-front ] [ work-list set ] [ ] tri ] keep
    '[ _ process-loop-block ] slurp-deque ;

: process-loop-headers ( -- )

SYMBOLS: visited active ;

: record-back-edge ( from to -- )
    lookup-header ends>> adjoin ;

DEFER: find-loop-headers

: visit-edge ( from to active -- )
    dupd in?
    [ record-back-edge ]
    [ nip find-loop-headers ]
    if ;
