according to www.linux-foundation.org/spec/refspecs/elf/x86_64-SysV-psABI.pdf the registers should be in the order rax, rbx, rcx, rdx, gcc puts them in rax, rdx, rcx, rbx. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32982
Turns out that www.linux-foundation.org/spec/refspecs/elf/x86_64-SysV-psABI.pdf is obsolete and reference should be made to: <http://www.x86-64.org/viewvc/trunk/x86-64-ABI/low-level-sys-info.tex?revision=214&view=markup>