//
// sub_10066BE20 from 0x10066be20 to 0x10066bf0c (236 bytes)
//
// 1 xrefs:
// > sub_10066BAC0 @ 0x10066bd4f
//
// 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:35:01 +0000
//
_QWORD *__fastcall sub_10066BE20(__int64 **a1, __int64 a2)
{
_QWORD *v3; // r14
_QWORD *v4; // rdi
__int64 *v5; // rsi
int v6; // ecx
_QWORD *v7; // rdi
__int64 *v8; // rax
int v9; // esi
__int64 *v10; // rax
v3 = operator new(0x40u);
v3[4] = *(_QWORD *)a2;
v4 = v3 + 5;
if ( (*(_BYTE *)(a2 + 8) & 1) != 0 )
{
sub_10001AD30(v4, *(const void **)(a2 + 24), *(_QWORD *)(a2 + 16));
}
else
{
v3[7] = *(_QWORD *)(a2 + 24);
*(_OWORD *)v4 = *(_OWORD *)(a2 + 8);
}
v5 = a1[1];
if ( v5 )
{
v6 = *((_DWORD *)v3 + 8);
do
{
while ( 1 )
{
v8 = v5;
v9 = *((_DWORD *)v5 + 8);
if ( v6 >= v9 && (v6 > v9 || *((_DWORD *)v3 + 9) >= *((_DWORD *)v8 + 9)) )
break;
v5 = (__int64 *)*v8;
v7 = v8;
if ( !*v8 )
goto LABEL_13;
}
v5 = (__int64 *)v8[1];
}
while ( v5 );
v7 = v8 + 1;
}
else
{
v8 = (__int64 *)(a1 + 1);
v7 = a1 + 1;
}
LABEL_13:
*(_OWORD *)v3 = 0;
v3[2] = v8;
*v7 = v3;
v10 = (__int64 *)**a1;
if ( v10 )
*a1 = v10;
sub_10001B680(a1[1], v3);
a1[2] = (__int64 *)((char *)a1[2] + 1);
return v3;
}