public void reDisassembleAllInstructions(TaskMonitor monitor)
			throws IOException, CancelledException {

		redisassemblyMode = true;
		try {
			if (lock.getOwner() != Thread.currentThread()) {
				throw new IllegalStateException("Must be invoked by lock owner");
			}

			Disassembler.clearUnimplementedPcodeWarnings(program, null, monitor);
			Disassembler.clearBadInstructionErrors(program, null, monitor);

			int maxCount = instAdapter.getRecordCount();
			monitor.initialize(maxCount);
			monitor.setMessage("Preparing for Re-Disassembly...");

			redisassmblyFlags = new HashMap<>();

			HashMap<Integer, Integer> protoLengthCache = new HashMap<>();
			AddressSet codeSet = new AddressSet();

			Address minAddr = null;
			Address maxAddr = null;

			int count = 0;
			RecordIterator recIter = instAdapter.getRecords();
			while (recIter.hasNext()) {
				DBRecord rec = recIter.next();

				Address addr = addrMap.decodeAddress(rec.getKey());
				if (minAddr == null) {
					minAddr = addr;
				}
				else {
					Address nextAddr = null;
					try {
						nextAddr = maxAddr.add(1);
					}
					catch (AddressOutOfBoundsException e) {
						// nextAddr will be null
					}
					if (nextAddr == null || !addr.equals(nextAddr)) {
						codeSet.addRange(minAddr, maxAddr);
						minAddr = addr;
					}
				}

				int protoId = rec.getIntValue(InstDBAdapter.PROTO_ID_COL);
				Integer len = protoLengthCache.get(protoId);
				if (len == null) {
					len = protoMgr.getOriginalPrototypeLength(protoId);
					if (len <= 0) {
						len = 1; // just in-case
					}
					protoLengthCache.put(protoId, len);
				}

				maxAddr = addr;
				try {
					maxAddr = addr.add(len - 1);
				}
				catch (AddressOutOfBoundsException e) {
					// maxAddr will equals addr
				}

				byte flags = rec.getByteValue(InstDBAdapter.FLAGS_COL);
				if (flags != 0) {
					redisassmblyFlags.put(rec.getKey(), flags);
				}

				if ((++count % 1000) == 0) {
					monitor.checkCancelled();
					monitor.setProgress(count);
				}
			}

			if (minAddr != null) {
				codeSet.addRange(minAddr, maxAddr);
			}

			monitor.setMessage("Clearing Old Instructions...");
			monitor.initialize(0);

			instAdapter.deleteAll();
			cache.invalidate();
			protoMgr.setLanguage(program.getLanguage());

			monitor.setMessage("Performing Re-Disassembly...");
			Disassembler d =
				Disassembler.getDisassembler(program, monitor, new DisassemblerMessageListener() {
					@Override
					public void disassembleMessageReported(String msg) {
						Msg.warn(this, msg);
					}
				});
			d.disassemble(codeSet, codeSet, true);

		}
		finally {
			redisassemblyMode = false;
			redisassmblyFlags = null;
		}

	}
Complete language transformation of all instructions.  All existing prototypes will be 
discarded and all instructions re-disassembled following flow and adjusting context as 
needed. Instructions which fail to re-disassemble will be marked - since only one byte will 
be skipped, such bad instruction disassembly may cause subsequent errors due to possible 
instruction shift.
<P>
This method is only intended for use by the ProgramDB setLanguage method which must ensure 
that the context has been properly initialized.
@param monitor task monitor
@throws IOException if IO error occurs
@throws CancelledException if the operation is canceled.
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/code/CodeManager.java