//
// sub_18002FA30 from 0x18002fa30 to 0x18002fb82 (338 bytes)
//
// 3 xrefs:
// > sub_180031D30 @ 0x180031f17
// > sub_180031D30 @ 0x180031f8d
// > ??> @ 0x1801f78fc
//
// 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_18002FA30(__int64 a1, _DWORD *a2, unsigned int *a3, int a4, _DWORD *a5)
{
unsigned __int64 v7; // rax
unsigned int v8; // r14d
bool v9; // zf
__int64 v10; // rax
__int64 v11; // r15
_BYTE *v12; // rdi
int v13; // eax
char v14; // bp
int v15; // ebp
int v16; // esi
int v17; // ecx
int v19; // [rsp+68h] [rbp+20h]
*a5 = 0;
v7 = a3[3];
if ( a4 )
v8 = dword_1801C5390[v7 >> 1];
else
v8 = dword_1801C4B90[v7];
v9 = a3[4] == 2;
a3[19] = (v8 >> 15) & 1;
v10 = 0;
v19 = 0;
if ( v9 )
{
v10 = 1;
if ( a3[5] )
v10 = 2;
v19 = v10;
}
v11 = 4;
v12 = (_BYTE *)(0x180000000LL + 4 * (((v8 >> 12) & 7) + 6 * v10) + 1752208);
do
{
LOBYTE(v13) = *v12;
v14 = v8;
v8 >>= 3;
v15 = v14 & 7;
if ( v15 )
{
v16 = 0;
if ( (_BYTE)v13 )
{
do
{
*a2 = sub_18002B9C0(a1, v15);
++v16;
v13 = (unsigned __int8)*v12;
++a2;
}
while ( v16 < v13 );
}
*a5 += v15 * (unsigned __int8)v13;
}
else
{
v17 = 0;
if ( (_BYTE)v13 )
{
do
{
*a2 = 0;
++v17;
++a2;
}
while ( v17 < (unsigned __int8)*v12 );
}
}
++v12;
--v11;
}
while ( v11 );
memset(a2, 0, 4LL * (unsigned int)(2 * v19 + 1));
return 0;
}