code: private static void fixupList(CFG cfg, List<BasicBlock> list) {
          int n = list.size();
          for (int i = 0; i < n - 1; i++) {
              BasicBlock current = list.get(i);
  
              if (current.isExitBB()) { // exit not last
                  current.addInstr(new Return(Undefined.UNDEFINED));
                  continue;
              }
  
              Instruction lastInstr = current.getLastInstr();
              if (lastInstr instanceof Jump) { // if jumping to next BB then remove it
                  tryAndRemoveUnneededJump(list.get(i + 1), cfg, lastInstr, current);
              } else {
                  addJumpIfNextNotDestination(cfg, list.get(i + 1), lastInstr, current);
              }
          }
  
          BasicBlock current = list.get(n - 1);
          if (!current.isExitBB()) {
              Instruction lastInstr = current.getLastInstr();
              // Last instruction of the last basic block in the linearized list can NEVER
              // be a branch instruction because this basic block would then have a fallthrough
              // which would have to be present after it.
              assert (!(lastInstr instanceof Branch));
  
              if ((lastInstr == null) || !lastInstr.transfersControl()) {
                  // We are guaranteed to have at least one non-exception edge because
                  // the exit BB post-dominates all BBs in the CFG even when exception
                  // edges are removed.
                  //
                  // Verify that we have exactly one non-exception target
                  Iterator<BasicBlock> iter = cfg.getOutgoingDestinationsNotOfType(current, EdgeType.EXCEPTION).iterator();
                  BasicBlock target = iter.next();
                  assert (target != null && !iter.hasNext());
  
                  // System.out.println("BB " + curr.getID() + " is the last bb in the layout! Adding a jump to " + tgt._label);
                  current.addInstr(new Jump(target.getLabel()));
              }
          }
      }
docs: Process (fixup) list of instruction and add or remove jumps.