//
// sub_8B8BE8 from 0x8b8be8 to 0x8b8d9c (436 bytes)
//
// 3 xrefs:
// > MDC2_Update @ 0x8b8e30
// > MDC2_Update @ 0x8b8e74
// > MDC2_Final @ 0x8b8efc
//
// 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 sub_8B8BE8(int result, int a2, unsigned int a3)
{
char v4; // r1
int v5; // r6
unsigned __int8 *v6; // r9
unsigned __int8 *v7; // r8
int v8; // r11
unsigned int v9; // r10
char v10; // r2
int v11; // r5
int v12; // r4
__int16 v13; // r12^2
int v14; // lr
int v15; // r1
int v16; // r3
int v17; // r1
int v18; // r3
int v20; // [sp+10h] [bp-B8h] BYREF
int v21; // [sp+14h] [bp-B4h]
int v22; // [sp+18h] [bp-B0h] BYREF
int v23; // [sp+1Ch] [bp-ACh]
int v24[42]; // [sp+20h] [bp-A8h] BYREF
if ( a3 )
{
v4 = *(_BYTE *)(result + 20);
v5 = result;
v6 = (unsigned __int8 *)(result + 12);
v7 = (unsigned __int8 *)(result + 20);
v8 = a2 + 8;
v9 = 0;
LOBYTE(result) = *(_BYTE *)(result + 12);
v10 = v4;
do
{
v11 = (*(unsigned __int8 *)(v8 - 6) << 16)
| (*(unsigned __int8 *)(v8 - 7) << 8)
| *(unsigned __int8 *)(v8 - 8)
| (*(unsigned __int8 *)(v8 - 5) << 24);
v12 = (*(unsigned __int8 *)(v8 - 2) << 16)
| (*(unsigned __int8 *)(v8 - 3) << 8)
| *(unsigned __int8 *)(v8 - 4)
| (*(unsigned __int8 *)(v8 - 1) << 24);
*(_BYTE *)(v5 + 20) = v10 & 0x9F | 0x20;
*(_BYTE *)(v5 + 12) = result & 0x9F | 0x40;
v22 = v11;
v20 = v11;
v23 = v12;
v21 = v12;
DES_set_odd_parity(v6);
DES_set_key_unchecked(v6, (int)v24);
DES_encrypt1(&v20, v24, 1);
DES_set_odd_parity(v7);
DES_set_key_unchecked(v7, (int)v24);
DES_encrypt1(&v22, v24, 1);
v13 = HIWORD(v11) ^ HIWORD(v20);
v9 += 8;
v14 = v22 ^ v11;
result = (unsigned __int8)(v11 ^ v20);
v15 = v23;
*(_BYTE *)(v5 + 13) = (unsigned __int16)(v11 ^ v20) >> 8;
v16 = v21;
*(_WORD *)(v5 + 14) = v13;
v17 = v15 ^ v12;
*(_BYTE *)(v5 + 21) = BYTE1(v14);
v10 = v14;
v18 = v16 ^ v12;
*(_BYTE *)(v5 + 22) = BYTE2(v14);
*(_BYTE *)(v5 + 23) = HIBYTE(v14);
*(_BYTE *)(v5 + 16) = v17;
*(_BYTE *)(v5 + 24) = v18;
*(_BYTE *)(v5 + 17) = BYTE1(v17);
*(_BYTE *)(v5 + 18) = BYTE2(v17);
v8 += 8;
*(_BYTE *)(v5 + 12) = result;
*(_BYTE *)(v5 + 20) = v14;
*(_BYTE *)(v5 + 19) = HIBYTE(v17);
*(_BYTE *)(v5 + 25) = BYTE1(v18);
*(_BYTE *)(v5 + 26) = BYTE2(v18);
*(_BYTE *)(v5 + 27) = HIBYTE(v18);
}
while ( a3 > v9 );
}
return result;
}