generalize deinterleave_first implementation to all integers