//
// sub_100470AE8 from 0x100470ae8 to 0x100470c10 (296 bytes)
//
// 1 xrefs:
// > sub_10046F80C @ 0x10046fcec
//
// 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_100470AE8(__int64 a1, __int64 a2, char *a3, _DWORD *a4)
{
__int64 v7; // x9
__int64 v8; // x10
__int64 v9; // x8
__int64 v10; // x22
__int64 result; // x0
int v12; // w8
__int64 v13; // x9
_OWORD *v14; // x8
__int64 v15; // x9
char v16; // t1
v7 = 36;
v8 = 21;
if ( *(unsigned __int8 *)(a2 + 3) > 0xBFu )
{
v7 = 21;
v8 = 13;
}
if ( (*(_BYTE *)(a2 + 1) & 8) != 0 )
v9 = v7;
else
v9 = v8;
v10 = a2 + v9;
if ( (unsigned int)sub_1004C6FE8(a2 + v9, "Xing", 4) )
return 19;
v12 = *(unsigned __int8 *)(v10 + 7);
if ( (v12 & 1) != 0 )
{
v13 = v10 + 12;
if ( a4 )
{
*a4 = bswap32(*(_DWORD *)(v10 + 8));
*(_BYTE *)(a1 + 572) = 1;
}
}
else
{
v13 = v10 + 8;
}
result = 0;
if ( a3 && (v12 & 4) != 0 )
{
v14 = (_OWORD *)(v13 + ((2 * v12) & 4LL));
if ( (unsigned __int64)(a3 - (char *)v14) >= 0x10 )
{
*(_OWORD *)a3 = *v14;
*((_OWORD *)a3 + 1) = v14[1];
*((_OWORD *)a3 + 2) = v14[2];
*((_OWORD *)a3 + 3) = v14[3];
*((_OWORD *)a3 + 4) = v14[4];
*((_OWORD *)a3 + 5) = v14[5];
v14 += 6;
v15 = 96;
}
else
{
v15 = 0;
}
do
{
v16 = *(_BYTE *)v14;
v14 = (_OWORD *)((char *)v14 + 1);
a3[v15++] = v16;
}
while ( v15 != 100 );
*(_BYTE *)(a1 + 573) = 1;
return 0;
}
return result;
}