Sorry, I thought it was obvious.
C++, Kernel32:
LONG __cdecl InterlockedCompareExchange(
_Inout_ LONG volatile *Destination,
_In_ LONG Exchange,
_In_ LONG Comparand
);
C++, Kernel64:
LONGLONG __cdecl InterlockedCompareExchange64(
_Inout_ LONGLONG volatile *Destination,
_In_ LONGLONG Exchange,
_In_ LONGLONG Comparand
);
Kernel32 disassembled:
762FC37C 8B4C24 04 mov ecx, [esp+4]
762FC380 8B5424 08 mov edx, [esp+8]
762FC384 8B4424 0C mov eax, [esp+0C]
762FC388 F0:0FB111 lock cmpxchg [ecx], edx
Assembler logic:
if eax=Dest
mov Dest, edx
else
mov eax, Dest
endif
Assembler, direct:
mov Dest11, 11
mov edx, 22
mov eax, 33
lock cmpxchg Dest11, edx
Assembler, via Kernel32:
mov Dest11, 11
invoke InterlockedCompareExchange, addr Dest11, 22, 33
Right now I can't check how the 64-bit version is implemented, but you can google for CMPXCHG8B CMPXCHGQ (they look similar but are not identical).