ONF compilation algorithm, based on POPL'14 paper