//
// sub_10059C368 from 0x10059c368 to 0x10059c498 (304 bytes)
//
// 6 xrefs:
// > sub_10059BC20 @ 0x10059bc90
// > sub_10059BEC8 @ 0x10059bfb0
// > sub_10059BEC8 @ 0x10059c1a0
// > sub_10059C5E0 @ 0x10059c680
// > sub_10059C5E0 @ 0x10059c740
// > sub_10059C7D8 @ 0x10059c89c
//
// 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 sub_10059C368(unsigned __int64 *result, _DWORD *a2)
{
int v2; // w11
unsigned __int64 v3; // x10
int v4; // w9
unsigned __int64 v5; // x8
int v6; // w13
_DWORD *v7; // x14
int v8; // w15
__int64 v9; // x16
_DWORD *v10; // x17
unsigned int v11; // w11
unsigned __int16 v12; // w10
int v13; // w9
unsigned __int16 v14; // w8
v2 = (unsigned __int16)*result;
v3 = *result >> 16;
v4 = (unsigned __int16)result[1];
v5 = result[1] >> 16;
v6 = 3;
v7 = a2;
v8 = 5;
while ( 1 )
{
v9 = 4LL * (unsigned int)(v8 - 1);
v10 = v7;
do
{
v11 = (v5 & v4) + v2 + (v3 & ~(_DWORD)v5) + *v10;
v2 = (v11 >> 15) & 1 | (2 * (unsigned __int16)v11);
v12 = v10[1] + v3 + (v2 & v5) + (v4 & ~(_WORD)v2);
LODWORD(v3) = (v12 >> 14) & 3 | (4 * v12);
v13 = v10[2] + v4 + (v3 & v2) + (v5 & ~(_DWORD)v3);
v4 = ((unsigned __int16)v13 >> 13) & 7 | (8 * (unsigned __int16)v13);
v14 = v10[3] + v5 + (v4 & v3) + (v2 & ~(_WORD)v4);
LODWORD(v5) = (v14 >> 11) & 0x1F | (32 * v14);
--v8;
v10 += 4;
}
while ( v8 );
if ( !--v6 )
break;
v7 += v9 + 4;
v2 += a2[v5 & 0x3F];
LODWORD(v3) = a2[v2 & 0x3F] + v3;
if ( v6 == 2 )
v8 = 6;
else
v8 = 5;
v4 += a2[v3 & 0x3F];
LODWORD(v5) = a2[v4 & 0x3F] + v5;
}
*result = (unsigned __int16)v2 | ((unsigned __int64)(unsigned __int16)v3 << 16);
result[1] = (unsigned __int16)v4 | ((unsigned __int64)(unsigned __int16)v5 << 16);
return result;
}