//
// sub_EC2130 from 0xec2130 to 0xec26e4 (1460 bytes)
//
// 1 xrefs:
// > TIFFRGBAImageBegin @ 0xec8098
//
// 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:33 +0000
//
__int64 __fastcall sub_EC2130(
__int64 a1,
unsigned __int64 a2,
__int64 a3,
__int64 a4,
unsigned int a5,
int a6,
int a7,
int a8,
unsigned __int8 *a9,
unsigned __int8 *a10,
unsigned __int8 *a11,
unsigned __int8 *a12)
{
int v12; // w18
int32x4_t v17; // q17
int8x16_t v18; // q18
__int64 v19; // x26
__int64 v20; // x15
__int64 result; // x0
unsigned int v22; // w9
unsigned int v23; // w24
unsigned int v24; // w25
unsigned __int8 *v25; // x8
unsigned __int8 *v26; // x7
__int64 v27; // x14
unsigned __int8 *v28; // x5
unsigned __int8 *v29; // x3
unsigned int *v30; // x2
int v31; // w23
int v32; // t1
int v33; // w17
int v34; // t1
int v35; // w20
int v36; // t1
int v37; // t1
unsigned int v38; // w17
unsigned int v39; // w20
int8x16_t *v40; // x21
__int64 v41; // x23
unsigned int v42; // w25
int8x16_t *v43; // x19
uint8x8_t *v44; // x24
uint8x8_t *v45; // x18
uint8x16_t v46; // q7
int8x16_t *v47; // x28
uint8x16_t v48; // q21
int8x16_t *v49; // x27
uint16x8_t v50; // q16
uint16x8_t v51; // q6
uint16x8_t v52; // q5
uint16x8_t v53; // q25
uint16x8_t v54; // q4
uint16x8_t v55; // q26
uint16x8_t v56; // q21
int32x4_t v57; // q28
uint16x8_t v58; // q0
int32x4_t v59; // q24
uint32x4_t v60; // q2
uint32x4_t v61; // q1
int32x4_t v62; // q27
int32x4_t v63; // q20
int32x4_t v64; // q26
int32x4_t v65; // q7
uint32x4_t v66; // q3
uint32x4_t v67; // q19
uint32x4_t v68; // q4
int32x4_t v69; // q28
int32x4_t v70; // q6
int32x4_t v71; // q10
int32x4_t v72; // q9
uint32x4_t v73; // q5
uint32x4_t v74; // q20
uint32x4_t v75; // q1
uint32x4_t v76; // q2
uint32x4_t v77; // q21
uint32x4_t v78; // q24
uint32x4_t v79; // q6
uint32x4_t v80; // q23
int32x4_t v81; // q16
int32x4_t v82; // q9
uint32x4_t v83; // q20
__int64 v84; // x20
__int64 v85; // x14
__int64 v86; // x9
__int64 v87; // [xsp+70h] [xbp-20h]
__int64 v88; // [xsp+78h] [xbp-18h]
int v89; // [xsp+8Ch] [xbp-4h]
v12 = a6 - 1;
if ( a6 )
{
v17.n128_u64[0] = 0xFF000000FFLL;
v17.n128_u64[1] = 0xFF000000FFLL;
v18.n128_u64[0] = 0xFF000000FF000000LL;
v18.n128_u64[1] = 0xFF000000FF000000LL;
v19 = a5 - 1;
v87 = 4LL * a8;
v20 = v19 + 1;
v88 = 4LL * a5;
result = 255;
do
{
if ( a5 )
{
if ( a5 > 0x11
&& (a2 >= (unsigned __int64)&a9[a5] || (unsigned __int64)a9 >= a2 + v88)
&& (a2 >= (unsigned __int64)&a10[a5] || (unsigned __int64)a10 >= a2 + v88)
&& (a2 >= (unsigned __int64)&a11[a5] || (unsigned __int64)a11 >= a2 + v88)
&& (a2 >= (unsigned __int64)&a12[a5] || (unsigned __int64)a12 >= a2 + v88) )
{
v22 = -((a2 >> 2) & 3) & 3;
if ( v22 > a5 )
v22 = a5;
if ( v22 )
{
v23 = v19 - v22;
v24 = a5 - 1;
v25 = a12;
v26 = a11;
v27 = (unsigned int)v19 - v22;
v28 = a10;
v29 = a9;
v30 = (unsigned int *)a2;
do
{
v32 = *v25++;
v31 = v32;
v34 = *v29++;
v33 = v34;
v36 = *v28++;
v35 = v36;
v37 = *v26++;
--v24;
*v30++ = ((255 - v33) * (255 - v31) / 0xFFu)
| 0xFF000000
| (((255 - v35) * (255 - v31) / 0xFFu) << 8)
| (((255 - v37) * (255 - v31) / 0xFFu) << 16);
}
while ( v24 != v23 );
}
else
{
v27 = (unsigned int)v19;
v25 = a12;
v26 = a11;
v28 = a10;
v29 = a9;
v30 = (unsigned int *)a2;
v23 = a5 - 1;
}
v38 = ((a5 - v22 - 16) >> 4) + 1;
v39 = 16 * v38;
if ( v23 <= 0xE )
goto LABEL_15;
v40 = (int8x16_t *)(a2 + 4LL * v22);
v41 = 0;
v42 = 0;
v89 = v12;
do
{
v43 = v40;
v44 = (uint8x8_t *)&a10[v41 + v22];
v45 = (uint8x8_t *)&a11[v41 + v22];
v46 = *(uint8x16_t *)&a12[v41 + v22];
v47 = v40 + 2;
v48 = *(uint8x16_t *)&a9[v41 + v22];
v49 = v40 + 3;
++v42;
v41 += 16;
v40 += 4;
v50 = vmovl_u8((uint8x8_t)v46.n128_u64[0]);
v51 = vmovl_u8((uint8x8_t)v48.n128_u64[0]);
v52 = vmovl_u8((uint8x8_t)v44->n64_u64[0]);
v53 = vmovl_u8((uint8x8_t)v45->n64_u64[0]);
v54 = vmovl_high_u8(*(uint8x16_t *)v44->n64_u64);
v55 = vmovl_high_u8(v46);
v56 = vmovl_high_u8(v48);
v57 = vsubq_s32(v17, vmovl_u16((uint16x4_t)v50.n128_u64[0]));
v58 = vmovl_high_u8(*(uint8x16_t *)v45->n64_u64);
v59 = vsubw_high_u16(v17, v50);
v60 = vmulq_s32(vsubq_s32(v17, vmovl_u16((uint16x4_t)v51.n128_u64[0])), v57);
v61 = vmulq_s32(vsubq_s32(v17, vmovl_u16((uint16x4_t)v52.n128_u64[0])), v57);
v62 = vsubq_s32(v17, vmovl_u16((uint16x4_t)v55.n128_u64[0]));
v63 = vsubq_s32(v17, vmovl_u16((uint16x4_t)v54.n128_u64[0]));
v64 = vsubw_high_u16(v17, v55);
v65 = vsubw_high_u16(v17, v54);
v66 = vmulq_s32(vsubw_high_u16(v17, v52), v59);
v67 = vmulq_s32(vsubq_s32(v17, vmovl_u16((uint16x4_t)v53.n128_u64[0])), v57);
v68 = vmulq_s32(vsubw_high_u16(v17, v51), v59);
v69 = vmull_u32((uint32x2_t)v60.n128_u64[0], (uint32x2_t)0x8080808180808081LL);
v70 = vmull_high_u32(v60, (uint32x4_t)xmmword_EC26F0);
v71 = vmull_u32((uint32x2_t)v61.n128_u64[0], (uint32x2_t)0x8080808180808081LL);
v72 = vmull_high_u32(v61, (uint32x4_t)xmmword_EC26F0);
v73 = vmulq_s32(vsubq_s32(v17, vmovl_u16((uint16x4_t)v56.n128_u64[0])), v62);
v74 = vmulq_s32(v63, v62);
v75 = vmulq_s32(v65, v64);
v76 = vmulq_s32(vsubw_high_u16(v17, v56), v64);
v77 = vuzp2q_s32(v69, v70);
v78 = vmulq_s32(vsubw_high_u16(v17, v53), v59);
v79 = vuzp2q_s32(v71, v72);
v80 = vmulq_s32(vsubq_s32(v17, vmovl_u16((uint16x4_t)v58.n128_u64[0])), v62);
v81 = vmull_high_u32(v74, (uint32x4_t)xmmword_EC26F0);
v82 = vmull_u32((uint32x2_t)v74.n128_u64[0], (uint32x2_t)0x8080808180808081LL);
v83 = vmulq_s32(vsubw_high_u16(v17, v58), v64);
*v43 = vorrq_s8(
vorrq_s8(vorrq_s8(vshrq_n_u32(v77, 7u), v18), vshlq_n_s32(vshrq_n_u32(v79, 7u), 8u)),
vshlq_n_s32(
vshrq_n_u32(
vuzp2q_s32(
vmull_u32((uint32x2_t)v67.n128_u64[0], (uint32x2_t)0x8080808180808081LL),
vmull_high_u32(v67, (uint32x4_t)xmmword_EC26F0)),
7u),
0x10u));
v43[1] = vorrq_s8(
vorrq_s8(
vorrq_s8(
vshrq_n_u32(
vuzp2q_s32(
vmull_u32((uint32x2_t)v68.n128_u64[0], (uint32x2_t)0x8080808180808081LL),
vmull_high_u32(v68, (uint32x4_t)xmmword_EC26F0)),
7u),
v18),
vshlq_n_s32(
vshrq_n_u32(
vuzp2q_s32(
vmull_u32((uint32x2_t)v66.n128_u64[0], (uint32x2_t)0x8080808180808081LL),
vmull_high_u32(v66, (uint32x4_t)xmmword_EC26F0)),
7u),
8u)),
vshlq_n_s32(
vshrq_n_u32(
vuzp2q_s32(
vmull_u32((uint32x2_t)v78.n128_u64[0], (uint32x2_t)0x8080808180808081LL),
vmull_high_u32(v78, (uint32x4_t)xmmword_EC26F0)),
7u),
0x10u));
*v47 = vorrq_s8(
vorrq_s8(
vorrq_s8(
vshrq_n_u32(
vuzp2q_s32(
vmull_u32((uint32x2_t)v73.n128_u64[0], (uint32x2_t)0x8080808180808081LL),
vmull_high_u32(v73, (uint32x4_t)xmmword_EC26F0)),
7u),
v18),
vshlq_n_s32(vshrq_n_u32(vuzp2q_s32(v82, v81), 7u), 8u)),
vshlq_n_s32(
vshrq_n_u32(
vuzp2q_s32(
vmull_u32((uint32x2_t)v80.n128_u64[0], (uint32x2_t)0x8080808180808081LL),
vmull_high_u32(v80, (uint32x4_t)xmmword_EC26F0)),
7u),
0x10u));
*v49 = vorrq_s8(
vorrq_s8(
vorrq_s8(
vshrq_n_u32(
vuzp2q_s32(
vmull_u32((uint32x2_t)v76.n128_u64[0], (uint32x2_t)0x8080808180808081LL),
vmull_high_u32(v76, (uint32x4_t)xmmword_EC26F0)),
7u),
v18),
vshlq_n_s32(
vshrq_n_u32(
vuzp2q_s32(
vmull_u32((uint32x2_t)v75.n128_u64[0], (uint32x2_t)0x8080808180808081LL),
vmull_high_u32(v75, (uint32x4_t)xmmword_EC26F0)),
7u),
8u)),
vshlq_n_s32(
vshrq_n_u32(
vuzp2q_s32(
vmull_u32((uint32x2_t)v83.n128_u64[0], (uint32x2_t)0x8080808180808081LL),
vmull_high_u32(v83, (uint32x4_t)xmmword_EC26F0)),
7u),
0x10u));
}
while ( v38 > v42 );
v12 = v89;
v29 += v39;
v28 += v39;
v30 += v39;
v26 += v39;
v25 += v39;
v27 = (unsigned int)v27 - v39;
if ( a5 - v22 != v39 )
{
LABEL_15:
v84 = 0;
v85 = v27 + 1;
do
{
v30[v84] = ((255 - v29[v84]) * (255 - (unsigned int)v25[v84]) / 0xFF)
| 0xFF000000
| (((255 - v28[v84]) * (255 - (unsigned int)v25[v84]) / 0xFF) << 8)
| (((255 - v26[v84]) * (255 - (unsigned int)v25[v84]) / 0xFF) << 16);
++v84;
}
while ( v84 != v85 );
}
}
else
{
v86 = 0;
do
{
*(_DWORD *)(a2 + 4 * v86) = ((255 - a9[v86]) * (255 - (unsigned int)a12[v86]) / 0xFF)
| 0xFF000000
| (((255 - a10[v86]) * (255 - (unsigned int)a12[v86]) / 0xFF) << 8)
| (((255 - a11[v86]) * (255 - (unsigned int)a12[v86]) / 0xFF) << 16);
++v86;
}
while ( v86 != v20 );
}
a12 += v20;
a9 += v20;
a10 += v20;
a11 += v20;
a2 += 4 * (v19 + 1);
}
--v12;
a9 += a7;
a10 += a7;
a11 += a7;
a12 += a7;
a2 += v87;
}
while ( v12 != -1 );
}
return result;
}