complete basic block generation function