//
// sub_10020BDB4 from 0x10020bdb4 to 0x10020be58 (164 bytes)
//
// 1 xrefs:
// > sub_10020BAC8 @ 0x10020bc3c
//
// 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_10020BDB4(__int64 result, __int64 a2, __int64 (__fastcall **a3)(_QWORD *, __int64), __int64 a4)
{
__int64 v4; // x29
__int64 v5; // x30
unsigned __int64 v6; // x8
__int64 v8; // x20
unsigned __int64 v9; // x23
_QWORD *v10; // x21
_QWORD *v11; // x22
_QWORD *v12; // x24
_QWORD v13[9]; // [xsp+8h] [xbp-48h] BYREF
v6 = a4 - 2;
if ( a4 >= 2 )
{
v13[7] = v4;
v13[8] = v5;
v8 = result;
v9 = v6 >> 1;
v10 = (_QWORD *)(result + 8 * (v6 >> 1));
v11 = (_QWORD *)(a2 - 8);
result = (*a3)(v10, a2 - 8);
if ( (_DWORD)result )
{
v13[0] = *v11;
do
{
v12 = v10;
*v11 = *v10;
if ( !v9 )
break;
v9 = (v9 - 1) >> 1;
v10 = (_QWORD *)(v8 + 8 * v9);
result = (*a3)(v10, (__int64)v13);
v11 = v12;
}
while ( (result & 1) != 0 );
*v12 = v13[0];
}
}
return result;
}