//
// sub_1008CFEC0 from 0x1008cfec0 to 0x1008d028a (970 bytes)
//
// 1 xrefs:
// > sub_1008CDF10 @ 0x1008ce06e
//
// This function is hookable on this platform (idp: pc, 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 12:37:37 +0000
//
void __fastcall sub_1008CFEC0(__int64 a1, unsigned int **a2)
{
__int64 v4; // rdi
int v5; // r12d
unsigned int *v6; // rdi
unsigned __int64 v7; // rcx
unsigned int *v8; // rax
__int64 v9; // rax
__int64 v10; // r15
__int64 v11; // r15
unsigned int *v12; // rdi
unsigned __int64 v13; // rdx
unsigned int *v14; // rax
char v15; // cl
unsigned __int64 v16; // rcx
unsigned __int64 v17; // rcx
__int64 v18; // rdx
unsigned __int64 v19; // rcx
_DWORD *v20; // rdi
unsigned __int64 v21; // rax
unsigned int *v22; // rcx
unsigned __int64 i; // rdx
unsigned __int64 v24; // rsi
unsigned __int64 v25; // rsi
unsigned __int64 v26; // r8
unsigned __int64 v27; // r8
unsigned __int64 v28; // rcx
unsigned int *v29; // rax
unsigned __int64 v30; // rcx
__int64 v31; // rdx
unsigned __int64 v32; // rcx
unsigned __int64 v33; // rsi
__int64 v34; // rdx
unsigned __int64 v35; // r8
unsigned __int64 v36; // r8
unsigned __int64 v37; // rsi
unsigned __int64 v38; // r8
unsigned __int64 v39; // r8
void *__p[2]; // [rsp+0h] [rbp-40h] BYREF
__int64 v41; // [rsp+10h] [rbp-30h]
LODWORD(__p[0]) = 0;
sub_1008CFBD0(a2, 0x65u, (unsigned int *)__p);
v4 = *(_QWORD *)(a1 + 680);
if ( v4 )
{
v5 = *(_DWORD *)(a1 + 740);
if ( *(_BYTE *)(a1 + 732) == 1 )
{
if ( (v5 & 0xFFFFFFFD) != 0 )
goto LABEL_6;
*(_OWORD *)__p = 0;
v41 = 0;
GJGameLevel::dtExpandOrder((std::string *)(v4 + 1544), __p);
v6 = (unsigned int *)__p[0];
v7 = ((char *)__p[1] - (char *)__p[0]) >> 2;
v8 = *a2;
if ( v7 < 2 )
{
v8[100] += *(_DWORD *)(*(_QWORD *)(a1 + 680) + 1656LL);
if ( !v6 )
{
LABEL_6:
if ( (unsigned int)(v5 - 1) > 1 )
return;
goto LABEL_25;
}
LABEL_24:
__p[1] = v6;
operator delete(v6);
if ( (unsigned int)(v5 - 1) > 1 )
return;
LABEL_25:
*(_OWORD *)__p = 0;
v41 = 0;
GJGameLevel::dtExpandOrder((std::string *)(*(_QWORD *)(a1 + 680) + 1568LL), __p);
v20 = __p[0];
v21 = ((char *)__p[1] - (char *)__p[0]) >> 2;
if ( v21 >= 3 )
{
v22 = *a2;
for ( i = 3; i <= v21; i += 3LL )
{
v24 = (unsigned int)v20[i - 2];
if ( v24 <= 0x63 )
v22[v24] += v20[i - 1];
}
LABEL_42:
__p[1] = v20;
operator delete(v20);
return;
}
LABEL_41:
if ( !v20 )
return;
goto LABEL_42;
}
v17 = v7 - 2;
if ( v17 < 2 )
{
v18 = 0;
LABEL_20:
if ( (v17 & 2) == 0 )
{
v19 = v6[v18];
if ( v19 <= 0x63 )
v8[v19] += v6[v18 + 1];
}
(*a2)[100] += *(_DWORD *)(*(_QWORD *)(a1 + 680) + 1656LL);
goto LABEL_24;
}
v25 = ((v17 >> 1) + 1) & 0xFFFFFFFFFFFFFFFELL;
v18 = 0;
while ( 1 )
{
v26 = v6[v18];
if ( v26 <= 0x63 )
{
v8[v26] += v6[v18 + 1];
v27 = v6[v18 + 2];
if ( v27 <= 0x63 )
LABEL_36:
v8[v27] += v6[v18 + 3];
}
else
{
v27 = v6[v18 + 2];
if ( v27 <= 0x63 )
goto LABEL_36;
}
v18 += 4;
v25 -= 2LL;
if ( !v25 )
goto LABEL_20;
}
}
v9 = *(int *)(a1 + 736);
if ( v9 >= 0 )
{
v10 = *(_QWORD *)(a1 + 752);
if ( (int)v9 < (int)((unsigned __int64)(*(_QWORD *)(a1 + 760) - v10) >> 6) )
{
v11 = (v9 << 6) + v10;
if ( (v5 & 0xFFFFFFFD) == 0 )
{
*(_OWORD *)__p = 0;
v41 = 0;
GJGameLevel::dtExpandOrder((std::string *)(v11 + 8), __p);
v12 = (unsigned int *)__p[0];
if ( __p[1] != __p[0] )
{
v13 = ((char *)__p[1] - (char *)__p[0]) >> 2;
v14 = *a2;
v15 = 1;
if ( v13 >= 2 )
{
v15 = ((char *)__p[1] - (char *)__p[0]) >> 2;
v33 = v13 & 0xFFFFFFFFFFFFFFFELL;
v34 = 0;
while ( 1 )
{
v35 = v12[v34];
if ( v35 <= 0x64 )
{
++v14[v35];
v36 = v12[v34 + 1];
if ( v36 <= 0x64 )
LABEL_53:
++v14[v36];
}
else
{
v36 = v12[v34 + 1];
if ( v36 <= 0x64 )
goto LABEL_53;
}
v34 += 2;
if ( v33 == v34 )
goto LABEL_15;
}
}
v34 = 0;
LABEL_15:
if ( (v15 & 1) != 0 )
{
v16 = v12[v34];
if ( v16 <= 0x64 )
++v14[v16];
}
goto LABEL_38;
}
if ( __p[0] )
{
LABEL_38:
__p[1] = v12;
operator delete(v12);
}
}
if ( (unsigned int)(v5 - 1) > 1 )
return;
*(_OWORD *)__p = 0;
v41 = 0;
GJGameLevel::dtExpandOrder((std::string *)(v11 + 32), __p);
v20 = __p[0];
v28 = ((char *)__p[1] - (char *)__p[0]) >> 2;
if ( v28 < 2 )
goto LABEL_41;
v29 = *a2;
v30 = v28 - 2;
v31 = 1;
if ( v30 < 2 )
{
LABEL_45:
if ( (v30 & 2) == 0 )
{
v32 = (unsigned int)v20[v31];
if ( v32 <= 0x63 )
++v29[v32];
}
goto LABEL_42;
}
v37 = ((v30 >> 1) + 1) & 0xFFFFFFFFFFFFFFFELL;
while ( 1 )
{
v38 = (unsigned int)v20[v31];
if ( v38 <= 0x63 )
{
++v29[v38];
v39 = (unsigned int)v20[v31 + 2];
if ( v39 <= 0x63 )
LABEL_60:
++v29[v39];
}
else
{
v39 = (unsigned int)v20[v31 + 2];
if ( v39 <= 0x63 )
goto LABEL_60;
}
v31 += 4;
v37 -= 2LL;
if ( !v37 )
goto LABEL_45;
}
}
}
}
}