let rec array_reference x n calls =
  let s = "[array_reference arg]" in 
  match calls with 
    | [] ->  
        debug "%s %a: arity %d ok" s pp_var_type x n;
        oracle "%s %a ArgAref"  s pp_var_type x;
        ArgAReference.replace x (n,[])
    | (k,(b,Prop))::m -> 
        if k <= n then 
          (decr_addr_taken_bool x b; array_reference x n m)
        else remove_array_reference_arg x 
    | (k,(b,p))::m ->
        if k > n then ArgAReference.remove x 
        else
          (
            if ByPReference.mem p then 
              begin
                try (match ByPReference.find p with 
                       | (i,[]) ->
                           debug "%s %a is byPref resolved" s pp_var_type p;
                           if k <= i then 
                             ( debug "%s arity OK" s; decr_addr_taken_bool x b;
                               array_reference x n m) 
                           else 
                             (debug "%s arity KO" s;
                              remove_array_reference_arg x) 
                       | (i,lp) -> (* can't happen *) 
                           debug "%s %a is byPref NOT resolved"s pp_var_type p;
                           if k <= i then 
                             ( debug "%s arity OK"s ;by_ptr_reference p i lp; 
                               debug "%s resolution of %a" s pp_var_type p;
                               array_reference x n ((k,(b,p))::m))
                           else 
                             (debug "%s arity KO" s; 
                              remove_ptr_reference_arg x )
                    )
                with Not_found -> remove_array_reference_arg x
              end
            else 
              begin
                try (match ByAReference.find p with 
                       | (_,[]) -> 
                           decr_addr_taken_bool x b; array_reference x n m 
                       | (i,lp) -> (* can't happen *)
                           by_array_reference p i lp; 
                           array_reference x n ((k,(b,p))::m)
                    )
                with Not_found -> (* can't happen *)
                  debug "%s %a NOT ByARef" s pp_var_type p;
                  let i = brackets_and_stars_var_type_typ p in  
                  add_array_reference_param p i;
                  if not (ByAReference.mem p) || ByValue.mem p
                  then remove_array_reference_arg x
                  else array_reference x n ((k,(b,p))::m)
              end
          )