private void performMergeInstruction(Instruction instruction, boolean copyBytes)
			throws CodeUnitInsertionException, MemoryAccessException {
		Address minAddress = instruction.getMinAddress();
		Address maxAddress;
		if (instruction.isLengthOverridden()) {
			maxAddress = minAddress.add(instruction.getParsedLength() - 1);
		}
		else {
			maxAddress = instruction.getMaxAddress();
		}
		Program fromPgm = instruction.getProgram();
		// Code unit should already be cleared where this instruction needs to go.
		Listing resultListing = resultPgm.getListing();

		// Copy the bytes if requested.
		if (copyBytes && !resultUninitSet.intersects(minAddress, maxAddress)) {
			ProgramMemoryUtil.copyBytesInRanges(resultPgm, fromPgm, minAddress, maxAddress);
		}

		// avoid forcing length of new instruction if old instruction length was not overriden
		int lengthOverride = instruction.isLengthOverridden() ? instruction.getLength() : 0;

		Instruction inst = resultListing.createInstruction(minAddress, instruction.getPrototype(),
			new DumbMemBufferImpl(resultPgm.getMemory(), minAddress),
			new ProgramProcessorContext(resultPgm.getProgramContext(), minAddress), lengthOverride);

		// Set the fallthrough override if necessary.
		if (instruction.isFallThroughOverridden()) {
			// override the fallthrough the same as it is in the one being merged.
			inst.setFallThrough(instruction.getFallThrough());
		}

		// Set the flow override if necessary.
		if (instruction.getFlowOverride() != FlowOverride.NONE) {
			inst.setFlowOverride(instruction.getFlowOverride());
		}
	}
<CODE>performMergeInstruction</CODE> merges the indicated instruction
into the result program. The bytes are also moved from the program
if they differ. The flow override and fallthrough override will be set
the same in the result program's instruction as they are in the instruction
that is passed to this method.

@param instruction the instruction to be merged
@param copyBytes whether or not bytes should be copied if turned into
an instruction.
@throws CodeUnitInsertionException if the instruction can't be created
in the merge program.

@throws MemoryAccessException if bytes can't be copied.
Ghidra/Features/Base/src/main/java/ghidra/app/merge/listing/CodeUnitMerger.java