//
// sub_1006036C0 from 0x1006036c0 to 0x1006037c4 (260 bytes)
//
// 2 xrefs:
// > sub_100603544 @ 0x100603628
// > sub_1006037C4 @ 0x1006038a8
//
// 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_1006036C0(int *a1, __int64 a2)
{
int v4; // w21
__int64 v5; // x22
int v6; // w8
int v7; // w0
v4 = sub_1005DE730(a1, a2);
if ( v4 == -1 )
return 0;
if ( (unsigned int)(*(_DWORD *)a2 - 1) <= 1 )
{
while ( 1 )
{
if ( v4 >= (int)sub_1005DEA4C((unsigned int *)a1) )
return 0;
v5 = sub_1005DEA60((__int64)a1, v4);
v6 = *(_DWORD *)v5;
v7 = *(_DWORD *)v5 - *(_DWORD *)a2;
if ( *(_DWORD *)v5 == *(_DWORD *)a2 )
{
if ( v6 == 2 )
{
v7 = sub_1005FEE00(*(_QWORD *)(v5 + 8), *(_QWORD *)(a2 + 8));
}
else
{
if ( v6 != 1 )
goto LABEL_13;
v7 = sub_1005FED60(*(_QWORD *)(v5 + 8), *(_QWORD *)(a2 + 8));
}
}
if ( v7 )
return 0;
v6 = *(_DWORD *)a2;
LABEL_13:
if ( v6 == 2 )
{
if ( !(unsigned int)sub_1005FEEA0(*(_QWORD *)(v5 + 8), *(_QWORD *)(a2 + 8)) )
return v5;
}
else if ( v6 != 1 || !(unsigned int)sub_1005FEF78(*(__int64 **)(v5 + 8), *(__int64 **)(a2 + 8)) )
{
return v5;
}
++v4;
}
}
return sub_1005DEA60((__int64)a1, v4);
}