//
// sub_5F848 from 0x5f848 to 0x5f938 (240 bytes)
//
// 3 xrefs:
// > sub_68DB4 @ 0x68dc8
// > sub_78B30 @ 0x7a004
// > sub_7AAB4 @ 0x7aac0
//
// 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
//
__int64 __fastcall sub_5F848(__int64 *a1, __int64 a2, unsigned int a3, __int64 a4)
{
int v7; // w24
__int64 v8; // x20
__int64 result; // x0
int v10; // w8
if ( (a3 & 0x80000000) != 0 )
{
v8 = *a1;
if ( a2 )
{
while ( (__int64 *)v8 != a1 )
{
if ( *(_BYTE *)(v8 + 60) && !(unsigned int)sub_5FB80() )
goto LABEL_18;
v8 = *(_QWORD *)v8;
}
}
else
{
while ( (__int64 *)v8 != a1 )
{
if ( *(_BYTE *)(v8 + 60) )
goto LABEL_18;
v8 = *(_QWORD *)v8;
}
}
return 63;
}
if ( a2 )
{
v7 = 0;
v8 = (__int64)a1;
while ( 1 )
{
v8 = *(_QWORD *)v8;
if ( (__int64 *)v8 == a1 )
return 63;
if ( !(unsigned int)sub_5FB80() )
{
if ( v7 == a3 )
goto LABEL_18;
++v7;
}
}
}
v8 = sub_5F938(a1, a3);
if ( !v8 )
return 63;
LABEL_18:
result = 0;
*(_QWORD *)a4 = *(_QWORD *)(v8 + 24);
*(_QWORD *)(a4 + 8) = *(_QWORD *)(v8 + 32);
*(_QWORD *)(a4 + 16) = *(_QWORD *)(v8 + 40);
*(_DWORD *)(a4 + 24) = *(_DWORD *)(v8 + 56);
v10 = *(unsigned __int8 *)(v8 + 60);
*(_DWORD *)(a4 + 28) = v10;
if ( v10 )
*(_BYTE *)(v8 + 60) = 0;
return result;
}