improve 2bf.c: remove code duplication