//
// sub_10050FE70 from 0x10050fe70 to 0x10050fff4 (388 bytes)
//
// 2 xrefs:
// > sub_10050FE40 @ 0x10050fe60
// > sub_100510370 @ 0x10051039c
//
// 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_10050FE70(__int64 a1, int *a2, _QWORD *a3)
{
int v3; // w9
int v7; // w8
__int64 v8; // x1
__int64 result; // x0
int v10; // w23
int *v11; // x22
int v12; // w8
__int64 v13; // x9
__int64 v14; // x22
int v15; // t1
int v16; // w24
__int64 v17; // x8
__int64 v18; // x20
int v19; // w8
int v20; // w9
int v21; // w8
int v22; // w8
__int64 v23; // x1
__int64 v24; // x8
v3 = *(_DWORD *)(a1 + 36);
if ( v3 == -1 )
return 28;
v7 = *(_DWORD *)(a1 + 8);
if ( v3 == v7 )
{
if ( v3 >= 2 )
v8 = (unsigned int)(2 * v3);
else
v8 = 4;
result = sub_1005107F4(a1, v8);
if ( (_DWORD)result )
return result;
v7 = *(_DWORD *)(a1 + 8);
}
if ( !v7 )
return 28;
v10 = *a2;
v11 = (int *)(*(_QWORD *)a1 + 4LL * (*a2 & (v7 - 1)));
v12 = *v11;
if ( *v11 != -1 )
{
v13 = *(_QWORD *)(a1 + 16);
while ( *(_DWORD *)(v13 + 16LL * v12) != v10 )
{
v14 = v13 + 16LL * v12;
v15 = *(_DWORD *)(v14 + 4);
v11 = (int *)(v14 + 4);
v12 = v15;
if ( v15 == -1 )
goto LABEL_13;
}
return 28;
}
LABEL_13:
v16 = *(_DWORD *)(a1 + 32);
if ( v16 != -1 )
{
v17 = *(_QWORD *)(a1 + 16) + 16LL * v16;
*(_DWORD *)(a1 + 32) = *(_DWORD *)(v17 + 4);
*(_DWORD *)(v17 + 4) = -1;
*(_DWORD *)v17 = *a2;
*(_QWORD *)(v17 + 8) = *a3;
LABEL_28:
*v11 = v16;
++*(_DWORD *)(a1 + 36);
return 0;
}
v18 = *a3;
v16 = *(_DWORD *)(a1 + 24);
v19 = *(_DWORD *)(a1 + 28);
if ( v19 >= 0 )
v20 = *(_DWORD *)(a1 + 28);
else
v20 = -v19;
v21 = *(_DWORD *)(a1 + 24);
if ( v20 > v16 )
{
LABEL_27:
v24 = *(_QWORD *)(a1 + 16) + 16LL * v21;
*(_DWORD *)v24 = v10;
*(_DWORD *)(v24 + 4) = -1;
*(_QWORD *)(v24 + 8) = v18;
++*(_DWORD *)(a1 + 24);
goto LABEL_28;
}
v22 = (int)(float)((float)v20 * 1.5);
if ( v22 <= v16 + 1 )
v22 = v16 + 1;
if ( v22 <= 4 )
v23 = 4;
else
v23 = (unsigned int)v22;
result = sub_100510928(a1 + 16, v23);
if ( !(_DWORD)result )
{
v21 = *(_DWORD *)(a1 + 24);
goto LABEL_27;
}
return result;
}