//
// sub_8C5D4 from 0x8c5d4 to 0x8c77c (424 bytes)
//
// 1 xrefs:
// > sub_8F210 @ 0x90bf8
//
// 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
//
// positive sp value has been detected, the output may be wrong!
__int64 __fastcall sub_8C5D4(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 v6; // x21
__int64 v7; // x29
__int64 v8; // x30
__int64 result; // x0
_QWORD *v10; // x1
_BYTE *v11; // x2
int v12; // w3
int v13; // w5
__int64 v14; // x6
char v15; // w4
_BYTE *v16; // x22
int v17; // w20
unsigned __int16 v18; // w9
char v19; // w19
char v20; // w23
unsigned __int16 v21; // w8
unsigned int v22; // w25
unsigned __int8 v23; // w24
unsigned int v24; // w28
__int64 v25; // x0
int v26; // w8
char v27; // w8
unsigned __int8 v28; // w10
unsigned int v29; // w9
unsigned int v31; // w8
char v32; // w8
__int64 v33; // [xsp-78h] [xbp-78h]
char v34; // [xsp-68h] [xbp-68h]
unsigned int v35; // [xsp-64h] [xbp-64h] BYREF
__int64 v36; // [xsp-10h] [xbp-10h]
__int64 v37; // [xsp-8h] [xbp-8h]
result = ((__int64 (__fastcall *)(__int64, __int64, __int64, __int64, __int64, __int64, __int64))sub_919BC)(
a1,
a2,
a3,
a4,
a5,
a6,
v8);
v36 = v7;
v37 = v14;
v34 = v15;
if ( v10 )
{
v16 = v11;
if ( v11 )
{
if ( *v10 )
{
v17 = v12;
v33 = v13;
if ( v12 )
{
while ( 2 )
{
result = ((__int64 (__fastcall *)(__int64))sub_919B0)(result);
if ( (_DWORD)result )
return result;
if ( v17 >= 0x8000 )
v18 = 0x8000;
else
v18 = v17;
v19 = 0;
v20 = 0;
v21 = 0;
v22 = v18;
v23 = 9;
LABEL_10:
v24 = v21;
while ( v22 > v24 )
{
v25 = ((__int64 (*)(void))sub_919A0)();
if ( v23 > 6u )
{
if ( v23 > 8u )
{
if ( v23 != 9 )
{
((void (__fastcall *)(__int64))sub_91920)(v25);
return 19;
}
LOBYTE(v26) = v35;
if ( (v35 & 0x100) == 0 )
goto LABEL_30;
v23 = v35 + 1;
}
else
{
v26 = v35;
v29 = (unsigned __int8)((0xFFu >> (9 - v23)) - 4);
if ( v35 <= v29 || v35 > v29 + 8 )
{
if ( v23 <= 7u )
LABEL_29:
v26 = (char)(v26 << (8 - v23)) >> (8 - v23);
LABEL_30:
v19 += v26;
v20 += v19;
v16 += v33;
if ( (v34 & 1) != 0 )
v32 = v20;
else
v32 = v19;
*v16 = v32;
v21 = v24 + 1;
goto LABEL_10;
}
v31 = v35 - v29;
v35 = v31;
if ( v31 < v23 )
v23 = v31;
else
v23 = v31 + 1;
}
}
else
{
v26 = v35;
if ( v35 != 1 << (v23 - 1) )
goto LABEL_29;
sub_8C474(v6, 3u, (int *)&v35);
v27 = v35;
v28 = v35++ + 2;
if ( v35 < v23 )
v23 = v27 + 1;
else
v23 = v28;
}
}
result = sub_91920();
v17 -= v22;
if ( v17 )
continue;
break;
}
}
return 0;
}
else
{
return 31;
}
}
}
return result;
}