//
// sub_EC9D20 from 0xec9d20 to 0xeca0dc (956 bytes)
//
// 1 xrefs:
// > sub_ECBFEC @ 0xecc2ec
//
// 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:11:37 +0000
//
__int64 __fastcall sub_EC9D20(__int64 a1, __int16 *a2, __int64 a3)
{
__int64 result; // x0
unsigned int *v7; // x23
__int64 v8; // x21
int v9; // w20
int v10; // w0
int v11; // w20
double v12; // d8
int v13; // w0
__int64 v14; // x1
unsigned __int64 v15; // x0
__int64 v16; // x2
int8x16_t v17; // q7
int8x16_t v18; // q6
const __int16 *v19; // x6
int8x16_t *v20; // x4
unsigned __int64 v21; // x3
int8x16_t *v22; // x5
int16x8x3_t v23; // 0:q0.16,16:q1.16,32:q2.16
result = *(unsigned int *)(a1 + 4);
v7 = *(unsigned int **)(a1 + 16);
if ( (_DWORD)result )
{
if ( a3 > 0 )
{
v8 = 0;
while ( 1 )
{
v11 = *a2 << 16;
if ( !(_DWORD)result )
break;
v12 = (double)a2[1];
v9 = ((unsigned __int8)(int)((double)rand() * 4.65661288e-10 + v12 * 0.012512207 - 0.5) << 8) | v11;
if ( !*(_DWORD *)(a1 + 4) )
goto LABEL_5;
v13 = a2[2];
a2 += 3;
result = v9
| (unsigned int)(unsigned __int8)(int)((double)rand() * 4.65661288e-10 + (double)v13 * 0.012512207 - 0.5);
v7[v8++] = result;
if ( v8 == a3 )
return result;
LABEL_6:
LODWORD(result) = *(_DWORD *)(a1 + 4);
}
v9 = ((unsigned __int8)(int)((double)a2[1] * 0.012512207) << 8) | v11;
LABEL_5:
v10 = a2[2];
a2 += 3;
result = v9 | (unsigned int)(unsigned __int8)(int)((double)v10 * 0.012512207);
v7[v8++] = result;
if ( v8 == a3 )
return result;
goto LABEL_6;
}
}
else
{
v14 = a3 - 1;
if ( a3 > 0 )
{
v15 = ((unsigned __int64)(a3 - 8) >> 3) + 1;
v16 = 8 * v15;
if ( (unsigned __int64)v14 <= 6 )
goto LABEL_16;
v17.n128_u64[0] = 0xFF000000FF00LL;
v17.n128_u64[1] = 0xFF000000FF00LL;
v18.n128_u64[0] = 0xFF000000FFLL;
v18.n128_u64[1] = 0xFF000000FFLL;
v19 = a2;
v20 = *(int8x16_t **)(a1 + 16);
v21 = 0;
do
{
v23 = vld3q_s16(v19);
v19 += 24;
++v21;
v22 = v20;
v20 += 2;
*v22 = vorrq_s8(
vorrq_s8(
vandq_s8(
vshrq_n_u32(vmulq_s32(vmovl_s16((int16x4_t)v23.val[1].n128_u64[0]), (int32x4_t)xmmword_ECA0E0), 7u),
v17),
vandq_s8(
vshrq_n_u32(
vmulq_s32(vmovl_s16((int16x4_t)v23.val[2].n128_u64[0]), (int32x4_t)xmmword_ECA0E0),
0xFu),
v18)),
vshlq_n_s32(vmovl_s16((int16x4_t)v23.val[0].n128_u64[0]), 0x10u));
v22[1] = vorrq_s8(
vorrq_s8(
vandq_s8(vshrq_n_u32(vmulq_s32(vmovl_high_s16(v23.val[1]), (int32x4_t)xmmword_ECA0E0), 7u), v17),
vandq_s8(vshrq_n_u32(vmulq_s32(vmovl_high_s16(v23.val[2]), (int32x4_t)xmmword_ECA0E0), 0xFu), v18)),
vshlq_n_s32(vmovl_high_s16(v23.val[0]), 0x10u));
}
while ( v21 < v15 );
result = 48 * v15;
v7 += v16;
a2 += 3 * v16;
v14 -= v16;
if ( v16 != a3 )
{
LABEL_16:
result = 410;
*v7 = ((unsigned int)(410 * a2[1]) >> 7) & 0xFF00
| (unsigned __int8)((unsigned __int64)(unsigned int)(410 * a2[2]) >> 15)
| (*a2 << 16);
if ( v14 > 0 )
{
v7[1] = ((unsigned int)(410 * a2[4]) >> 7) & 0xFF00
| (unsigned __int8)((unsigned __int64)(unsigned int)(410 * a2[5]) >> 15)
| (a2[3] << 16);
if ( v14 > 1 )
{
v7[2] = ((unsigned int)(410 * a2[7]) >> 7) & 0xFF00
| (unsigned __int8)((unsigned __int64)(unsigned int)(410 * a2[8]) >> 15)
| (a2[6] << 16);
if ( v14 > 2 )
{
v7[3] = ((unsigned int)(410 * a2[10]) >> 7) & 0xFF00
| (unsigned __int8)((unsigned __int64)(unsigned int)(410 * a2[11]) >> 15)
| (a2[9] << 16);
if ( v14 > 3 )
{
v7[4] = ((unsigned int)(410 * a2[13]) >> 7) & 0xFF00
| (unsigned __int8)((unsigned __int64)(unsigned int)(410 * a2[14]) >> 15)
| (a2[12] << 16);
if ( v14 > 4 )
{
v7[5] = ((unsigned int)(410 * a2[16]) >> 7) & 0xFF00
| (unsigned __int8)((unsigned __int64)(unsigned int)(410 * a2[17]) >> 15)
| (a2[15] << 16);
if ( v14 > 5 )
{
result = ((unsigned int)(410 * a2[19]) >> 7) & 0xFF00
| (unsigned __int8)((unsigned __int64)(unsigned int)(410 * a2[20]) >> 15)
| (a2[18] << 16);
v7[6] = result;
}
}
}
}
}
}
}
}
}
return result;
}