lib: Improve the performance of memcpy and memmove