//
// sub_1005D885C from 0x1005d885c to 0x1005d8990 (308 bytes)
//
// 4 xrefs:
// > sub_100565B84 @ 0x100566520
// > sub_100565B84 @ 0x100566540
// > sub_100565B84 @ 0x100566560
// > sub_1005EB8B0 @ 0x1005eb8c4
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:09:35 +0000
//
__int64 __fastcall sub_1005D885C(_QWORD *a1, __int64 a2, int a3, __int64 a4)
{
_QWORD *v8; // x23
int v9; // w24
int v10; // w8
__int64 result; // x0
int v12; // w9
if ( a3 < 0 )
{
if ( !a2 )
{
v8 = a1;
while ( 1 )
{
v8 = (_QWORD *)*v8;
if ( v8 == a1 )
return 63;
if ( *((_BYTE *)v8 + 60) )
goto LABEL_28;
}
}
v8 = (_QWORD *)*a1;
if ( (_QWORD *)*a1 == a1 )
return 63;
while ( !*((_BYTE *)v8 + 60) || (unsigned int)sub_1005ED12C(v8[4], a2) )
{
v8 = (_QWORD *)*v8;
if ( v8 == a1 )
return 63;
}
}
else
{
v8 = (_QWORD *)*a1;
if ( a2 )
{
if ( (_QWORD *)*a1 != a1 )
{
v9 = 0;
while ( 1 )
{
if ( !(unsigned int)sub_1005ED12C(v8[4], a2) )
{
if ( v9 == a3 )
goto LABEL_28;
++v9;
}
v8 = (_QWORD *)*v8;
if ( v8 == a1 )
return 63;
}
}
return 63;
}
if ( (_QWORD *)*a1 == a1 )
return 63;
if ( a3 )
{
v10 = a3 + 1;
do
{
v8 = (_QWORD *)*v8;
if ( v8 == a1 )
return 63;
}
while ( --v10 >= 2 );
}
if ( !v8 )
return 63;
}
LABEL_28:
*(_QWORD *)a4 = v8[3];
*(_QWORD *)(a4 + 8) = v8[4];
*(_QWORD *)(a4 + 16) = v8[5];
v12 = *((unsigned __int8 *)v8 + 60);
*(_DWORD *)(a4 + 24) = *((_DWORD *)v8 + 14);
*(_DWORD *)(a4 + 28) = v12;
result = 0;
if ( v12 )
*((_BYTE *)v8 + 60) = 0;
return result;
}