//
// sub_1002A8960 from 0x1002a8960 to 0x1002a91af (2127 bytes)
//
// 0 xrefs:
//
// This function is hookable on this platform (idp: pc, 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 12:27:57 +0000
//
void __fastcall sub_1002A8960(__int64 a1)
{
__int64 v1; // r15
__int64 v2; // r12
int v3; // r14d
int v4; // ebx
void *v5; // rax
unsigned __int64 v6; // r13
unsigned int v7; // ebx
char *v8; // rdi
__int64 v9; // r15
__int64 v10; // rax
__int64 v11; // rcx
__int64 v12; // rsi
char *v13; // rdx
__int64 v14; // rcx
unsigned __int64 v15; // rsi
char *v16; // rdx
unsigned __int64 v17; // r12
char *v18; // r8
unsigned __int64 v19; // rsi
unsigned __int64 v20; // rcx
char *v21; // r9
char *v22; // r10
unsigned __int64 v23; // r9
char *v24; // rcx
bool v25; // di
bool v26; // r8
bool v27; // zf
__int64 v28; // rsi
__int64 v29; // rax
__m128i *v30; // rsi
char *v31; // r11
__int64 v32; // r13
__int64 v33; // rdi
__int64 v34; // r14
__int64 v35; // r10
__int64 v36; // r8
__m128i v37; // xmm0
__m128d v38; // xmm10
__m128d v39; // xmm7
__m128i v40; // xmm0
__m128d v41; // xmm9
__m128d v42; // xmm4
__m128i v43; // xmm0
__m128d v44; // xmm6
__m128d v45; // xmm3
__m128i v46; // xmm0
__m128d v47; // xmm8
__m128d v48; // xmm5
__m128i v49; // xmm11
__m128d v50; // xmm0
__m128d v51; // xmm13
__m128i v52; // xmm11
__m128d v53; // xmm15
__m128d v54; // xmm12
__m128i v55; // xmm11
__m128d v56; // xmm14
__m128d v57; // xmm7
__m128d v58; // xmm10
__m128i v59; // xmm0
__m128d v60; // xmm8
__m128d v61; // xmm13
__m128d v62; // xmm6
__m128d v63; // xmm4
__m128i v64; // xmm0
__m128d v65; // xmm12
__m128i v66; // xmm10
__m128d v67; // xmm11
__m128d v68; // xmm7
__m128i v69; // xmm13
__m128i v70; // xmm9
__int64 v71; // rdi
__int64 v72; // r8
__int64 v73; // r10
__int64 v74; // r11
__int64 v75; // rbx
__m128i v76; // xmm3
__m128i v77; // xmm5
__m128i v78; // xmm6
__m128i v79; // xmm3
__m128i v80; // xmm3
__int64 v81; // [rsp+18h] [rbp-A8h]
__int64 v82; // [rsp+28h] [rbp-98h]
__int64 v83; // [rsp+50h] [rbp-70h]
unsigned __int64 v84; // [rsp+60h] [rbp-60h]
__int64 v85; // [rsp+68h] [rbp-58h]
__int64 v86; // [rsp+70h] [rbp-50h]
__int64 v87; // [rsp+78h] [rbp-48h]
__int64 v88; // [rsp+80h] [rbp-40h]
__int64 v89; // [rsp+88h] [rbp-38h]
char *v90; // [rsp+90h] [rbp-30h]
v1 = *(unsigned __int8 *)(a1 + 5);
if ( v1 != 8 )
{
v2 = a1;
v3 = *(__int16 *)(a1 + 8);
v4 = *(__int16 *)(a1 + 6);
v5 = malloc(*(__int16 *)(a1 + 8) * (__int64)*(__int16 *)(a1 + 6));
if ( v5 )
{
v6 = (unsigned __int64)v5;
v7 = v3 * v4;
v8 = *(char **)(a1 + 16);
if ( (int)v7 <= 0 )
{
LABEL_8:
free(v8);
*(_WORD *)(v2 + 4) = 2051;
*(_QWORD *)(v2 + 16) = v6;
return;
}
v9 = (unsigned int)v1 >> 3;
v10 = v7;
if ( v7 < 4 )
{
v11 = 0;
v12 = 0;
goto LABEL_6;
}
v89 = v2;
v14 = v9 * (v7 - 1LL);
v15 = (unsigned __int64)&v8[v14 + 2];
v16 = v8 + 2;
v17 = (unsigned __int64)(v8 + 2);
if ( v15 < (unsigned __int64)(v8 + 2) )
v17 = (unsigned __int64)&v8[v14 + 2];
if ( v15 <= (unsigned __int64)(v8 + 2) )
v15 = (unsigned __int64)(v8 + 2);
v18 = &v8[v14];
v19 = v15 + 1;
v20 = (unsigned __int64)&v8[v14 + 1];
v21 = v8 + 1;
v22 = v8 + 1;
if ( v20 < (unsigned __int64)(v8 + 1) )
v22 = (char *)v20;
if ( v20 > (unsigned __int64)(v8 + 1) )
v21 = (char *)v20;
v23 = (unsigned __int64)(v21 + 1);
v24 = v18;
if ( v8 < v18 )
v24 = v8;
v90 = v8;
if ( v8 > v18 )
v18 = v8;
v25 = v6 < (unsigned __int64)(v18 + 1);
v26 = (unsigned __int64)v24 < v7 + v6;
v11 = 0;
if ( v17 < v7 + v6 && v6 < v19 )
{
v12 = 0;
v2 = v89;
v8 = v90;
}
else
{
v2 = v89;
if ( (unsigned __int64)v22 < v7 + v6 && v6 < v23 )
{
v12 = 0;
v8 = v90;
}
else
{
v12 = 0;
v27 = !v26 || !v25;
v8 = v90;
if ( v27 )
{
if ( v7 < 0x10 )
{
v11 = 0;
goto LABEL_31;
}
v11 = v7 & 0x7FFFFFF0;
v85 = 15 * v9;
v81 = (unsigned int)(16 * v9);
v82 = 3 * v9;
v28 = (unsigned int)(2 * v9);
v83 = 5 * v28;
v86 = 9 * v9;
v87 = 7 * v9;
v88 = 3 * v28;
v29 = v11;
v84 = v6;
v30 = (__m128i *)v6;
v31 = v90;
v32 = 5 * v9;
v33 = 11 * v9;
v34 = 3LL * (unsigned int)(4 * v9);
v35 = 13 * v9;
v36 = v81 - v9 - v9;
do
{
v37 = _mm_cvtepu8_epi32(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_insert_epi8(_mm_cvtsi32_si128((unsigned __int8)*v31), (unsigned __int8)v31[v9], 1),
(unsigned __int8)v31[2 * v9],
2),
(unsigned __int8)v31[3 * v9],
3));
v38 = _mm_cvtepi32_pd(_mm_shuffle_epi32(v37, 238));
v39 = _mm_cvtepi32_pd(v37);
v40 = _mm_cvtepu8_epi32(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_cvtsi32_si128((unsigned __int8)v31[4 * v9]),
(unsigned __int8)v31[5 * v9],
1),
(unsigned __int8)v31[v88],
2),
(unsigned __int8)v31[7 * v9],
3));
v41 = _mm_cvtepi32_pd(_mm_shuffle_epi32(v40, 238));
v42 = _mm_cvtepi32_pd(v40);
v43 = _mm_cvtepu8_epi32(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_cvtsi32_si128((unsigned __int8)v31[8 * v9]),
(unsigned __int8)v31[9 * v9],
1),
(unsigned __int8)v31[v83],
2),
(unsigned __int8)v31[11 * v9],
3));
v44 = _mm_cvtepi32_pd(_mm_shuffle_epi32(v43, 238));
v45 = _mm_cvtepi32_pd(v43);
v46 = _mm_cvtepu8_epi32(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_cvtsi32_si128((unsigned __int8)v31[3 * (unsigned int)(4 * v9)]),
(unsigned __int8)v31[13 * v9],
1),
(unsigned __int8)v31[v36],
2),
(unsigned __int8)v31[15 * v9],
3));
v47 = _mm_cvtepi32_pd(_mm_shuffle_epi32(v46, 238));
v48 = _mm_cvtepi32_pd(v46);
v49 = _mm_cvtepu8_epi32(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_insert_epi8(_mm_cvtsi32_si128((unsigned __int8)v31[1]), (unsigned __int8)v31[v9 + 1], 1),
(unsigned __int8)v31[2 * v9 + 1],
2),
(unsigned __int8)v31[v82 + 1],
3));
v50 = _mm_cvtepi32_pd(v49);
v51 = _mm_cvtepi32_pd(_mm_shuffle_epi32(v49, 238));
v52 = _mm_cvtepu8_epi32(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_cvtsi32_si128((unsigned __int8)v31[v34 + 1]),
(unsigned __int8)v31[v35 + 1],
1),
(unsigned __int8)v31[v36 + 1],
2),
(unsigned __int8)v31[v85 + 1],
3));
v53 = _mm_cvtepi32_pd(v52);
v54 = _mm_cvtepi32_pd(_mm_shuffle_epi32(v52, 238));
v55 = _mm_cvtepu8_epi32(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_cvtsi32_si128((unsigned __int8)v31[8 * v9 + 1]),
(unsigned __int8)v31[v86 + 1],
1),
(unsigned __int8)v31[v83 + 1],
2),
(unsigned __int8)v31[v33 + 1],
3));
v56 = _mm_cvtepi32_pd(v55);
v57 = _mm_add_pd(_mm_mul_pd(v39, (__m128d)xmmword_100A076F0), _mm_mul_pd(v50, (__m128d)xmmword_100A076E0));
v58 = _mm_add_pd(_mm_mul_pd(v38, (__m128d)xmmword_100A076F0), _mm_mul_pd(v51, (__m128d)xmmword_100A076E0));
v59 = _mm_cvtepu8_epi32(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_cvtsi32_si128((unsigned __int8)v31[4 * v9 + 1]),
(unsigned __int8)v31[v32 + 1],
1),
(unsigned __int8)v31[v88 + 1],
2),
(unsigned __int8)v31[v87 + 1],
3));
v60 = _mm_add_pd(_mm_mul_pd(v47, (__m128d)xmmword_100A076F0), _mm_mul_pd(v54, (__m128d)xmmword_100A076E0));
v61 = _mm_mul_pd(_mm_cvtepi32_pd(_mm_shuffle_epi32(v59, 238)), (__m128d)xmmword_100A076E0);
v62 = _mm_add_pd(
_mm_mul_pd(v44, (__m128d)xmmword_100A076F0),
_mm_mul_pd(_mm_cvtepi32_pd(_mm_shuffle_epi32(v55, 238)), (__m128d)xmmword_100A076E0));
v63 = _mm_add_pd(
_mm_mul_pd(v42, (__m128d)xmmword_100A076F0),
_mm_mul_pd(_mm_cvtepi32_pd(v59), (__m128d)xmmword_100A076E0));
v64 = _mm_cvtepu8_epi32(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_insert_epi8(_mm_cvtsi32_si128((unsigned __int8)v31[2]), (unsigned __int8)v31[v9 + 2], 1),
(unsigned __int8)v31[2 * v9 + 2],
2),
(unsigned __int8)v31[v82 + 2],
3));
v65 = _mm_add_pd(
_mm_mul_pd(_mm_cvtepi32_pd(_mm_shuffle_epi32(v64, 238)), (__m128d)xmmword_100A07700),
v58);
v66 = _mm_cvtepu8_epi32(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_cvtsi32_si128((unsigned __int8)v31[4 * v9 + 2]),
(unsigned __int8)v31[v32 + 2],
1),
(unsigned __int8)v31[v88 + 2],
2),
(unsigned __int8)v31[v87 + 2],
3));
v67 = _mm_add_pd(_mm_mul_pd(_mm_cvtepi32_pd(v64), (__m128d)xmmword_100A07700), v57);
v68 = _mm_add_pd(
_mm_mul_pd(_mm_cvtepi32_pd(_mm_shuffle_epi32(v66, 238)), (__m128d)xmmword_100A07700),
_mm_add_pd(_mm_mul_pd(v41, (__m128d)xmmword_100A076F0), v61));
v69 = _mm_cvtepu8_epi32(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_cvtsi32_si128((unsigned __int8)v31[v34 + 2]),
(unsigned __int8)v31[v35 + 2],
1),
(unsigned __int8)v31[v36 + 2],
2),
(unsigned __int8)v31[v85 + 2],
3));
v70 = _mm_cvtepu8_epi32(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_cvtsi32_si128((unsigned __int8)v31[8 * v9 + 2]),
(unsigned __int8)v31[v86 + 2],
1),
(unsigned __int8)v31[v83 + 2],
2),
(unsigned __int8)v31[v33 + 2],
3));
*v30 = _mm_packus_epi16(
_mm_packs_epi32(
(__m128i)_mm_unpacklo_pd((__m128d)_mm_cvttpd_epi32(v67), (__m128d)_mm_cvttpd_epi32(v65)),
(__m128i)_mm_unpacklo_pd(
(__m128d)_mm_cvttpd_epi32(
_mm_add_pd(
_mm_mul_pd(_mm_cvtepi32_pd(v66), (__m128d)xmmword_100A07700),
v63)),
(__m128d)_mm_cvttpd_epi32(v68))),
_mm_packs_epi32(
(__m128i)_mm_unpacklo_pd(
(__m128d)_mm_cvttpd_epi32(
_mm_add_pd(
_mm_mul_pd(_mm_cvtepi32_pd(v70), (__m128d)xmmword_100A07700),
_mm_add_pd(
_mm_mul_pd(v45, (__m128d)xmmword_100A076F0),
_mm_mul_pd(v56, (__m128d)xmmword_100A076E0)))),
(__m128d)_mm_cvttpd_epi32(
_mm_add_pd(
_mm_mul_pd(
_mm_cvtepi32_pd(_mm_shuffle_epi32(v70, 238)),
(__m128d)xmmword_100A07700),
v62))),
(__m128i)_mm_unpacklo_pd(
(__m128d)_mm_cvttpd_epi32(
_mm_add_pd(
_mm_mul_pd(_mm_cvtepi32_pd(v69), (__m128d)xmmword_100A07700),
_mm_add_pd(
_mm_mul_pd(v48, (__m128d)xmmword_100A076F0),
_mm_mul_pd(v53, (__m128d)xmmword_100A076E0)))),
(__m128d)_mm_cvttpd_epi32(
_mm_add_pd(
_mm_mul_pd(
_mm_cvtepi32_pd(_mm_shuffle_epi32(v69, 238)),
(__m128d)xmmword_100A07700),
v60)))));
v31 += v81;
++v30;
v29 -= 16;
}
while ( v29 );
v10 = v7;
v2 = v89;
v8 = v90;
v6 = v84;
if ( (_DWORD)v11 == v7 )
goto LABEL_8;
if ( (v7 & 0xC) != 0 )
{
LABEL_31:
v71 = v11;
v11 = v10 & 0x7FFFFFFC;
v12 = v9 * v11;
v72 = v9 * (v71 + 3);
v73 = v9 * (v71 + 2);
v74 = v9 * (v71 + 1);
v75 = v9 * v71;
do
{
v76 = _mm_cvtepu8_epi32(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_cvtsi32_si128((unsigned __int8)v16[v75 - 2]),
(unsigned __int8)v16[v74 - 2],
1),
(unsigned __int8)v16[v73 - 2],
2),
(unsigned __int8)v16[v72 - 2],
3));
v77 = _mm_cvtepu8_epi32(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_cvtsi32_si128((unsigned __int8)v16[v75 - 1]),
(unsigned __int8)v16[v74 - 1],
1),
(unsigned __int8)v16[v73 - 1],
2),
(unsigned __int8)v16[v72 - 1],
3));
v78 = _mm_cvtepu8_epi32(
_mm_insert_epi8(
_mm_insert_epi8(
_mm_insert_epi8(_mm_cvtsi32_si128((unsigned __int8)v16[v75]), (unsigned __int8)v16[v74], 1),
(unsigned __int8)v16[v73],
2),
(unsigned __int8)v16[v72],
3));
v79 = (__m128i)_mm_unpacklo_pd(
(__m128d)_mm_cvttpd_epi32(
_mm_add_pd(
_mm_mul_pd(_mm_cvtepi32_pd(v78), (__m128d)xmmword_100A07700),
_mm_add_pd(
_mm_mul_pd(_mm_cvtepi32_pd(v76), (__m128d)xmmword_100A076F0),
_mm_mul_pd(_mm_cvtepi32_pd(v77), (__m128d)xmmword_100A076E0)))),
(__m128d)_mm_cvttpd_epi32(
_mm_add_pd(
_mm_mul_pd(
_mm_cvtepi32_pd(_mm_shuffle_epi32(v78, 238)),
(__m128d)xmmword_100A07700),
_mm_add_pd(
_mm_mul_pd(
_mm_cvtepi32_pd(_mm_shuffle_epi32(v76, 238)),
(__m128d)xmmword_100A076F0),
_mm_mul_pd(
_mm_cvtepi32_pd(_mm_shuffle_epi32(v77, 238)),
(__m128d)xmmword_100A076E0)))));
v80 = _mm_packus_epi32(v79, v79);
*(_DWORD *)(v6 + v71) = _mm_cvtsi128_si32(_mm_packus_epi16(v80, v80));
v71 += 4;
v16 += (unsigned int)(4 * v9);
}
while ( v11 != v71 );
v8 = v90;
if ( (_DWORD)v11 == (_DWORD)v10 )
goto LABEL_8;
goto LABEL_6;
}
v12 = v9 * v11;
}
}
}
LABEL_6:
v13 = &v8[v12 + 2];
do
{
*(_BYTE *)(v6 + v11++) = (int)((double)(unsigned __int8)*v13 * 0.11
+ (double)(unsigned __int8)*(v13 - 2) * 0.3
+ (double)(unsigned __int8)*(v13 - 1) * 0.59);
v13 += v9;
}
while ( v10 != v11 );
goto LABEL_8;
}
}
}