let check_comparable ~with_alarms ev1 ev2 =
  try
    if not (Location_Bytes.is_included ev1 Location_Bytes.top_int)
      || not (Location_Bytes.is_included ev2 Location_Bytes.top_int)
    then begin
      (* First check if a non-zero integer is compared to an address *)
      let null_1, rest_1 = Location_Bytes.split Base.null ev1 in
      let null_2, rest_2 = Location_Bytes.split Base.null ev2 in
      if (not (Ival.is_included null_1 Ival.zero)) &&
        (not (Location_Bytes.equal rest_2 Location_Bytes.bottom ))
      then raise Not_found;
      if (not (Ival.is_included null_2 Ival.zero)) &&
        (not (Location_Bytes.equal rest_1 Location_Bytes.bottom ))
      then raise Not_found;

      (* If both addresses are valid, they can be compared.
         If one/both is not valid, the only way they can be
         compared is if they are offsets in a same array t.
         In this case, if t+n is the address of the last valid
         location in t, t+n+1 is allowed in the comparison *)

      let loc1 = make_loc (loc_bytes_to_loc_bits rest_1) Int_Base.one in
      if (not (Locations.is_valid loc1)) ||
        let loc2 = make_loc (loc_bytes_to_loc_bits rest_2) Int_Base.one in
        (not (Locations.is_valid loc2))
      then begin
        let base_1, _offs_1 = Location_Bytes.find_lonely_key rest_1 in
        let base_2, _offs_2 = Location_Bytes.find_lonely_key rest_2 in
        if Base.compare base_1 base_2 <> 0 then raise Not_found;
        (* TODO *)
      end
    end;
    ev1, ev2
  with Not_found ->
    CilE.warn_pointer_comparison with_alarms;
    ev1, ev2