Old C Code Transmogrifier* *What is a transmogrifier?
In the C programming language, there are formations called digraphs and trigraphs that are two and three characters sequences that evaluate to less common characters. For example, you can use ??- if your keyboard doesn't have ~.
Given text, replace all instances of the following digraphs and trigraphs (left side) with the correct, shorter, golfed character (right side).
??=  #
??/  \
??'  ^
??(  [
??)  ]
??!  |
??&lt;  {
??&gt;  }
??-  ~
&lt;:   [
:&gt;   ]
&lt;%   {
%&gt;   }
%:   #

Source
Input
Input is ASCII text. Trailing newline allowed. Does not need to be valid C code.
Output
Output is the same text, with all instances of the above digraphs and trigraphs replaced with the shortened version, evaluated left to right. Trailing newline allowed. Does not need to be valid C code.
Test Cases
=&gt; separates input and output.
if (true ??!??! false) { =&gt; if (true || false) {

??-arr.indexOf(n) =&gt; ~arr.indexOf(n)

function f(??) { console.log('test??'); } =&gt; function f(] { console.log('test^); }

/* comment :&gt; :) *??/ =&gt; /* comment ] :) *\

%:What am I doing??!!??` =&gt; `#What am I doing|!??

??(??)??(??) &lt;:-- not a palindrome =&gt; [][] [-- not a palindrome

?????????? =&gt; ??????????

int f(int??(??) a) ??&lt; return a??(0??)??'a??(1??) + &quot;??/n&quot;; ??&gt; =&gt; int f(int[] a) { return a[0]^a[1] + &quot;\n&quot;; }

??&lt;:&gt;??&lt;% =&gt; {]{%

&lt;:&gt; =&gt; [&gt;

&lt;::&gt; =&gt; []

:&gt;&gt; =&gt; ]&gt;

#\^[]|{}~ =&gt; #\^[]|{}~

: &gt; =&gt; : &gt;

??=%: =&gt; ##
C, 206 205 bytes

(-1 thanks to ceilingcat)

The newlines are just here for readability.

c,d,q;f(char*s){for(char*S,*T,*t=s;c-63?q=0:q++,d=c&lt;&lt;8|*s,*s?
q&gt;1&amp;&amp;(T=index(S="=/'()!&lt;&gt;-",*s))?t-=2,*s="#\\^[]|{}~"[T-S]:
d&gt;*s&amp;&amp;(T=strstr(S="&gt;:&lt;&gt;%&lt;:%",&amp;d))&amp;&amp;(c="][ }{ # "[T-S])&amp;1?--t,*s=c:0:
0,*t++=c=*s++;);}


Modifies s in place. Tested with GCC and clang on Fedora Workstation, x86, in 32-bit and 64-bit mode.

C is not exactly the best language for golfing here.