//
// sub_100665498 from 0x100665498 to 0x1006655c4 (300 bytes)
//
// 3 xrefs:
// > sub_100648704 @ 0x10064896c
// > sub_100654DEC @ 0x10065514c
// > sub_100654DEC @ 0x10065525c
//
// 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:11:00 +0000
//
__int64 __fastcall sub_100665498(__int64 a1, __int64 a2, __int64 a3, int (*a4)(void))
{
_QWORD *v8; // x26
int v9; // w25
int v10; // w0
int v11; // w8
__int64 v12; // x24
__int64 v13; // x22
_QWORD *v14; // x0
v8 = *(_QWORD **)(a1 + 256);
v9 = *(_DWORD *)(a1 + 676);
sub_100657448(a1);
if ( !a2 )
return 0;
if ( !a4 )
a4 = *(int (**)(void))(*(_QWORD *)(a1 + 8) + 152LL);
v10 = sub_100704BB4(a2);
v11 = a3;
if ( v10 >= 1 )
{
v12 = 0;
v13 = a3;
do
{
v14 = (_QWORD *)sub_100704BC8(a2, v12);
if ( (v8[6] & v14[7]) == 0 && (v8[2] & v14[3]) == 0 && (v8[3] & v14[4]) == 0 )
v13 += a4();
v12 = (unsigned int)(v12 + 1);
}
while ( (int)v12 < (int)sub_100704BB4(a2) );
v11 = a3;
if ( v13 != a3 )
{
if ( !v9 )
v13 += ((int (__fastcall *)(void *, __int64))a4)(&unk_1009E3B80, v13);
if ( (*(_BYTE *)(a1 + 432) & 0x80) != 0 )
v11 = v13 + ((__int64 (__fastcall *)(void *, __int64))a4)(&unk_1009E3BD8, v13);
else
v11 = v13;
}
}
return (unsigned int)(v11 - a3);
}