//
// sub_180001910 from 0x180001910 to 0x180001a0f (255 bytes)
//
// 6 xrefs:
// > sub_180002760 @ 0x1800027b2
// > sub_180002830 @ 0x180002893
// > sub_180002960 @ 0x180002a34
// > sub_180002960 @ 0x180002a77
// > sub_180002960 @ 0x180002aad
// > sub_180002960 @ 0x180002ae8
//
// 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_180001910(__int64 a1, __int64 a2, __int16 a3, int a4)
{
__int64 v4; // r8
unsigned int v5; // edx
unsigned int v6; // r11d
unsigned int v7; // r9d
unsigned int v8; // edx
__int64 v9; // r9
int v10; // eax
char v11; // cl
unsigned int v12; // edx
unsigned int *v13; // rax
unsigned int v14; // r8d
int v15; // ecx
v4 = a3 & 0x7FFF;
v5 = __ROL4__(a4 & *(_DWORD *)(a1 + 104), 16);
v6 = *(__int16 *)(a1 + 98);
v7 = (v5 << 8) ^ ((v5 << 8) ^ (v5 >> 8)) & 0xFF00FF;
v8 = (16 * v7) ^ ((16 * v7) ^ (v7 >> 4)) & 0xF0F0F0F;
v9 = *(_QWORD *)(a1 + 64);
v10 = 2 * ((4 * v8) ^ ((4 * v8) ^ (v8 >> 2)) & 0x33333333);
v11 = v6 - v4;
v12 = v10 ^ (v10 ^ (((4 * v8) ^ ((4 * v8) ^ (v8 >> 2)) & 0x33333333) >> 1)) & 0x55555555;
v13 = (unsigned int *)(v9 + 4 * v4);
v14 = (v6 - (unsigned int)v4) >> 2;
if ( v14 )
{
while ( *v13 <= v12 )
{
if ( v13[1] > v12 )
return ((__int64)v13 - v9 + 4) >> 2;
if ( v13[2] > v12 )
return ((__int64)v13 - v9 + 8) >> 2;
if ( v13[3] > v12 )
return ((__int64)v13 - v9 + 12) >> 2;
v13 += 4;
if ( !--v14 )
goto LABEL_7;
}
}
else
{
LABEL_7:
v15 = v11 & 3;
if ( !v15 )
return v6;
while ( *v13 <= v12 )
{
++v13;
if ( !--v15 )
return v6;
}
}
return ((__int64)v13 - v9) >> 2;
}