//
// sub_F004C0 from 0xf004c0 to 0xf00940 (1152 bytes)
//
// 1 xrefs:
// > sub_F0165C @ 0xf016a8
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:12:19 +0000
//
unsigned __int64 __fastcall sub_F004C0(unsigned __int64 result)
{
int v1; // w1
unsigned int *v2; // x5
__int64 v3; // x10
int v4; // w4
unsigned __int64 v5; // x6
unsigned __int64 v6; // x7
unsigned __int64 v7; // x1
int v8; // w10
int v9; // w7
unsigned int v10; // w3
int32x4_t v11; // q0
int v12; // w9
unsigned int *v13; // x2
unsigned int v14; // w8
int8x16_t *v15; // x1
uint32x4_t v16; // q3
uint32x2_t *v17; // x11
uint32x4_t v18; // q4
uint32x2_t *v19; // x12
int v20; // w1
int v21; // w7
int v22; // w1
unsigned __int64 v23; // x7
__int64 v24; // x3
__int64 v25; // x2
v1 = *(_DWORD *)(result + 24);
v2 = *(unsigned int **)(result + 72);
v3 = *(_QWORD *)(result + 88);
v4 = *(_DWORD *)(result + 52) * *(_DWORD *)(result + 8);
v5 = *(_QWORD *)(result + 96);
if ( v1 )
{
v23 = ((unsigned __int64)(unsigned int)-v1 << 32) / *(int *)(result + 32);
if ( v4 > 0 )
{
v24 = 0;
do
{
*((_BYTE *)v2 + v24) = (((*(unsigned int *)(v3 + 4 * v24) * (unsigned __int64)(unsigned int)v23
+ *(unsigned int *)(v5 + 4 * v24) * (unsigned __int64)(unsigned int)-(int)v23
+ 0x80000000) >> 32)
* *(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
++v24;
}
while ( v4 > (int)v24 );
}
}
else if ( v4 > 0 )
{
v6 = (unsigned __int64)v2 + v4;
if ( (unsigned int)v4 > 0x12
&& (v6 <= result + 16 || (unsigned __int64)v2 >= result + 20)
&& ((unsigned __int64)v2 >= v5 + 4LL * v4 || v5 >= v6) )
{
v7 = -((v5 >> 2) & 3) & 3;
if ( (unsigned int)v7 > v4 )
v7 = (unsigned int)(*(_DWORD *)(result + 52) * *(_DWORD *)(result + 8));
if ( (_DWORD)v7 )
{
*(_BYTE *)v2 = (*(unsigned int *)v5 * (unsigned __int64)*(unsigned int *)(result + 16) + 0x80000000) >> 32;
if ( (_DWORD)v7 == 1 )
{
v8 = 1;
}
else
{
*((_BYTE *)v2 + 1) = (*(unsigned int *)(v5 + 4) * (unsigned __int64)*(unsigned int *)(result + 16) + 0x80000000) >> 32;
if ( (_DWORD)v7 == 3 )
{
v8 = 3;
*((_BYTE *)v2 + 2) = (*(unsigned int *)(v5 + 8) * (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
}
else
{
v8 = 2;
}
}
}
else
{
v8 = 0;
}
v9 = v4 - v7;
v10 = ((unsigned int)(v4 - v7 - 16) >> 4) + 1;
v11 = vdupq_n_s32(*(_DWORD *)(result + 16));
v12 = 16 * v10;
v13 = (unsigned int *)(v5 + 4 * v7);
v14 = 0;
v15 = (int8x16_t *)((char *)v2 + v7);
do
{
v16 = *((uint32x4_t *)v13 + 2);
v17 = (uint32x2_t *)(v13 + 4);
v18 = *(uint32x4_t *)v13;
v19 = (uint32x2_t *)(v13 + 12);
++v14;
v13 += 16;
*v15++ = vmovn_hight_s16(
vmovn_s16(
vmovn_hight_s32(
vmovn_s32(
vmovn_hight_s64(
vmovn_s64(
vshrq_n_u64(
vmlal_u32(
(uint64x2_t)xmmword_F00940,
(uint32x2_t)v18.n128_u64[0],
(uint32x2_t)v11.n128_u64[0]),
0x20u)),
vshrq_n_u64(vmlal_high_u32((uint64x2_t)xmmword_F00940, v18, v11), 0x20u))),
vmovn_hight_s64(
vmovn_s64(
vshrq_n_u64(
vmlal_u32(
(uint64x2_t)xmmword_F00940,
(uint32x2_t)v17->n64_u64[0],
(uint32x2_t)v11.n128_u64[0]),
0x20u)),
vshrq_n_u64(
vmlal_high_u32((uint64x2_t)xmmword_F00940, *(uint32x4_t *)v17->n64_u64, v11),
0x20u)))),
vmovn_hight_s32(
vmovn_s32(
vmovn_hight_s64(
vmovn_s64(
vshrq_n_u64(
vmlal_u32(
(uint64x2_t)xmmword_F00940,
(uint32x2_t)v16.n128_u64[0],
(uint32x2_t)v11.n128_u64[0]),
0x20u)),
vshrq_n_u64(vmlal_high_u32((uint64x2_t)xmmword_F00940, v16, v11), 0x20u))),
vmovn_hight_s64(
vmovn_s64(
vshrq_n_u64(
vmlal_u32(
(uint64x2_t)xmmword_F00940,
(uint32x2_t)v19->n64_u64[0],
(uint32x2_t)v11.n128_u64[0]),
0x20u)),
vshrq_n_u64(vmlal_high_u32((uint64x2_t)xmmword_F00940, *(uint32x4_t *)v19->n64_u64, v11), 0x20u))));
}
while ( v14 < v10 );
v20 = v8 + v12;
if ( v9 != v12 )
{
*((_BYTE *)v2 + v20) = (*(unsigned int *)(v5 + 4LL * v20) * (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
if ( v4 > v20 + 1 )
{
*((_BYTE *)v2 + v20 + 1) = (*(unsigned int *)(v5 + 4LL * (v20 + 1))
* (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
if ( v4 > v20 + 2 )
{
*((_BYTE *)v2 + v20 + 2) = (*(unsigned int *)(v5 + 4LL * (v20 + 2))
* (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
if ( v4 > v20 + 3 )
{
*((_BYTE *)v2 + v20 + 3) = (*(unsigned int *)(v5 + 4LL * (v20 + 3))
* (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
if ( v4 > v20 + 4 )
{
*((_BYTE *)v2 + v20 + 4) = (*(unsigned int *)(v5 + 4LL * (v20 + 4))
* (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
if ( v4 > v20 + 5 )
{
*((_BYTE *)v2 + v20 + 5) = (*(unsigned int *)(v5 + 4LL * (v20 + 5))
* (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
if ( v4 > v20 + 6 )
{
*((_BYTE *)v2 + v20 + 6) = (*(unsigned int *)(v5 + 4LL * (v20 + 6))
* (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
if ( v4 > v20 + 7 )
{
*((_BYTE *)v2 + v20 + 7) = (*(unsigned int *)(v5 + 4LL * (v20 + 7))
* (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
if ( v4 > v20 + 8 )
{
*((_BYTE *)v2 + v20 + 8) = (*(unsigned int *)(v5 + 4LL * (v20 + 8))
* (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
if ( v4 > v20 + 9 )
{
*((_BYTE *)v2 + v20 + 9) = (*(unsigned int *)(v5 + 4LL * (v20 + 9))
* (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
if ( v4 > v20 + 10 )
{
*((_BYTE *)v2 + v20 + 10) = (*(unsigned int *)(v5 + 4LL * (v20 + 10))
* (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
if ( v4 > v20 + 11 )
{
*((_BYTE *)v2 + v20 + 11) = (*(unsigned int *)(v5 + 4LL * (v20 + 11))
* (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
if ( v4 > v20 + 12 )
{
v21 = v20 + 13;
*((_BYTE *)v2 + v20 + 12) = (*(unsigned int *)(v5 + 4LL * (v20 + 12))
* (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
if ( v4 > v20 + 13 )
{
v22 = v20 + 14;
*((_BYTE *)v2 + v21) = (*(unsigned int *)(v5 + 4LL * v21)
* (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
if ( v4 > v22 )
{
result = (*(unsigned int *)(v5 + 4LL * v22)
* (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
*((_BYTE *)v2 + v22) = result;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
else
{
v25 = 0;
do
{
*((_BYTE *)v2 + v25) = (*(unsigned int *)(v5 + 4 * v25) * (unsigned __int64)*(unsigned int *)(result + 16)
+ 0x80000000) >> 32;
++v25;
}
while ( v4 > (int)v25 );
}
}
return result;
}