//
// RC2_decrypt from 0xdcfd00 to 0xdcfe68 (360 bytes)
//
// 4 xrefs:
// > RC2_cbc_encrypt @ 0xdd00b4
// > RC2_cbc_encrypt @ 0xdd0190
// > RC2_ecb_encrypt @ 0xdd0478
// > ??> @ 0x69c48
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
unsigned __int64 *__fastcall RC2_decrypt(unsigned __int64 *result, __int64 a2)
{
int v2; // w14
int v3; // w15
_DWORD *v4; // x13
__int64 v5; // x2
int v6; // w16
unsigned int v7; // w6
unsigned __int64 v8; // x11
unsigned __int64 v9; // x9
int v10; // w8
int v11; // w17
unsigned __int16 v12; // w3
unsigned __int16 v13; // w4
int v14; // w8
v2 = 5;
v3 = *(_DWORD *)(a2 + 252);
v4 = (_DWORD *)(a2 + 252);
LODWORD(v5) = (unsigned __int16)result[1];
v6 = 3;
v7 = (unsigned __int16)*result;
v8 = *result >> 16;
v9 = result[1] >> 16;
while ( 1 )
{
LODWORD(v9) = (unsigned __int16)((((_WORD)v9 << 11) | ((unsigned int)v9 >> 5)) - (v7 & ~(_WORD)v5) - (v5 & v8) - v3);
v10 = (unsigned __int16)(((_WORD)v5 << 13) | ((unsigned int)v5 >> 3)) - (v9 & ~(_DWORD)v8) - (v8 & v7) - *(v4 - 1);
v5 = (unsigned __int16)((((_WORD)v5 << 13) | ((unsigned int)v5 >> 3))
- (v9 & ~(_WORD)v8)
- (v8 & v7)
- *((_WORD *)v4 - 2));
v11 = *(v4 - 2);
v4 -= 4;
v12 = (((_WORD)v8 << 14) | ((unsigned int)v8 >> 2)) - (v5 & ~(_WORD)v7) - (v9 & v7) - v11;
LODWORD(v8) = v12;
--v2;
v13 = (((_WORD)v7 << 15) | (v7 >> 1)) - (v12 & ~(_WORD)v9) - (v10 & v9) - v4[1];
v7 = v13;
if ( v2 )
goto LABEL_8;
if ( !--v6 )
break;
v14 = *(_DWORD *)(a2 + 4LL * (v10 & 0x3F));
if ( v6 == 2 )
v2 = 6;
else
v2 = 5;
LODWORD(v9) = (unsigned __int16)(v9 - v14);
LODWORD(v5) = (unsigned __int16)(v5 - *(_DWORD *)(a2 + 4LL * (v12 & 0x3F)));
LODWORD(v8) = (unsigned __int16)(v8 - *(_WORD *)(a2 + 4LL * (v13 & 0x3F)));
v7 = (unsigned __int16)(v13 - *(_DWORD *)(a2 + 4 * (v9 & 0x3F)));
LABEL_8:
v3 = *v4;
}
*result = ((unsigned __int64)v12 << 16) | v13;
result[1] = ((unsigned __int64)(unsigned int)v9 << 16) | v5;
return result;
}