//
// sub_100502C04 from 0x100502c04 to 0x100502cdc (216 bytes)
//
// 1 xrefs:
// > sub_100501EE4 @ 0x100501ee4
//
// 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_100502C04(_QWORD *a1, __int64 a2, int a3, _DWORD *a4)
{
int v5; // w22
int v8; // w24
int v9; // w23
int v10; // w24
__int64 result; // x0
int v12; // [xsp+8h] [xbp-38h] BYREF
int v13; // [xsp+Ch] [xbp-34h] BYREF
v12 = 0;
v13 = a3;
*a4 = 0;
if ( a3 )
{
v5 = a3;
while ( 1 )
{
if ( (unsigned int)sub_1004FE328(a1[54], nullptr, 0) )
{
v8 = v12;
v9 = sub_1004FE328(a1[54], (float *)(a2 + 4LL * (unsigned int)(*(_DWORD *)(a1[1] + 12LL) * v12)), v5);
v10 = v9 + v8;
v12 = v10;
v13 = v5 - v9;
sub_1004FE454(a1[54], v9);
if ( v5 == v9 )
break;
}
result = sub_100502A98(a1, a2, &v13, &v12);
if ( (_DWORD)result )
return result;
v5 = v13;
if ( !v13 )
{
v10 = v12;
break;
}
}
}
else
{
v10 = 0;
}
*a4 = v10;
return 0;
}