Revert usage of valgrind replacements for write/memcpy/memset

To use these replacements, it is necessary to link with valgrind
static libraries which are not properly compiled with -fPIC. Because of
this, it is not possible to build a shared library on x86-64 linked to
these static libraries.

The fix is to simply not link to any Valgrind library and use regular C
library functions (except for write() which cause recursion loops and
therefore we use syscall() to do the syscall directly).