//
// sub_1004BCF20 from 0x1004bcf20 to 0x1004bd1a0 (640 bytes)
//
// 1 xrefs:
// > sub_1004BBCDC @ 0x1004bbe20
//
// 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:06:18 +0000
//
void __fastcall sub_1004BCF20(__int64 a1, __int64 *a2)
{
__int64 v4; // x8
int v5; // w21
_BYTE *v6; // x0
unsigned __int64 v7; // x9
__int64 v8; // x8
__int64 v9; // x8
__int64 v10; // x9
__int64 v11; // x20
_BYTE *v12; // x0
unsigned __int64 v13; // x9
__int64 v14; // x8
unsigned int *v15; // x10
__int64 v16; // x11
unsigned int v17; // t1
_DWORD *v18; // x10
unsigned __int64 i; // x11
__int64 v20; // x12
_BYTE *v21; // x0
unsigned __int64 v22; // x8
_DWORD *v23; // x9
__int64 v24; // x10
unsigned __int64 j; // x11
__int64 v26; // x12
unsigned __int64 v27; // x8
__int64 v28; // x9
unsigned int *v29; // x10
unsigned __int64 k; // x11
__int64 v31; // x12
unsigned int v32; // t1
_DWORD *v33; // [xsp+8h] [xbp-38h] BYREF
_BYTE *v34; // [xsp+10h] [xbp-30h]
__int64 v35; // [xsp+18h] [xbp-28h]
LODWORD(v33) = 0;
sub_1004BCBE0(a2, 0x65u, (int *)&v33);
v4 = *(_QWORD *)(a1 + 680);
if ( !v4 )
return;
v5 = *(_DWORD *)(a1 + 740);
if ( *(_BYTE *)(a1 + 732) == 1 )
{
if ( (v5 | 2) != 2 )
goto LABEL_24;
v33 = nullptr;
v34 = nullptr;
v35 = 0;
GJGameLevel::dtExpandOrder((std::string *)(v4 + 1544), (__int64)&v33);
v6 = v33;
v7 = (v34 - (_BYTE *)v33) >> 2;
v8 = *a2;
if ( v7 >= 2 )
{
v18 = v33 + 1;
for ( i = 2; i <= v7; i += 2LL )
{
v20 = (unsigned int)*(v18 - 1);
if ( (unsigned int)v20 <= 0x63 )
*(_DWORD *)(v8 + 4 * v20) += *v18;
v18 += 2;
}
*(_DWORD *)(*a2 + 400) += *(_DWORD *)(*(_QWORD *)(a1 + 680) + 1656LL);
}
else
{
*(_DWORD *)(v8 + 400) += *(_DWORD *)(*(_QWORD *)(a1 + 680) + 1656LL);
if ( !v6 )
{
LABEL_24:
if ( (unsigned int)(v5 - 1) > 1 )
return;
v33 = nullptr;
v34 = nullptr;
v35 = 0;
GJGameLevel::dtExpandOrder((std::string *)(*(_QWORD *)(a1 + 680) + 1568LL), (__int64)&v33);
v21 = v33;
v22 = (v34 - (_BYTE *)v33) >> 2;
if ( v22 >= 3 )
{
v23 = v33 + 2;
v24 = *a2;
for ( j = 3; j <= v22; j += 3LL )
{
v26 = (unsigned int)*(v23 - 1);
if ( (unsigned int)v26 <= 0x63 )
*(_DWORD *)(v24 + 4 * v26) += *v23;
v23 += 3;
}
goto LABEL_41;
}
goto LABEL_35;
}
}
v34 = v6;
operator delete(v6);
goto LABEL_24;
}
v9 = *(unsigned int *)(a1 + 736);
if ( (v9 & 0x80000000) != 0 )
return;
v10 = *(_QWORD *)(a1 + 752);
if ( (int)v9 >= (int)((unsigned __int64)(*(_QWORD *)(a1 + 760) - v10) >> 6) )
return;
v11 = v10 + (v9 << 6);
if ( (v5 | 2) == 2 )
{
v33 = nullptr;
v34 = nullptr;
v35 = 0;
GJGameLevel::dtExpandOrder((std::string *)(v11 + 8), (__int64)&v33);
v12 = v33;
if ( v34 == (_BYTE *)v33 )
{
if ( !v33 )
goto LABEL_33;
}
else
{
v13 = (v34 - (_BYTE *)v33) >> 2;
v14 = *a2;
if ( v13 <= 1 )
v13 = 1;
v15 = v33;
do
{
v17 = *v15++;
v16 = v17;
if ( v17 <= 0x64 )
++*(_DWORD *)(v14 + 4 * v16);
--v13;
}
while ( v13 );
}
v34 = v12;
operator delete(v12);
}
LABEL_33:
if ( (unsigned int)(v5 - 1) > 1 )
return;
v33 = nullptr;
v34 = nullptr;
v35 = 0;
GJGameLevel::dtExpandOrder((std::string *)(v11 + 32), (__int64)&v33);
v21 = v33;
v27 = (v34 - (_BYTE *)v33) >> 2;
if ( v27 >= 2 )
{
v28 = *a2;
v29 = v33 + 1;
for ( k = 2; k <= v27; k += 2LL )
{
v32 = *v29;
v29 += 2;
v31 = v32;
if ( v32 <= 0x63 )
++*(_DWORD *)(v28 + 4 * v31);
}
goto LABEL_41;
}
LABEL_35:
if ( v21 )
{
LABEL_41:
v34 = v21;
operator delete(v21);
}
}