lib: Improve performance of memcpy and memmove