 class="keyword">end</span>
FI{N+2} = [N];   <span class="comment">% fan-in of the primary output is the last inverter in the chain</span>

<span class="comment">% fan-out cell array</span>
<span class="comment">% (will be computed from the fan-in cell array, no need to modify)</span>
FO = cell(M,1);
<span class="keyword">for</span> gate = [1:N primary_outputs]
  preds = FI{gate};
  <span class="keyword">for</span> k = 1:length(preds)
    FO{preds(k)}(end+1) = gate;
  <span class="keyword">end</span>
<span 