//
// CAST_ecb_encrypt from 0x8cd124 to 0x8cd1d8 (180 bytes)
//
// 2 xrefs:
// > sub_8B68FC @ 0x8b6954
// > ??> @ 0x6afbc
//
// 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 int __fastcall CAST_ecb_encrypt(unsigned int *a1, _BYTE *a2, int a3, int a4)
{
unsigned int v4; // lr
char v6; // r3
char v7; // r6
char v8; // r5
unsigned int v9; // lr
unsigned int v10; // r12
unsigned int result; // r0
unsigned int v12; // r1
unsigned int v13; // [sp+0h] [bp-8h] BYREF
unsigned int v14; // [sp+4h] [bp-4h]
v4 = _byteswap_ulong(*a1);
v14 = _byteswap_ulong(a1[1]);
v13 = v4;
if ( a4 )
CAST_encrypt(&v13, a3);
else
CAST_decrypt(&v13, a3);
v6 = v14;
v7 = HIBYTE(v13);
v8 = BYTE2(v13);
v9 = v13 >> 8;
v10 = HIBYTE(v14);
result = HIWORD(v14);
v12 = v14 >> 8;
a2[3] = v13;
*a2 = v7;
a2[1] = v8;
a2[2] = v9;
a2[7] = v6;
a2[4] = v10;
a2[5] = result;
a2[6] = v12;
return result;
}