//
// sub_6662C from 0x6662c to 0x66774 (328 bytes)
//
// 1 xrefs:
// > ??> @ 0x10cb20
//
// 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_6662C(
__int64 a1,
unsigned int a2,
unsigned int a3,
_QWORD *a4,
_QWORD *a5,
unsigned int *a6,
_DWORD *a7)
{
__int64 result; // x0
unsigned int v15; // w8
unsigned int v16; // w26
unsigned int v17; // w10
__int64 v19; // x8
_BYTE v20[4]; // [xsp+8h] [xbp-48h] BYREF
int v21; // [xsp+Ch] [xbp-44h] BYREF
result = sub_66774(a1, 8, &v21, 1);
if ( !(_DWORD)result )
{
result = sub_66774(a1, *(unsigned int *)(a1 + 68), v20, 1);
if ( !(_DWORD)result )
{
v15 = *(_DWORD *)(a1 + 384);
v16 = a3 + a2;
if ( !v15 || v16 <= v15 || v21 + v15 <= a2 || (result = sub_66794(a1), !(_DWORD)result) )
{
v17 = *(_DWORD *)(a1 + 72);
if ( v17 > a2 && v17 >= a3 )
{
v19 = *(_QWORD *)(a1 + 352);
*a4 = v19 + a2;
if ( v16 <= v17 )
{
if ( a6 )
*a6 = a3;
if ( a5 )
*a5 = 0;
if ( a7 )
{
*a7 = 0;
return 0;
}
}
else
{
if ( a6 )
*a6 = v17 - a2;
if ( a5 )
*a5 = v19;
if ( a7 )
{
*a7 = v16 - *(_DWORD *)(a1 + 72);
return 0;
}
}
return 0;
}
else
{
*a4 = 0;
if ( a5 )
*a5 = 0;
if ( a6 )
*a6 = 0;
if ( a7 )
*a7 = 0;
return 31;
}
}
}
}
return result;
}