private Map<Integer, BasicBlock> createBasicBlocks(
    short[] startblock,
    InstructionSequence instrseq) {
    Map<Integer, BasicBlock> mapInstrBlocks = new HashMap<>();

    this.blocks = new VBStyleCollection<>();

    InstructionSequence currseq = null;
    List<Integer> lstOffs = null;

    int len = startblock.length;
    short counter = 0;
    int blockoffset = 0;

    BasicBlock currentBlock = null;
    for (int i = 0; i < len; i++) {

      if (startblock[i] == 1) {
        currentBlock = new BasicBlock(++counter);

        currseq = currentBlock.getSeq();
        lstOffs = currentBlock.getInstrOldOffsets();

        // index: $i, key: $i+1, value BasicBlock(id = $i + 1)
        this.blocks.addWithKey(currentBlock, currentBlock.id);

        blockoffset = instrseq.getOffset(i);
      }

      startblock[i] = counter;
      mapInstrBlocks.put(i, currentBlock);

      // can't throw npe cause startblock[0] == 1 is always true
      assert currseq != null && lstOffs != null;
      currseq.addInstruction(instrseq.getInstr(i), instrseq.getOffset(i) - blockoffset);
      lstOffs.add(instrseq.getOffset(i));
    }

    this.first = this.blocks.get(0);
    this.last = new BasicBlock(++counter);
    mapInstrBlocks.put(len, this.last);

    last_id = counter;

    return mapInstrBlocks;
  }
@param startblock     inout, starts as a flag of which instruction is a
                      new block, returns as the cumulative sum list
                      representing the instruction index -> block id mapping
src/org/jetbrains/java/decompiler/code/cfg/ControlFlowGraph.java