In low-level systems code such as firmware used by Meta hardware platforms, copying bytes within the same buffer must be safe even when the source and destination ranges overlap. Implement a function that performs memmove-style copying on a byte array.
Given a list of integers buffer representing bytes, and integers dst, src, and count, copy count bytes starting at index src to index dst in place. Return the modified buffer.
Unlike a naive forward copy, your implementation must work correctly when the source and destination ranges overlap.
buffer: List[int], dst: int, src: int, count: intcount bytes from src to dstbuffer is in the range 0..255Example 1
buffer = [1, 2, 3, 4, 5, 6], dst = 2, src = 0, count = 4[1, 2, 1, 2, 3, 4]Example 2
buffer = [10, 20, 30, 40, 50], dst = 0, src = 2, count = 3[30, 40, 50, 40, 50]0 <= len(buffer) <= 10^50 <= count <= len(buffer)0 <= src, dst <= len(buffer)src + count <= len(buffer)dst + count <= len(buffer)