//
// sub_10065C16C from 0x10065c16c to 0x10065c83c (1744 bytes)
//
// 6 xrefs:
// > sub_10065BA8C @ 0x10065bee0
// > sub_10065BA8C @ 0x10065bf5c
// > sub_10065C83C @ 0x10065c968
// > sub_10065D0BC @ 0x10065d250
// > sub_10065D610 @ 0x10065d694
// > sub_10065D6CC @ 0x10065d870
//
// 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:56 +0000
//
__int64 __fastcall sub_10065C16C(
__int64 a1,
__int64 a2,
int a3,
__int64 a4,
int a5,
__int64 a6,
int a7,
__int64 a8,
int a9,
__int64 a10,
int a11,
int8x16_t *a12,
int8x16_t *a13,
int a14)
{
int v18; // w28
__int64 v19; // x26
int v20; // w0
__int64 v21; // x26
int v22; // w8
int v23; // w9
__int64 v24; // x10
char v27; // w28
__int64 v28; // x20
int v29; // w19
__int64 v30; // x27
int v31; // w22
int8x16_t *v32; // x20
__int64 v33; // x8
unsigned __int64 v34; // x10
int8x16_t *v35; // x11
int8x16_t *v36; // x12
int8x16_t v37; // q0
int8x16_t v38; // t1
int8x16_t v39; // q1
int v40; // w9
__int8 *v41; // x10
__int8 *v42; // x8
char v43; // t1
__int64 v44; // [xsp+10h] [xbp-1E0h]
__int64 v45; // [xsp+18h] [xbp-1D8h]
__int64 v46; // [xsp+20h] [xbp-1D0h]
char *v47; // [xsp+28h] [xbp-1C8h]
unsigned __int64 v48; // [xsp+38h] [xbp-1B8h]
__int64 v50; // [xsp+48h] [xbp-1A8h]
unsigned __int64 v51; // [xsp+58h] [xbp-198h]
__int64 v55; // [xsp+98h] [xbp-158h]
unsigned int v56; // [xsp+A0h] [xbp-150h]
__int64 v57; // [xsp+A8h] [xbp-148h] BYREF
__int64 v58; // [xsp+B0h] [xbp-140h] BYREF
__int64 v59; // [xsp+B8h] [xbp-138h] BYREF
_BYTE v60[48]; // [xsp+C0h] [xbp-130h] BYREF
_BYTE v61[48]; // [xsp+F0h] [xbp-100h] BYREF
_BYTE v62[48]; // [xsp+120h] [xbp-D0h] BYREF
__int64 v63; // [xsp+150h] [xbp-A0h] BYREF
_BYTE __src[64]; // [xsp+158h] [xbp-98h] BYREF
if ( !(unsigned int)sub_100669BCC(0, &v58, &v57) )
goto LABEL_11;
v18 = 0;
v19 = 1;
do
{
if ( (a1 & (v58 << 10)) != 0 )
++v18;
v20 = sub_100669BCC(v19, &v58, &v57);
v19 = (unsigned int)(v19 + 1);
}
while ( v20 );
if ( !v18 )
{
LABEL_11:
sub_100706FB0(20, 284, 68, "t1_enc.c", 265);
return 0;
}
bzero(a12, a14);
if ( !(unsigned int)sub_100669BCC(0, &v58, &v57) )
return 1;
LODWORD(v21) = 0;
v22 = a11 / v18;
v23 = a11 & 1;
v46 = a3;
v45 = a5;
v44 = a7;
v24 = (unsigned int)(a14 - 1);
if ( v18 == 1 )
v23 = 0;
v50 = v24 + 1;
v47 = &a12->i8[v24];
v48 = (unsigned __int64)a13->u64 + v24;
v56 = v22 + v23;
v55 = v22;
v51 = (v24 + 1) & 0xFFFFFFFFFFFFFFE0LL;
while ( (a1 & (v58 << 10)) == 0 )
{
LABEL_97:
v21 = (unsigned int)(v21 + 1);
if ( !(unsigned int)sub_100669BCC(v21, &v58, &v57) )
return 1;
}
v28 = v57;
if ( !v57 )
{
sub_100706FB0(20, 284, 326, "t1_enc.c", 276);
return 0;
}
v29 = sub_100711410(v57);
if ( v29 < 0 )
sub_1006AE64C((char)"t1_enc.c");
sub_100708F5C(v62);
sub_100708F5C(v61);
sub_100708F5C(v60);
sub_100711464(v60, 8);
v30 = sub_1007133B4(855, 0, a10, v56);
if ( v30 )
{
if ( (unsigned int)sub_10071348C(v60, 0, v28, 0, v30) )
{
if ( (unsigned int)sub_1007093D4(v62, v60) )
{
if ( a2 && !(unsigned int)sub_1007091A4(v62, a2, v46) )
{
v27 = 1;
}
else if ( a4 && !(unsigned int)sub_1007091A4(v62, a4, v45) )
{
v27 = 1;
}
else if ( a6 && !(unsigned int)sub_1007091A4(v62, a6, v44) )
{
v27 = 1;
}
else if ( a8 && !(unsigned int)sub_1007091A4(v62, a8, a9) )
{
v27 = 1;
}
else if ( (unsigned int)sub_100713660(v62, __src, &v59) )
{
v31 = a14;
v32 = a13;
if ( a2 )
{
while ( 1 )
{
if ( !(unsigned int)sub_1007093D4(v62, v60) )
{
v27 = 1;
goto LABEL_85;
}
if ( !(unsigned int)sub_1007091A4(v62, __src, v59) )
{
v27 = 1;
goto LABEL_85;
}
if ( v31 > v29 && !(unsigned int)sub_1007093D4(v61, v62) )
break;
if ( !(unsigned int)sub_1007091A4(v62, a2, v46) )
{
v27 = 1;
goto LABEL_85;
}
if ( a4 && !(unsigned int)sub_1007091A4(v62, a4, v45) )
{
v27 = 1;
goto LABEL_85;
}
if ( a6 && !(unsigned int)sub_1007091A4(v62, a6, v44) )
{
v27 = 1;
goto LABEL_85;
}
if ( a8 && !(unsigned int)sub_1007091A4(v62, a8, a9) )
{
v27 = 1;
goto LABEL_85;
}
if ( v31 <= v29 )
goto LABEL_13;
if ( !(unsigned int)sub_100713660(v62, v32, &v63) )
{
v27 = 1;
goto LABEL_85;
}
v32 = (int8x16_t *)((char *)v32 + v63);
v31 -= v63;
v27 = 1;
if ( !(unsigned int)sub_100713660(v61, __src, &v59) )
goto LABEL_85;
}
v27 = 1;
}
else
{
while ( 1 )
{
if ( !(unsigned int)sub_1007093D4(v62, v60) )
{
v27 = 1;
goto LABEL_85;
}
if ( !(unsigned int)sub_1007091A4(v62, __src, v59) )
{
v27 = 1;
goto LABEL_85;
}
if ( v31 > v29 && !(unsigned int)sub_1007093D4(v61, v62) )
{
v27 = 1;
goto LABEL_85;
}
if ( a4 && !(unsigned int)sub_1007091A4(v62, a4, v45) )
{
v27 = 1;
goto LABEL_85;
}
if ( a6 && !(unsigned int)sub_1007091A4(v62, a6, v44) )
{
v27 = 1;
goto LABEL_85;
}
if ( a8 && !(unsigned int)sub_1007091A4(v62, a8, a9) )
{
v27 = 1;
goto LABEL_85;
}
if ( v31 <= v29 )
break;
if ( !(unsigned int)sub_100713660(v62, v32, &v63) )
{
v27 = 1;
goto LABEL_85;
}
v32 = (int8x16_t *)((char *)v32 + v63);
v31 -= v63;
v27 = 1;
if ( !(unsigned int)sub_100713660(v61, __src, &v59) )
goto LABEL_85;
}
LABEL_13:
if ( (unsigned int)sub_100713660(v62, __src, &v59) )
{
memcpy(v32, __src, v31);
v27 = 0;
}
else
{
v27 = 1;
}
}
}
else
{
v27 = 1;
}
}
else
{
v27 = 1;
}
}
else
{
v27 = 1;
}
}
else
{
v27 = 1;
}
LABEL_85:
sub_10070FBF4(v30);
sub_10070930C(v62);
sub_10070930C(v61);
sub_10070930C(v60);
sub_1006B0510((int)__src, 0x40u);
if ( (v27 & 1) == 0 )
{
a10 += v55;
if ( a14 >= 1 )
{
v33 = v50 & 0x1FFFFFFE0LL;
if ( (v50 & 0x1FFFFFFE0LL) != 0 )
{
v34 = v51;
v35 = a13 + 1;
v36 = a12 + 1;
if ( v48 < (unsigned __int64)a12 || (v34 = v51, v35 = a13 + 1, v36 = a12 + 1, v47 < (char *)a13) )
{
do
{
v37 = v35[-1];
v38 = *v35;
v35 += 2;
v39 = veorq_s8(*v36, v38);
v36[-1] = veorq_s8(v36[-1], v37);
*v36 = v39;
v36 += 2;
v34 -= 32LL;
}
while ( v34 );
}
else
{
v33 = 0;
}
}
else
{
v33 = 0;
}
if ( (unsigned int)(a14 - 1) + 1LL != v33 )
{
v40 = a14 - v33;
v41 = &a13->i8[v33];
v42 = &a12->i8[v33];
do
{
v43 = *v41++;
*v42++ ^= v43;
--v40;
}
while ( v40 );
}
}
goto LABEL_97;
}
return 0;
}