this is mainly type differences in printf formats and casts, and signed/unsigned comparisons (the latter isn't x86 only issue).
The patch is attached. tested on xenial-i386 and xenial-amd64.
the main issue was that int64_t is defined as long on amd64 and longlong on x86. This means neither "%ld" nor "%lld" will work on all platforms.