//
// sub_6C50D0 from 0x6c50d0 to 0x6c5374 (676 bytes)
//
// 8 xrefs:
// > sub_6C5638 @ 0x6c5688
// > sub_6C5874 @ 0x6c58c4
// > sub_6C5874 @ 0x6c58fc
// > sub_6C5874 @ 0x6c598c
// > sub_6C5874 @ 0x6c5a5c
// > sub_6C5874 @ 0x6c5cbc
// > sub_6C5874 @ 0x6c5d38
// > sub_6C5874 @ 0x6c5db8
//
// 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
//
int __fastcall sub_6C50D0(int a1, int a2, int a3)
{
int v4; // r3
_BYTE *v6; // [sp+Ch] [bp-18h]
int v7; // [sp+10h] [bp-14h]
int v8; // [sp+14h] [bp-10h]
int v9; // [sp+18h] [bp-Ch]
_DWORD *i; // [sp+1Ch] [bp-8h]
v7 = a3 - a2;
v6 = (_BYTE *)(a1 + (a2 >> 3));
if ( a3 - a2 > 0 && (v8 = a2 & 7, (a2 & 7) != 0) )
{
v9 = byte_9E3D24[(unsigned __int8)((unsigned __int8)*v6 << v8)];
if ( 8 - v8 < v9 )
v9 = 8 - v8;
if ( v9 > v7 )
v9 = a3 - a2;
if ( v8 + v9 <= 7 )
return v9;
v7 -= v9;
++v6;
}
else
{
v9 = 0;
}
if ( v7 <= 63 )
goto LABEL_25;
while ( ((unsigned __int8)v6 & 3) != 0 )
{
if ( *v6 )
return byte_9E3D24[(unsigned __int8)*v6] + v9;
v9 += 8;
v7 -= 8;
++v6;
}
for ( i = v6; v7 > 31 && !*i; ++i )
{
v9 += 32;
v7 -= 32;
}
v6 = i;
LABEL_25:
while ( v7 > 7 )
{
if ( *v6 )
return byte_9E3D24[(unsigned __int8)*v6] + v9;
v9 += 8;
v7 -= 8;
++v6;
}
if ( v7 > 0 )
{
v4 = v7;
if ( byte_9E3D24[(unsigned __int8)*v6] < v7 )
v4 = byte_9E3D24[(unsigned __int8)*v6];
v9 += v4;
}
return v9;
}