Implement block sorting: all failed paths are grouped at the end of a function, whilst the mainly-linear successful paths are topologically sorted at the top.