//
// sub_100479448 from 0x100479448 to 0x1004796b8 (624 bytes)
//
// 1 xrefs:
// > sub_100478EB0 @ 0x100478eb0
//
// 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_100479448(__int64 a1, char *a2, unsigned __int64 a3, unsigned int *a4)
{
char *v5; // x22
int v7; // w9
int v8; // w0
unsigned int v9; // w21
int v10; // w8
char *v12; // x8
__int16 v13; // w9
__int16 v14; // w11
int8x8_t v15; // d0
char *v17; // x8
__int16 v18; // w9
__int16 v19; // w11
__int16 v20; // w12
__int16 v21; // w13
__int64 v22; // x0
__int64 v23; // x22
int v24; // w8
__int64 v25; // x25
const char *v26; // x24
void (__fastcall *v27)(__int64, __int64, const char *, unsigned __int8 *, _QWORD, __int64, __int64); // x27
int v28; // w0
_BYTE *v29; // x8
unsigned __int8 *v30; // x23
int v31; // w9
__int64 v32; // x9
unsigned int v33; // w8
int v34; // w9
v5 = a2;
v7 = *(_DWORD *)(*(_QWORD *)(a1 + 8) + 8LL) - 1;
if ( (unsigned int)v7 <= 4 )
a3 = (qword_10064A0E0[v7] * (unsigned __int64)(unsigned int)a3) >> 3;
v8 = sub_1004EE434(a1, a1 + 376, a2, (unsigned int)(a3 * *(_DWORD *)(*(_QWORD *)(a1 + 8) + 12LL)), 0, 2, 1, 0);
v9 = v8;
if ( v8 <= 0 )
{
if ( v8 != -3 )
{
if ( v8 == -131 )
return 31;
if ( v8 == -139 )
return 38;
return 16;
}
v9 = 0;
}
v10 = *(_DWORD *)(*(_QWORD *)(a1 + 8) + 12LL);
if ( v10 == 6 )
{
if ( v9 )
{
v17 = &v5[v9];
do
{
v18 = *((_WORD *)v5 + 1);
v19 = *((_WORD *)v5 + 3);
v20 = *((_WORD *)v5 + 4);
v21 = *((_WORD *)v5 + 5);
*((_WORD *)v5 + 1) = *((_WORD *)v5 + 2);
*((_WORD *)v5 + 2) = v18;
*((_WORD *)v5 + 3) = v21;
*((_WORD *)v5 + 4) = v19;
*((_WORD *)v5 + 5) = v20;
v5 += 12;
}
while ( v5 < v17 );
}
}
else if ( v10 == 8 && v9 != 0 )
{
v12 = &v5[v9];
do
{
v13 = *((_WORD *)v5 + 1);
v14 = *((_WORD *)v5 + 7);
*((_WORD *)v5 + 1) = *((_WORD *)v5 + 2);
*((_WORD *)v5 + 2) = v13;
v15 = *(int8x8_t *)(v5 + 6);
*((_WORD *)v5 + 3) = v14;
*((int8x8_t *)v5 + 1) = vext_s8(v15, v15, 4u);
v5 += 16;
}
while ( v5 < v12 );
}
v22 = sub_1004EE03C(a1 + 376, 0xFFFFFFFFLL);
if ( v22 )
{
v23 = v22;
v24 = *(_DWORD *)(v22 + 16);
if ( v24 )
{
if ( v24 >= 1 )
{
v25 = 0;
do
{
v29 = *(_BYTE **)(*(_QWORD *)v23 + 8 * v25);
v30 = v29 + 1;
v31 = (unsigned __int8)*v29;
if ( *v29 )
{
while ( v31 != 61 )
{
v31 = *v30++;
if ( !*(v30 - 1) )
goto LABEL_28;
}
*(v30 - 1) = 0;
v26 = v29;
}
else
{
LABEL_28:
v26 = "NONAME";
v30 = *(unsigned __int8 **)(*(_QWORD *)v23 + 8 * v25);
}
v27 = **(void (__fastcall ***)(__int64, __int64, const char *, unsigned __int8 *, _QWORD, __int64, __int64))(a1 + 16);
v28 = sub_1004C6AA0(v30);
v27(a1, 3, v26, v30, (unsigned int)(v28 + 1), 6, 1);
++v25;
}
while ( v25 < *(int *)(v23 + 16) );
}
sub_1004DA59C(a1, v23);
}
}
if ( !a4 )
return 0;
v32 = *(_QWORD *)(a1 + 8);
v33 = *(_DWORD *)(v32 + 12);
if ( !v33 )
return 0;
v34 = *(_DWORD *)(v32 + 8) - 1;
if ( (unsigned int)v34 <= 4 )
v9 = (unsigned int)(8 * (unsigned __int64)v9 / qword_10064A0E0[v34]) / v33;
*a4 = v9;
return 0;
}