//
// sub_72CA8 from 0x72ca8 to 0x72df4 (332 bytes)
//
// 1 xrefs:
// > sub_753C4 @ 0x770bc
//
// 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_72CA8(int a1, const void **a2, int a3, int a4, int a5, int a6)
{
int result; // r0
const void **v8; // r8
unsigned int v10; // r8
unsigned int v11; // r9
int v12; // r0
unsigned int v13; // r10
unsigned int v14; // r4
int v15; // r0
char v16; // r0
unsigned int v17; // r1
int v18; // r1
char v19; // r2
char v20; // r0
int v22; // [sp+4h] [bp-34h]
int v23; // [sp+8h] [bp-30h]
int v24; // [sp+Ch] [bp-2Ch]
int v25; // [sp+10h] [bp-28h]
int v26; // [sp+14h] [bp-24h]
unsigned int v27; // [sp+18h] [bp-20h] BYREF
result = 31;
if ( a2 && a3 )
{
v8 = a2;
if ( *a2 )
{
v22 = a3;
LABEL_5:
if ( a4 )
{
result = sub_72BF8(a1, v8);
if ( !result )
{
v23 = a4;
if ( a4 >= 0x8000 )
LOWORD(a4) = 0x8000;
v25 = 0;
v24 = 0;
v10 = (unsigned __int16)a4;
LOBYTE(v11) = 9;
v12 = 0;
LABEL_10:
v13 = (unsigned __int16)v12;
v26 = v12;
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
if ( v10 <= v13 )
{
sub_72C6C(a1);
a4 = v23 - v10;
v8 = a2;
goto LABEL_5;
}
v14 = (unsigned __int8)v11;
sub_72B92(a1, (unsigned __int8)v11, (int *)&v27);
if ( (unsigned __int8)v11 > 6u )
break;
v15 = v27;
if ( v27 != 1 << (v11 - 1) )
goto LABEL_27;
sub_72B92(a1, 3u, (int *)&v27);
v16 = v27;
v11 = v27 + 1;
v27 = v11;
if ( v11 >= v14 )
LOBYTE(v11) = v16 + 2;
}
if ( (unsigned __int8)v11 > 8u )
break;
v15 = v27;
v17 = (unsigned __int8)((0xFFu >> (9 - v11)) - 4);
if ( v27 <= v17 || v27 > (unsigned int)(unsigned __int8)((0xFFu >> (9 - v11)) - 4) + 8 )
{
if ( (unsigned __int8)v11 <= 7u )
LABEL_27:
v15 = (char)(v15 << (8 - v11)) >> (8 - v11);
LABEL_28:
v18 = v25 + v15;
v19 = v24 + v25 + v15;
v20 = v25 + v15;
v24 += v18;
v25 = v18;
if ( a5 )
v20 = v19;
*(_BYTE *)(v22 + a6) = v20;
v22 += a6;
v12 = v26 + 1;
goto LABEL_10;
}
LOBYTE(v11) = v27 - v17;
v27 -= v17;
if ( v15 - v17 >= v14 )
LOBYTE(v11) = v11 + 1;
}
if ( (unsigned __int8)v11 != 9 )
break;
v15 = v27;
if ( (v27 & 0x100) == 0 )
goto LABEL_28;
LOBYTE(v11) = v27 + 1;
}
sub_72C6C(a1);
return 19;
}
}
else
{
return 0;
}
}
else
{
return 31;
}
}
return result;
}