//
// sub_66DB40 from 0x66db40 to 0x66dbe4 (164 bytes)
//
// 0 xrefs:
//
// 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
//
unsigned int __fastcall sub_66DB40(unsigned int result, int a2, _DWORD *a3, int a4)
{
_DWORD *v4; // r5
_DWORD *v8; // r4
unsigned int v9; // r2
_DWORD *v10; // r1
int v11; // r3
int v12; // r0
unsigned int v13; // r3
v4 = *(_DWORD **)(result + 396);
if ( v4[2] < *(_DWORD *)(result + 288) )
{
v8 = (_DWORD *)result;
v9 = v4[3];
while ( 1 )
{
v13 = v8[71];
if ( v13 <= v9 )
{
result = (unsigned int)v8;
v10 = v4 + 6;
if ( v9 != v13 )
return result;
}
else
{
(*(void (__fastcall **)(_DWORD *, int, _DWORD *, int, _DWORD *, _DWORD *, _DWORD))(v8[100] + 4))(
v8,
a2,
a3,
a4,
v4 + 6,
v4 + 3,
v8[71]);
result = (unsigned int)v8;
v10 = v4 + 6;
if ( v4[3] != v8[71] )
return result;
}
result = (*(int (__fastcall **)(unsigned int, _DWORD *))(v8[101] + 4))(result, v10);
v9 = 0;
v11 = v4[4];
if ( !result )
break;
if ( v11 )
{
++*a3;
v4[4] = 0;
}
v12 = v4[2];
v4[3] = 0;
result = v12 + 1;
v4[2] = result;
if ( v8[72] <= result )
return result;
}
if ( !v11 )
{
--*a3;
v4[4] = 1;
}
}
return result;
}