//
// sub_1000C8D20 from 0x1000c8d20 to 0x1000c8fca (682 bytes)
//
// 1 xrefs:
// > sub_1000C9520 @ 0x1000c97d8
//
// 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:20:37 +0000
//
__int64 __fastcall sub_1000C8D20(__int64 a1, __int64 a2, __int64 a3, __m128 a4)
{
int *v4; // r12
int *v5; // r13
__int64 v6; // rbx
int v7; // edi
int v8; // r15d
unsigned __int64 v9; // r8
unsigned __int64 v10; // r10
unsigned __int64 v11; // rsi
__int64 **v12; // rax
__int64 *v13; // r9
unsigned __int64 v14; // r8
unsigned __int64 v15; // rax
__int64 v16; // rax
__int64 *i; // rax
int *v19; // [rsp+8h] [rbp-38h] BYREF
int v20; // [rsp+10h] [rbp-30h] BYREF
if ( *(_DWORD *)(a1 + 1028) != 1268 )
return a2;
v4 = *(int **)(a1 + 1840);
v5 = *(int **)(a1 + 1848);
if ( v4 == v5 )
return a2;
v6 = a3;
if ( a3 != a2 )
{
a4 = (__m128)*(unsigned int *)(a2 + 32);
*(_DWORD *)(a3 + 32) = a4.i32[0];
sub_100090950((_QWORD *)a3, *(__int64 **)(a2 + 16), nullptr);
v4 = *(int **)(a1 + 1840);
v5 = *(int **)(a1 + 1848);
}
*(_QWORD *)(v6 + 40) = *(_QWORD *)(a2 + 40);
while ( v4 != v5 )
{
v7 = *v4;
v20 = *v4;
v8 = v4[2];
v9 = *(_QWORD *)(v6 + 8);
if ( !v9 )
goto LABEL_36;
v10 = (0x101010101010101LL
* ((((v9 - ((v9 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v9 - ((v9 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((v9 - ((v9 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v9 - ((v9 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v10 > 1 )
{
v11 = v8;
if ( v9 > v8 )
goto LABEL_15;
if ( (v9 | v8) >> 32 )
{
v11 = v8 % v9;
LABEL_15:
v12 = *(__int64 ***)(*(_QWORD *)v6 + 8 * v11);
if ( !v12 )
goto LABEL_36;
goto LABEL_16;
}
v11 = v8 % (unsigned int)v9;
v12 = *(__int64 ***)(*(_QWORD *)v6 + 8 * v11);
if ( !v12 )
goto LABEL_36;
}
else
{
v11 = v8 & (v9 - 1);
v12 = *(__int64 ***)(*(_QWORD *)v6 + 8 * v11);
if ( !v12 )
goto LABEL_36;
}
LABEL_16:
v13 = *v12;
if ( *v12 )
{
if ( (unsigned int)v10 < 2 )
{
v14 = v9 - 1;
while ( 1 )
{
v16 = v13[1];
if ( v16 == v8 )
{
if ( *((_DWORD *)v13 + 4) == v8 )
goto LABEL_34;
}
else if ( (v14 & v16) != v11 )
{
goto LABEL_36;
}
v13 = (__int64 *)*v13;
if ( !v13 )
goto LABEL_36;
}
}
do
{
v15 = v13[1];
if ( v15 == v8 )
{
if ( *((_DWORD *)v13 + 4) == v8 )
{
LABEL_34:
v8 = *((_DWORD *)v13 + 5);
break;
}
}
else
{
if ( v15 < v9 )
goto LABEL_25;
if ( (v9 | v15) >> 32 )
{
v15 %= v9;
LABEL_25:
if ( v15 != v11 )
break;
goto LABEL_20;
}
if ( (unsigned int)v15 % (unsigned int)v9 != v11 )
break;
}
LABEL_20:
v13 = (__int64 *)*v13;
}
while ( v13 );
}
LABEL_36:
for ( i = *(__int64 **)(v6 + 16); i; i = (__int64 *)*i )
{
if ( *((_DWORD *)i + 5) == v7 )
*((_DWORD *)i + 5) = v8;
}
v19 = &v20;
*((_DWORD *)sub_10001C2C0((float *)v6, &v20, a4, (__int64)&unk_100A04AD3, &v19) + 5) = v8;
v4 += 4;
}
*(_QWORD *)(v6 + 40) = sub_1000C8710(v6);
return v6;
}