//
// sub_1004356F0 from 0x1004356f0 to 0x100435830 (320 bytes)
//
// 2 xrefs:
// > sub_10047A668 @ 0x10047a81c
// > sub_10047A668 @ 0x10047a844
//
// 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 11:05:08 +0000
//
void __fastcall sub_1004356F0(__int64 a1, int a2, unsigned int a3, char a4)
{
unsigned int *v4; // x8
unsigned int *v5; // x20
unsigned int *v7; // x9
unsigned int *v8; // x10
__int64 v10; // x9
__int64 v11; // x10
_QWORD *v12; // x11
int v13; // w12
int v14; // w12
signed __int64 v15; // x21
__int64 v16; // [xsp+0h] [xbp-40h] BYREF
__int64 *v17; // [xsp+8h] [xbp-38h] BYREF
_QWORD *v18[2]; // [xsp+10h] [xbp-30h] BYREF
v4 = *(unsigned int **)(a1 + 1848);
v5 = *(unsigned int **)(a1 + 1840);
if ( v5 != v4 )
{
v7 = *(unsigned int **)(a1 + 1840);
while ( 1 )
{
if ( (a4 & 1) != 0 )
{
if ( *v7 != a2 )
goto LABEL_12;
v8 = v7;
if ( v7[2] == a3 )
goto LABEL_12;
}
else
{
v8 = v7 + 2;
if ( v7[2] != a2 || *v7 == a3 )
goto LABEL_12;
}
*v8 = a3;
LABEL_12:
v7 += 4;
if ( v7 == v4 )
{
v18[0] = nullptr;
v18[1] = nullptr;
v17 = (__int64 *)v18;
while ( 1 )
{
v10 = *v5;
v11 = v5[2];
v16 = v10 | (v11 << 32);
v12 = v18[0];
if ( !v18[0] )
{
LABEL_21:
sub_10001C658(&v17, (__int64)&v16, &v16);
v5 += 4;
v4 = *(unsigned int **)(a1 + 1848);
goto LABEL_22;
}
while ( 1 )
{
v13 = *((_DWORD *)v12 + 7);
if ( (int)v10 >= v13 )
{
if ( v13 < (int)v10 )
goto LABEL_19;
v14 = *((_DWORD *)v12 + 8);
if ( (int)v11 >= v14 )
break;
}
LABEL_20:
v12 = (_QWORD *)*v12;
if ( !v12 )
goto LABEL_21;
}
if ( v14 < (int)v11 )
{
LABEL_19:
++v12;
goto LABEL_20;
}
v15 = (char *)v4 - (char *)(v5 + 4);
if ( v4 != v5 + 4 )
memmove(v5, v5 + 4, (char *)v4 - (char *)(v5 + 4));
v4 = (unsigned int *)((char *)v5 + v15);
*(_QWORD *)(a1 + 1848) = (char *)v5 + v15;
LABEL_22:
if ( v5 == v4 )
{
sub_1000187C4((__int64)&v17, v18[0]);
return;
}
}
}
}
}
}