let find_code_annot_nodes pdg ~before stmt annot =
  M.debug 1 "[pdg:annotation] CodeAnnot-%d %s stmt %d : %a @."
      annot.annot_id
      (if before then "before" else "after") stmt.sid
      !Ast_printer.d_code_annotation annot;
  if Db.Value.is_accessible (Cil_types.Kstmt stmt) then
    try
      begin
        let kf = M.get_pdg_kf pdg in
        let info, pragmas =
          !Db.Properties.Interp.To_zone.from_stmt_annot annot ~before (stmt, kf)
        in
        let decl_nodes, data_dpds = zone_info_nodes pdg info in
        let stmt_key = Key.stmt_key stmt in
        let stmt_node = match stmt_key with 
          | Key.Stmt _ -> !Db.Pdg.find_stmt_node pdg stmt 
          | Key.CallStmt _ -> !Db.Pdg.find_call_ctrl_node pdg stmt
          | _ -> assert false
        in 
        let ctrl_dpds = !Db.Pdg.direct_ctrl_dpds pdg stmt_node in
        let add_stmt_nodes s acc =
          (!Db.Pdg.find_stmt_and_blocks_nodes pdg s) @ acc in
        (* can safely ignore pragmas.ctrl
        * because we already have the ctrl dpds from the stmt node. *)

        let stmt_pragmas = pragmas.Db.Properties.Interp.To_zone.stmt in
        let ctrl_dpds =
          Cilutil.StmtSet.fold add_stmt_nodes stmt_pragmas ctrl_dpds in
          if M.has_debug 2 then
            begin
              let p fmt (n,z) = match z with
                | None -> PdgTypes.Node.pretty fmt n
                | Some z -> Format.fprintf fmt "%a(%a)"
                              PdgTypes.Node.pretty n Locations.Zone.pretty z
              in
              let pl fmt l =
                List.iter (fun n -> Format.fprintf fmt " %a" p n) l
              in
              let data_nodes, data_undef = data_dpds in
                Pdg_parameters.result " ctrl nodes = %a"
                  PdgTypes.Node.pretty_list ctrl_dpds;
                Pdg_parameters.result " decl nodes = %a"
                   PdgTypes.Node.pretty_list decl_nodes;
                Pdg_parameters.result " data nodes = %a"
                  pl data_nodes;
                match data_undef with None -> ()
                  | Some data_undef ->
                      Pdg_parameters.result " data undef = %a"
                        Locations.Zone.pretty data_undef;
            end;
          ctrl_dpds, decl_nodes, data_dpds
      end
    with Extlib.NotYetImplemented msg ->
      raise (Extlib.NotYetImplemented 
               ("[pdg:find_code_annot_nodes] to_zone : "^msg))
  else
    begin
      M.debug 2 "[pdg:annotation] CodeAnnot-%d : unreachable stmt ! @."
        annot.annot_id;
      raise PdgIndex.NotFound (* unreachable statement *)
    end