        (map read-string)
        ))
 
-(->> "tmp/location-dump_non-atoms_2017-06-02.txt_100000"
+(->> "tmp/location-dump_non-atoms_2017-06-05_1.txt"
      read-lines
+     (take 1000000)
      (def location-dump-data)
      time
      )
 
 (defn process-dump-file
-  [[filename atoms-lst]]
-  (let [atoms (map (fn [[atom start-line end-line depth]]
-                     {:atom atom :start-line start-line :end-line end-line :depth depth}) atoms-lst)
-        comments (filter #(= :comment (:atom %)) atoms)]
+  [[filename nodes-lst]]
+  (let [nodes (map (fn [[type start-line end-line depth]]
+                     {:type type :start-line start-line :end-line end-line :depth depth}) nodes-lst)
+        {comments true non-comments false} (group-by #(= :comment (:type %)) nodes)
+        all-line-items (->> nodes (filter :start-line) (group-by :start-line)) ; :start-line -> node
+        ]
     (for [comment comments]
-      (let [next-line (->> atoms (map :start-line) (filter #(<= (:end-line comment) %)) min-of) ; next non-blank line after comment
-            next-line-items (filter #(= next-line (:start-line %)) atoms)
-            next-line-counts (frequencies next-line-items)]
-        (pprn [filename comment next-line next-line-counts])
-        next-line-counts
+      (let [endl (:end-line comment)
+            startl (:start-line comment)
+            max-n 10
+            line-items (->> all-line-items
+                            (filter (fn [[line-num items]]
+                                      (<= endl line-num (+ endl max-n))))
+                            (into {})
+                            ((fn [m] (update m startl (partial remove #{comment})))) ; remove this comment from consideration
+                            ) ; limit the lines we look at to ones near-ish this comment
+            type-count (fn [nodes] (->> nodes (map :type) frequencies))
+            ;inline? (boolean (some #(= (:start-line %) (:start-line comment)) non-comments))
+            same-line-items (line-items startl)
+            next-line (->> line-items keys (filter #(< endl %)) min-of); next non-blank line after comment
+            next-line-items (line-items next-line)
+            next-N-lines-items (fn [n] (->> line-items
+                                            (filter (fn [[line-num items]]
+                                                      (>= (+ n endl) line-num)))
+                                            (mapcat last)))
+            ]
+        {:file filename
+         :comment comment
+         :same-line (type-count same-line-items)
+         :next-line (type-count next-line-items)
+         :next-line-n next-line
+         :next-5-lines (type-count (next-N-lines-items 5))
+         :next-10-lines (type-count (next-N-lines-items 10))
+         }
       ))))
 
-'(->> location-dump-data
-     (take 50)
+(->> location-dump-data
      (partition-by first)
      (map (fn [lst] [(first (first lst)) (map rest lst)]))
+     (drop 240)(take 3)
      (map process-dump-file)
      pprint
      )
 
-(->> "/Users/dgopstein/opt/src/gcc/libatomic/gload.c"
+(->> (str gcc-path "/libstdc++-v3/include/ext/mt_allocator.h")
      parse-file
-     all-preprocessor
-     (map loc)
-     (map prn)
+     flatten-tree
+     (map start-line)
      )

     (map prn)
     (take 50000)
     dorun
     (log-to "location-dump_non-atoms_2017-06-05.txt")
     time
     )




;(->> "/Users/dgopstein/opt/src/gcc/contrib/paranoia.cc" location-dump-atoms-and-non-atoms (map prn))
(->> "/Users/dgopstein/opt/src/gcc/libatomic/gload.c" location-dump-atoms-and-non-atoms (map prn))

(defn now [] (java.util.Date.))
'(->> (now) println)

(->> (str gcc-path "/libatomic")
     (pmap-dir-files location-dump-atoms-and-non-atoms)
     (mapcat (partial map #(update % :node write-node)))
     (map #(merge %1 (if (:path %1) {:depth (count (:path %1))} {})))
