//
// sub_10065AFAC from 0x10065afac to 0x10065b140 (404 bytes)
//
// 3 xrefs:
// > sub_10064D160 @ 0x10064d500
// > sub_10064DCB8 @ 0x10064e080
// > sub_10065AD98 @ 0x10065adf4
//
// 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:10:55 +0000
//
__int64 __fastcall sub_10065AFAC(_QWORD *a1, __int64 a2, unsigned __int64 a3, int a4)
{
char *v8; // x0
char *v9; // x21
unsigned __int64 i; // x8
int v11; // w11
int *v12; // x10
int v13; // w11
__int64 v14; // x12
int v15; // w10
__int64 v16; // x12
int v17; // w10
char *v19; // x12
void *v20; // x0
void *v22; // x0
if ( (a3 & 1) != 0 )
return 0;
v8 = (char *)sub_1006AE878(a3, "t1_lib.c", 4057);
v9 = v8;
if ( !v8 )
return 0;
if ( a3 )
{
for ( i = 0; i < a3; i += 2LL )
{
v12 = (int *)(a2 + 4 * i);
v13 = *v12;
if ( dword_1009E3A3C == *v12 )
{
v14 = 0;
}
else
{
v14 = 1;
if ( dword_1009E3A44 != v13 )
{
v14 = 2;
if ( dword_1009E3A4C != v13 )
{
v14 = 3;
if ( dword_1009E3A54 != v13 )
{
v14 = 4;
if ( dword_1009E3A5C != v13 )
{
v14 = 5;
if ( dword_1009E3A64 != v13 )
{
v11 = -1;
goto LABEL_14;
}
}
}
}
}
}
v11 = *((_DWORD *)&unk_1009E3A00 + 2 * v14 + 16);
LABEL_14:
v15 = v12[1];
if ( dword_1009E3A04 == v15 )
{
v16 = 0;
}
else
{
v16 = 1;
if ( dword_1009E3A0C != v15 )
{
v16 = 2;
if ( dword_1009E3A14 != v15 )
goto LABEL_27;
}
}
v17 = *((_DWORD *)&unk_1009E3A00 + 2 * v16 + 2);
if ( v11 == -1 || v17 == -1 )
{
LABEL_27:
sub_1006AEDAC(v8);
return 0;
}
v19 = &v8[i];
*v19 = v11;
v19[1] = v17;
}
}
if ( a4 )
{
v20 = (void *)a1[76];
if ( v20 )
sub_1006AEDAC(v20);
a1[76] = v9;
a1[77] = a3;
return 1;
}
else
{
v22 = (void *)a1[74];
if ( v22 )
sub_1006AEDAC(v22);
a1[74] = v9;
a1[75] = a3;
return 1;
}
}