//
// sub_1005CA220 from 0x1005ca220 to 0x1005ca506 (742 bytes)
//
// 1 xrefs:
// > processGJGameStateFields @ 0x1005e2323
//
// 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:32:49 +0000
//
void __fastcall sub_1005CA220(__int64 *a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rcx
__int64 v4; // rcx
int v5; // r14d
char *v6; // rdi
const char *v7; // rdi
int v8; // ecx
signed int v9; // r13d
char *v10; // r14
signed int v11; // r12d
__int64 v12; // rax
char *v13; // rdi
const char *v14; // rdi
int v15; // r15d
signed int v16; // ebx
__int64 v17; // r13
char *v18; // rdi
const char *v19; // rdi
char *v20; // rdi
const char *v21; // rdi
__int64 v22; // r12
__int64 v23; // rax
_QWORD *v24; // rbx
int v25; // eax
int v26; // eax
char *v27; // r14
__int64 v28; // rax
int v29; // eax
int v30; // ecx
void **v31; // rbx
void **v32; // r14
void *v33; // rdi
std::string v34; // [rsp+10h] [rbp-80h] BYREF
void *__p; // [rsp+30h] [rbp-60h] BYREF
void **v36; // [rsp+38h] [rbp-58h]
signed int v37; // [rsp+48h] [rbp-48h]
int v38; // [rsp+5Ch] [rbp-34h]
int v39; // [rsp+60h] [rbp-30h]
int v40; // [rsp+64h] [rbp-2Ch]
memset(&v34, 0, sizeof(v34));
v2 = *((int *)a1 + 6);
v3 = *a1;
if ( (int)v2 < (int)(-1431655765 * ((unsigned __int64)(a1[1] - *a1) >> 3)) )
{
*((_DWORD *)a1 + 6) = v2 + 1;
std::string::operator=(&v34, (const std::string *)(v3 + 24 * v2));
}
sub_1005C67B0((__int64)&__p, (unsigned __int8 *)&v34, "|", a1[4]);
v4 = v37;
v5 = 0;
if ( v37 < (int)(-1431655765 * ((unsigned __int64)((char *)v36 - (_BYTE *)__p) >> 3)) )
{
++v37;
v6 = (char *)__p + 24 * v4;
if ( (*v6 & 1) != 0 )
v7 = *((const char **)v6 + 2);
else
v7 = v6 + 1;
v5 = atoi(v7);
}
sub_10001ADF0(a2, *(_QWORD **)(a2 + 8));
*(_QWORD *)a2 = a2 + 8;
*(_OWORD *)(a2 + 8) = 0;
if ( v5 > 0 )
{
v8 = 0;
v40 = v5;
while ( 1 )
{
v9 = v37;
v10 = (char *)__p;
v11 = -1431655765 * ((unsigned __int64)((char *)v36 - (_BYTE *)__p) >> 3);
v39 = v8;
if ( v37 >= v11 )
break;
v12 = v37;
v9 = ++v37;
v13 = (char *)__p + 24 * v12;
if ( (*v13 & 1) != 0 )
v14 = *((const char **)v13 + 2);
else
v14 = v13 + 1;
v15 = atoi(v14);
v38 = 0;
if ( v9 >= v11 )
goto LABEL_14;
v16 = v9 + 1;
v37 = v9 + 1;
v18 = &v10[24 * v9];
if ( (*v18 & 1) != 0 )
v19 = *((const char **)v18 + 2);
else
v19 = v18 + 1;
v17 = (unsigned int)atoi(v19);
if ( v16 < v11 )
goto LABEL_22;
LABEL_26:
v22 = a2 + 8;
LABEL_27:
while ( 1 )
{
v23 = *(_QWORD *)v22;
v24 = (_QWORD *)v22;
if ( !*(_QWORD *)v22 )
break;
while ( 1 )
{
v22 = v23;
v25 = *(_DWORD *)(v23 + 28);
if ( v15 < v25 )
break;
if ( v15 <= v25 )
{
v26 = *(_DWORD *)(v22 + 32);
if ( (int)v17 < v26 )
goto LABEL_27;
if ( (int)v17 <= v26 )
{
v27 = (char *)v22;
goto LABEL_37;
}
}
v23 = *(_QWORD *)(v22 + 8);
if ( !v23 )
{
v24 = (_QWORD *)(v22 + 8);
goto LABEL_34;
}
}
}
LABEL_34:
v27 = (char *)operator new(0x28u);
*(_QWORD *)(v27 + 28) = (v17 << 32) | (unsigned int)v15;
*((_DWORD *)v27 + 9) = 0;
*(_OWORD *)v27 = 0;
*((_QWORD *)v27 + 2) = v22;
*v24 = v27;
v28 = **(_QWORD **)a2;
if ( v28 )
*(_QWORD *)a2 = v28;
sub_10001B680(*(__int64 **)(a2 + 8), (__int64 *)v27);
++*(_QWORD *)(a2 + 16);
LABEL_37:
v29 = v40;
v30 = v39;
*((_DWORD *)v27 + 9) = v38;
v8 = v30 + 1;
if ( v8 == v29 )
goto LABEL_40;
}
v15 = 0;
v38 = 0;
LABEL_14:
v16 = v9;
v17 = 0;
if ( v16 >= v11 )
goto LABEL_26;
LABEL_22:
v37 = v16 + 1;
v20 = &v10[24 * v16];
if ( (*v20 & 1) != 0 )
v21 = *((const char **)v20 + 2);
else
v21 = v20 + 1;
v38 = atoi(v21);
goto LABEL_26;
}
LABEL_40:
v31 = (void **)__p;
if ( __p )
{
v32 = v36;
v33 = __p;
if ( v36 != __p )
{
do
{
if ( (*(_BYTE *)(v32 - 3) & 1) != 0 )
operator delete(*(v32 - 1));
v32 -= 3;
}
while ( v32 != v31 );
v33 = __p;
}
v36 = v31;
operator delete(v33);
}
if ( (*(_BYTE *)&v34.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v34.__r_.__value_.__l.__data_);
}