int ValidateCode1, ValidateCode2, ValidateCode3, ClientIDCode, ClientIDCode1, ClientIDCode2, ReadCode1, ReadCode2, ReadCode3, WriteCode1, WriteCode2, WriteCode3;

//////////////////////////////////////////////////////////
// Internal Kfunc Algorithm, takes two arguments,	//
// ValidateCode1,2 returns two ClientCodes		//
/////////////////////////////////////////////////////////
__asm{ 
push edi                         
push ecx
push eax
xor ecx, ecx
mov     dx, word ptr [ValidateCode2]
mov     cx, word ptr [ValidateCode1]
mov     ax, dx
xor     dh, 7Ch
shr     dx, 8
xor     al, 3Ah
movzx   edi, ax
movzx   eax, dx
shl     edi, 8
or      edi, eax
mov     ax, cx
and     edi, 0FFFFh
xor     ah, 49h
shr     ax, 8
movzx   eax, ax
shl     eax, 10h
or      edi, eax
movzx   eax, cx
xor     eax, 0FFFFFFD5h
shl     eax, 18h
or      edi, eax
mov ClientIDCode, edi
pop eax
pop ecx
pop edi
	}
ClientIDCode1 = (unsigned int) (ClientIDCode & 0XFFFF);
ClientIDCode2 = (unsigned int) (ClientIDCode >> 16);
ClientIDCode1 =(ClientIDCode1 & 0xFFFF);
ClientIDCode2 =(ClientIDCode2 & 0xFFFF);


//////////////////////////////////////////////////////////
// Internal Kfunc Algorithm, takes three arguments,	//
// ValidateCode12,3 returns three readcodes		//
/////////////////////////////////////////////////////////
__asm{
		push edi                         
		push ecx
		push eax
		xor ecx, ecx
		mov	ax, word ptr [ValidateCode1]
		mov	cx, ax
		movzx	eax, ax
		xor	ch, 3Ah
		xor	eax, 0FFFFFF9Ch
		shl	eax, 8
		shr	cx, 8
		movzx	ecx, cx
		or	ecx, eax
		and	ecx, 0FFFFh
		mov  	ReadCode1, ecx
		mov	ax, word ptr [ValidateCode2]
		mov	cx, ax
		xor	al, 26h
		movzx	eax, ax
		shl	eax, 8
		xor	ch, 18h
		shr	cx, 8
		movzx	ecx, cx
		or	ecx, eax
		and	ecx, 0FFFFh
		mov  	ReadCode2, ecx
		mov	ax, word ptr [ValidateCode3]
		mov	cx, ax
		xor	ah, 17h
		shr	ax, 8
		xor	cl, 2Ch
		movzx	ecx, cx
		movzx	eax, ax
		shl	ecx, 8
		or	ecx, eax
		and	ecx, 0FFFFh
		mov  	ReadCode3, ecx
		pop eax
		pop ecx
		pop edi
	}

//////////////////////////////////////////////////////////
// Internal Kfunc Write Algo takes three arguments,	//
// ValidateCode12,3 returns three writecodes		//
/////////////////////////////////////////////////////////

  __asm{
	  
		push edi                         
		push ecx
		push eax
		mov	ax, word ptr [ValidateCode2]
		movzx	ecx, ax
		xor	ecx, 0FFFFFFD2h
		xor	ah, 5Eh
		shl	ecx, 8
		shr	ax, 8
		movzx	edx, ax
		or	ecx, edx
		and	ecx, 0FFFFh
		mov 	WriteCode1, ecx
		mov	ax, word ptr [ValidateCode1]
		mov	cx, ax
		movzx	eax, ax
		shr	cx, 8
		xor	eax, 0FFFFFFB7h
		movzx	ecx, cx
		shl	eax, 8
		xor	ecx, 0FFFFFFC1h
		and	ecx, 0FFh
		or	ecx, eax
		and	ecx, 0FFFFh
		mov  	WriteCode2, ecx
		mov	ax, word ptr [ValidateCode3]
		mov	cx, ax
		movzx	eax, ax
		shr	cx, 8
		xor	eax, 0FFFFFF9Ah
		movzx	ecx, cx
		shl	eax, 8
		xor	ecx, 0FFFFFFC4h
		and	ecx, 0FFh
		or	ecx, eax
		and	ecx, 0FFFFh
		mov 	WriteCode3, ecx
		pop eax
		pop ecx
		pop edi
  }