//
// sub_BDC06 from 0xbdc06 to 0xbdc92 (140 bytes)
//
// 4 xrefs:
// > sub_BD410 @ 0xbd4b2
// > sub_BD598 @ 0xbd718
// > sub_BD598 @ 0xbd762
// > sub_BDACC @ 0xbdbee
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:41:47 +0000
//
int __fastcall sub_BDC06(int *a1, int a2, int a3, int a4)
{
int v4; // r8
int v5; // lr
int v6; // r12
bool v7; // cc
int v8; // r4
int result; // r0
v4 = a2 >> 3;
v5 = 0;
v6 = 1 << (a2 & 7);
while ( a2 < a3 )
{
v7 = v5 < a4;
if ( v5 < a4 )
v7 = a2 < a1[8];
if ( !v7 )
break;
v8 = *a1;
if ( ((unsigned __int8)v6 & *(_BYTE *)(*a1 + v4)) != 0 )
{
v5 = 0;
goto LABEL_12;
}
if ( (a2 & 0x1F) == 0 && *(_DWORD *)(v8 + v4) == -1 )
{
v5 = 0;
LABEL_13:
if ( *(_DWORD *)(v8 + v4) != -1 )
goto LABEL_15;
a2 += 32;
v4 += 4;
}
else
{
++v5;
LABEL_12:
if ( (a2 & 0x1F) == 0 )
goto LABEL_13;
LABEL_15:
++a2;
LOBYTE(v6) = 2 * v6;
if ( (a2 & 7) == 0 )
{
++v4;
LOBYTE(v6) = 1;
}
}
}
result = -1;
if ( v5 == a4 )
return a2 - a4;
return result;
}