//
// RC2_decrypt from 0x82a59c to 0x82a6fc (352 bytes)
//
// 4 xrefs:
// > RC2_cbc_encrypt @ 0x82a97c
// > RC2_cbc_encrypt @ 0x82aa7c
// > RC2_ecb_encrypt @ 0x82ad54
// > ??> @ 0x660dc
//
// 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
//
int *__fastcall RC2_decrypt(int *result, int a2)
{
unsigned int v2; // r3
unsigned int v3; // r4
unsigned int v4; // r5
unsigned int v5; // r12
int v6; // r6
int v7; // r9
int v8; // r8
int v9; // r7
int v10; // t1
int v11; // r2
int v12; // lr
int v13; // lr
v2 = (unsigned __int16)*result;
v3 = HIWORD(*result);
v4 = (unsigned __int16)result[1];
v5 = HIWORD(result[1]);
v6 = a2 + 252;
v7 = *(_DWORD *)(a2 + 252);
v8 = 3;
v9 = 5;
while ( 1 )
{
v5 = (unsigned __int16)((((_WORD)v5 << 11) | (v5 >> 5)) - (v2 & ~(_WORD)v4) - (v4 & v3) - v7);
v11 = (unsigned __int16)(((_WORD)v4 << 13) | (v4 >> 3)) - (v5 & ~v3) - (v3 & v2) - *(_DWORD *)(v6 - 4);
v4 = (unsigned __int16)v11;
v12 = (unsigned __int16)(((_WORD)v3 << 14) | (v3 >> 2))
- ((unsigned __int16)v11 & ~v2)
- (v5 & v2)
- *(_DWORD *)(v6 - 8);
v3 = (unsigned __int16)((((_WORD)v3 << 14) | (v3 >> 2)) - (v11 & ~(_WORD)v2) - (v5 & v2) - *(_WORD *)(v6 - 8));
--v9;
v13 = v12 & 0x3F;
v2 = (unsigned __int16)((((_WORD)v2 << 15) | (v2 >> 1)) - (v3 & ~(_WORD)v5) - (v11 & v5) - *(_WORD *)(v6 - 12));
if ( v9 )
goto LABEL_5;
if ( !--v8 )
break;
v5 -= *(_DWORD *)(a2 + 4 * (v11 & 0x3F));
v4 = (unsigned __int16)(v11 - *(_DWORD *)(a2 + 4 * v13));
v3 = (unsigned __int16)(v3 - *(_DWORD *)(a2 + 4 * (v2 & 0x3F)));
v2 = (unsigned __int16)(v2 - *(_DWORD *)(a2 + 4 * (v5 & 0x3F)));
v5 = (unsigned __int16)v5;
if ( v8 == 2 )
v9 = 6;
else
v9 = 5;
LABEL_5:
v10 = *(_DWORD *)(v6 - 16);
v6 -= 16;
LOWORD(v7) = v10;
}
*result = (unsigned __int16)v2 | (v3 << 16);
result[1] = (unsigned __int16)v11 | (v5 << 16);
return result;
}