//
// sub_1005813F0 from 0x1005813f0 to 0x1005814b0 (192 bytes)
//
// 1 xrefs:
// > sub_10055C450 @ 0x10055c4d8
//
// 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
//
_QWORD *__fastcall sub_1005813F0(_QWORD *result, __int64 a2)
{
__int64 v3; // x19
__int64 v4; // x21
_QWORD *v5; // x1
__int64 *v6[3]; // [xsp+8h] [xbp-38h] BYREF
v3 = (__int64)result;
v4 = *(_QWORD *)(a2 + 1600);
if ( v4 )
{
result = *(_QWORD **)(v4 + 16);
v5 = (_QWORD *)*result;
if ( *result )
{
while ( *v5 != a2 )
{
v5 = (_QWORD *)v5[2];
if ( !v5 )
goto LABEL_7;
}
result = (_QWORD *)sub_10056BBA0((__int64)result, v5, 0);
--*(_QWORD *)(v4 + 8);
*(_QWORD *)(a2 + 1600) = 0;
}
LABEL_7:
if ( !*(_QWORD *)(v4 + 8) && v3 )
{
sub_10056C468(v3, (__int64)v6);
while ( 1 )
{
result = (_QWORD *)sub_10056C478(v6);
if ( !result )
break;
if ( *result == v4 )
{
result = (_QWORD *)sub_10056C0CC(v3, result[1], result[2]);
break;
}
}
}
if ( v3 )
--*(_QWORD *)(v3 + 48);
}
return result;
}