let translated_name linfo =
(*
  Format.eprintf "Jessie.interp: linfo = %s(%a)(%d)@."
    linfo.l_name
    (fprintfList ~sep:",@ " d_logic_type)
    (List.map (fun v -> v.lv_type) linfo.l_profile)
    (Obj.magic linfo);
*)

  try
    let n = Hashtbl.find translated_names_table linfo.l_var_info.lv_id in
(*
    Format.eprintf "Jessie.interp: translated(%s) = %s" linfo.l_var_info.lv_name n;
*)

    n
  with Not_found ->
    let name =
      match linfo.l_var_info.lv_name with
        | "\\abs" ->
            begin
              match linfo.l_type with
                | Some Lreal -> "\\real_abs"
                | Some Linteger -> "\\integer_abs"
                | _ -> assert false
            end
        | "\\exact" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\double_exact"
                | Ctype x when x == floatType -> "\\float_exact"
                | _ -> assert false
            end
        | "\\model" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\double_model"
                | Ctype x when x == floatType -> "\\float_model"
                | _ -> assert false
            end
        | "\\round_error" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\double_round_error"
                | Ctype x when x == floatType -> "\\float_round_error"
                | _ -> assert false
            end
        | "\\total_error" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\double_total_error"
                | Ctype x when x == floatType -> "\\float_total_error"
                | _ -> assert false
            end
        | "\\relative_error" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\double_relative_error"
                | Ctype x when x == floatType -> "\\float_relative_error"
                | _ -> assert false
            end
        | "\\pow" ->
            begin
              match linfo.l_type with
                | Some Lreal -> "\\real_pow"
                | _ -> assert false
            end
        | "\\sqrt" ->
            begin
              match linfo.l_type with
                | Some Lreal -> "\\real_sqrt"
                | _ -> assert false
            end
        | "\\sign" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\sign_double"
                | Ctype x when x == floatType -> "\\sign_float"
                | _ -> assert false
            end
        | "\\is_finite" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\is_finite_double"
                | Ctype x when x == floatType -> "\\is_finite_float"
                | _ -> assert false
            end
        | "\\is_infinite" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\is_infinite_double"
                | Ctype x when x == floatType -> "\\is_infinite_float"
                | _ -> assert false
            end
        | "\\is_NaN" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\is_NaN_double"
                | Ctype x when x == floatType -> "\\is_NaN_float"
                | _ -> assert false
            end
        | "\\is_minus_infinity" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\is_minus_infinity_double"
                | Ctype x when x == floatType -> "\\is_minus_infinity_float"
                | _ -> assert false
            end
        | "\\is_plus_infinity" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\is_plus_infinity_double"
                | Ctype x when x == floatType -> "\\is_plus_infinity_float"
                | _ -> assert false
            end
        | "\\le_float" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\le_double"
                | Ctype x when x == floatType -> "\\le_float"
                | _ -> assert false
            end
        | "\\lt_float" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\lt_double"
                | Ctype x when x == floatType -> "\\lt_float"
                | _ -> assert false
            end
        | "\\ge_float" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\ge_double"
                | Ctype x when x == floatType -> "\\ge_float"
                | _ -> assert false
            end
        | "\\gt_float" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\gt_double"
                | Ctype x when x == floatType -> "\\gt_float"
                | _ -> assert false
            end
        | "\\eq_float" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\eq_double"
                | Ctype x when x == floatType -> "\\eq_float"
                | _ -> assert false
            end
        | "\\ne_float" ->
            begin
              match (List.hd linfo.l_profile).lv_type with
                | Ctype x when x == doubleType -> "\\ne_double"
                | Ctype x when x == floatType -> "\\ne_float"
                | _ -> assert false
            end
        | s ->
            try
(*
              Format.eprintf "Jessie.interp: Checking if %s overloaded" s;
*)

              let x = Hashtbl.find Rewrite.logic_names_overloading s in
              if !x then
                let ns = name_with_profile s linfo.l_profile in
(*
                Format.eprintf "yes! -> %s@." ns;
*)

                ns
              else
                begin
(*
                  Format.eprintf "no@.";
*)

                  s
                end
            with Not_found ->
              (* this happens with Jessie-generated predicates like valid_* etc *)
(*
              Format.eprintf "Jessie.Interp: warning, logic id `%s' not present in overloading table@." s;
*)

              s
    in
(*
    Format.eprintf "Jessie.interp: translated(%s) = %s" linfo.l_var_info.lv_name name;
*)

    Hashtbl.add translated_names_table linfo.l_var_info.lv_id name;
    name