//
// sub_180047260 from 0x180047260 to 0x1800474bd (605 bytes)
//
// 2 xrefs:
// > sub_180046ED0 @ 0x180047168
// > ??> @ 0x1801f8274
//
// 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_180047260(__int64 a1, __int64 a2, unsigned int a3, unsigned int a4, unsigned int a5, int a6)
{
__int64 v6; // rbp
unsigned int v7; // edi
__int64 v8; // r13
__int64 v12; // r14
_DWORD *v13; // rbx
__int64 v14; // rax
unsigned int v16; // edx
int v17; // [rsp+88h] [rbp+10h] BYREF
unsigned int v18; // [rsp+90h] [rbp+18h] BYREF
v6 = a5;
v7 = 0;
v8 = a3;
v12 = *(_QWORD *)(a2 + 8) + 320LL * a3;
*(_DWORD *)(v12 + 1408) = 2;
*(_QWORD *)(v12 + 1464) = *(_QWORD *)(*(_QWORD *)(a2 + 8) + 8LL * a3 + 192);
*(_DWORD *)(v12 + 1440) = v6;
if ( (_DWORD)v6 )
{
v13 = (_DWORD *)(v12 + 1444);
while ( (unsigned int)sub_180041CD0(a1, *(_QWORD *)(*(_QWORD *)(a2 + 8) + 120LL), &v17, a4) )
{
++v7;
*v13++ = v17;
if ( v7 >= (unsigned int)v6 )
goto LABEL_5;
}
return 0;
}
LABEL_5:
if ( !(unsigned int)sub_180041D20(a1, *(_QWORD *)(*(_QWORD *)(a2 + 8) + 120LL), &v18, 2u) )
return 0;
*(_DWORD *)(v12 + 1416) = v18;
if ( v18 >= 2 )
{
v14 = *(_QWORD *)(a2 + 8);
if ( *(_DWORD *)(v14 + 4112) )
++*(_DWORD *)(v14 + 6864);
else
(*(void (__fastcall **)(__int64, __int64, _QWORD))(v14 + 56))(a2, 3, *(_QWORD *)(v14 + 104));
**(_DWORD **)a2 = 2;
return 1;
}
if ( !(unsigned int)sub_180041D20(a1, *(_QWORD *)(*(_QWORD *)(a2 + 8) + 120LL), &v18, 4u) )
return 0;
v16 = *(_DWORD *)(v12 + 1416);
*(_DWORD *)(v12 + 1424) = v18;
*(_QWORD *)(v12 + 1432) = 24 * v8 + *(_QWORD *)(a2 + 8) + 256LL;
if ( v16 <= 1
&& !(unsigned int)sub_180046C10(
a1,
a2,
v6,
*(_DWORD *)(v12 + 1424),
(_QWORD *)(24 * v8 + *(_QWORD *)(a2 + 8) + 256LL),
*(_QWORD *)(*(_QWORD *)(a2 + 8) + 8 * v8 + 192),
v16 == 1) )
{
return 0;
}
if ( a6 )
{
memmove(*(void **)(*(_QWORD *)(a2 + 8) + 8 * v8 + 128), (const void *)(v12 + 1444), 4 * v6);
sub_180042C70(
*(char **)(*(_QWORD *)(a2 + 8) + 8 * v8 + 192),
*(_DWORD *)(*(_QWORD *)(a2 + 8) + 1368LL) - v6,
v6,
(char *)(4 * v6 + *(_QWORD *)(*(_QWORD *)(a2 + 8) + 8 * v8 + 128)));
}
return 1;
}