//
// sub_100622EE4 from 0x100622ee4 to 0x100622fec (264 bytes)
//
// 10 xrefs:
// > sub_100556A6C @ 0x100556b28
// > sub_100556A6C @ 0x100556b5c
// > sub_100556A6C @ 0x100556b90
// > sub_100556A6C @ 0x100556bc8
// > sub_100556C6C @ 0x100556de4
// > sub_100556C6C @ 0x100557164
// > sub_100556C6C @ 0x100557258
// > sub_100556C6C @ 0x1005572ec
// > sub_100557398 @ 0x100557618
// > sub_100557398 @ 0x100557788
//
// 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:10:20 +0000
//
unsigned __int64 __fastcall sub_100622EE4(__int64 a1, __int64 a2, __int16 a3, int a4)
{
unsigned int v4; // w10
__int64 v5; // x8
int v6; // w11
unsigned __int64 result; // x0
unsigned int v8; // w12
unsigned int *v9; // x9
int v10; // w11
__int64 v11; // x14
__int64 v12; // x13
unsigned int v13; // w15
unsigned int *v14; // x16
unsigned int v15; // t1
v4 = __rbit32(*(_DWORD *)(a1 + 104) & a4);
v5 = *(_QWORD *)(a1 + 64);
v6 = a3 & 0x7FFF;
result = (unsigned int)*(__int16 *)(a1 + 98);
v8 = result - v6;
v9 = (unsigned int *)(v5 + 4LL * (a3 & 0x7FFF));
if ( (unsigned int)(result - v6) >= 4 )
{
v11 = 0;
v12 = 0;
v13 = v8 >> 2;
do
{
v14 = &v9[v12];
if ( *v14 > v4 )
return (unsigned int)(v6 + v12);
if ( v14[1] > v4 )
return (unsigned int)(v6 + v12 + 1);
if ( v14[2] > v4 )
return (unsigned int)(v6 + v12 + 2);
if ( v14[3] > v4 )
return (unsigned int)(v6 + v12 + 3);
v12 += 4;
v11 -= 16;
--v13;
}
while ( v13 );
v9 = (unsigned int *)((char *)v9 - v11);
v10 = v8 & 3;
if ( (v8 & 3) != 0 )
goto LABEL_3;
}
else
{
v10 = result - (a3 & 0x7FFF);
if ( (v8 & 3) != 0 )
{
LABEL_3:
if ( *v9 > v4 )
return ((unsigned __int64)v9 - v5) >> 2;
if ( v10 != 1 )
{
if ( v9[1] > v4 )
return ((unsigned __int64)++v9 - v5) >> 2;
if ( v10 != 2 )
{
v15 = v9[2];
v9 += 2;
if ( v15 > v4 )
return ((unsigned __int64)v9 - v5) >> 2;
}
}
}
}
return result;
}