//
// sub_180015650 from 0x180015650 to 0x180015819 (457 bytes)
//
// 5 xrefs:
// > sub_180015B40 @ 0x180015c7c
// > ??> @ 0x18017f06c
// > ??> @ 0x18017f0a8
// > ??> @ 0x18017f0cc
// > ??> @ 0x1801f7050
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall sub_180015650(__int64 a1, unsigned int *a2, __int64 a3)
{
__int64 result; // rax
unsigned int v6; // ecx
int v7; // ecx
signed int v8; // ebp
__int64 v9; // r14
__int64 v10; // rbx
unsigned __int64 v11; // rax
_BYTE *v12; // rbx
__int64 (__fastcall **v13)(__int64, __int64, _BYTE *, __int64, int, int, _DWORD); // rdi
int v14; // eax
_BYTE v15[4096]; // [rsp+40h] [rbp-1038h] BYREF
result = *a2;
if ( (_DWORD)result )
{
if ( (_DWORD)result == 4 )
{
v8 = 0;
if ( (int)a2[8] > 0 )
{
v9 = 0;
do
{
v10 = *((_QWORD *)a2 + 5);
result = *(unsigned int *)(v10 + v9);
if ( (unsigned int)result <= 0xFFF )
{
memmove(v15, *(const void **)(v10 + v9 + 8), (unsigned int)result);
v11 = *(unsigned int *)(v10 + v9);
if ( v11 >= 0x1000 )
_report_rangecheckfailure();
v15[v11] = 0;
v12 = v15;
do
{
if ( *v12 == 61 )
break;
++v12;
}
while ( v12 );
v13 = *(__int64 (__fastcall ***)(__int64, __int64, _BYTE *, __int64, int, int, _DWORD))(a3 + 16);
*v12 = 0;
v14 = sub_1800B7F50(v12 + 1);
result = (*v13)(a3, 3, v15, (__int64)(v12 + 1), v14 + 1, 6, 0);
}
++v8;
v9 += 16;
}
while ( v8 < (int)a2[8] );
}
}
}
else
{
v6 = a2[10];
result = *(_QWORD *)(a3 + 8);
switch ( v6 )
{
case 8u:
*(_DWORD *)(result + 8) = 1;
break;
case 0x10u:
*(_DWORD *)(result + 8) = 2;
break;
case 0x18u:
*(_DWORD *)(result + 8) = 3;
break;
case 0x20u:
*(_DWORD *)(result + 8) = 4;
break;
default:
return result;
}
*(_DWORD *)(*(_QWORD *)(a3 + 8) + 12LL) = a2[9];
*(_DWORD *)(*(_QWORD *)(a3 + 8) + 16LL) = a2[8];
v7 = -1;
if ( *((_QWORD *)a2 + 6) )
v7 = *((_QWORD *)a2 + 6);
result = *(_QWORD *)(a3 + 8);
*(_DWORD *)(result + 24) = v7;
}
return result;
}