//
// sub_1000DFB20 from 0x1000dfb20 to 0x1000dfc56 (310 bytes)
//
// 2 xrefs:
// > sub_1000AB490 @ 0x1000ab54c
// > sub_1008C0F40 @ 0x1008c1298
//
// 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:21:02 +0000
//
void __fastcall sub_1000DFB20(__int64 a1, __int64 a2)
{
unsigned __int64 v3; // rbx
size_t v4; // rdi
unsigned __int64 v5; // rbx
__int64 *v6; // rax
unsigned __int64 v7; // rcx
unsigned __int64 v8; // r8
__int64 *v9; // rdi
__int64 v10; // rsi
__int64 *v11; // r8
__int64 *v12; // r9
int v13; // ecx
__int64 *v14; // r10
__int64 *v15; // r11
unsigned __int64 v16; // r15
__int64 v17; // r12
__int64 v18; // r13
__int64 v19; // r12
bool v20; // zf
if ( *(_QWORD *)(a1 + 16) << 6 < (unsigned __int64)a2 )
{
if ( a2 < 0 )
sub_1000DFC60(a1);
v3 = (unsigned __int64)(a2 - 1) >> 6;
v4 = 8 * v3 + 8;
v5 = v3 + 1;
v6 = (__int64 *)operator new(v4);
v7 = *(_QWORD *)(a1 + 8);
v8 = 0;
if ( v7 >= 0x41 )
v8 = (v7 - 1) >> 6;
v9 = *(__int64 **)a1;
v10 = *(_QWORD *)(a1 + 8) & 0x3FLL;
v6[v8] = 0;
if ( (v7 & 0x3F) != 0 || v7 >= 0x40 )
{
v11 = &v9[v7 >> 6];
v12 = v6;
v13 = 0;
v14 = v9;
v15 = v9;
v16 = 0;
do
{
v17 = 1LL << v13;
v18 = *v15;
if ( _bittest64(&v18, v16) )
v19 = *v12 | v17;
else
v19 = *v12 & ~v17;
v20 = (_DWORD)v16 == 63;
if ( (_DWORD)v16 == 63 )
v14 = ++v15;
v16 = (unsigned int)(v16 + 1);
if ( v20 )
v16 = 0;
*v12 = v19;
v20 = v13++ == 63;
v12 += v20;
if ( v20 )
{
v15 = v14;
v13 = 0;
}
}
while ( (_DWORD)v16 != (_DWORD)v10 || v15 != v11 );
}
*(_QWORD *)a1 = v6;
*(_QWORD *)(a1 + 16) = v5;
if ( v9 )
operator delete(v9);
}
}