let add_prop config acc kind (labels, id, p) =
  let get_p () =
    let txt = prop_txt id in
      try
        let p = NormAtLabels.preproc_annot labels p in
        let _ =
          Wp_parameters.debug ~level:3 "take (@[%s:@ %a@])@."
            txt !Ast_printer.d_predicate_named p
        in Some (id, p)
      with e -> NormAtLabels.catch_label_error e txt "annotation"None
  in
  let add_hyp l = match get_p () with None -> l | Some p -> p::l in
  let add_goal l =
    if goal_to_select config id
    then match get_p () with None -> l
      | Some p -> ( has_prop_goal := true; p::l )
        else l
  in
  let add_both l =
    match get_p () with None -> l
      | Some p ->
          let goal = goal_to_select config id in
            if goal then has_prop_goal := true;
            (goal, p)::l
  in
    match kind with
      | Ahyp -> { acc with p_hyp = add_hyp acc.p_hyp }
      | Agoal -> { acc with p_goal = add_goal acc.p_goal }
      | Aboth -> { acc with p_both = add_both acc.p_both }
      | Acut -> { acc with p_cut = add_both acc.p_cut }
      | Ainv -> { acc with p_inv = add_both acc.p_inv }