//
// sub_E52FE0 from 0xe52fe0 to 0xe5344c (1132 bytes)
//
// 2 xrefs:
// > png_read_filter_row @ 0xe58bcc
// > png_read_filter_row @ 0xe58bd4
//
// 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:10:17 +0000
//
unsigned __int64 __fastcall sub_E52FE0(unsigned __int64 result, unsigned __int64 a2, _BYTE *a3)
{
unsigned __int64 v3; // x6
unsigned __int64 v4; // x3
_BYTE *v5; // x5
__int64 v6; // x4
unsigned __int64 v7; // x9
unsigned __int64 v8; // x7
__int64 v9; // x8
int8x16_t *v10; // x1
int8x16_t *v11; // x3
int8x16_t *v12; // x10
unsigned __int64 v13; // x2
int8x16_t v14; // t1
int8x16_t v15; // q0
int8x16_t v16; // t1
v3 = *(_QWORD *)(result + 8);
if ( !v3 )
return result;
if ( (unsigned __int64)a3 < a2 + 16 && a2 < (unsigned __int64)(a3 + 16) || v3 <= 0x12 )
{
for ( result = 0; result != v3; ++result )
*(_BYTE *)(a2 + result) += a3[result];
return result;
}
v4 = -(__int64)a2 & 0xF;
if ( v4 > v3 )
v4 = *(_QWORD *)(result + 8);
if ( v4 )
{
v5 = a3 + 1;
*(_BYTE *)a2 += *a3;
result = a2 + 1;
if ( v4 == 1 )
goto LABEL_43;
v5 = a3 + 2;
result = a2 + 2;
*(_BYTE *)(a2 + 1) += a3[1];
if ( v4 == 2 )
goto LABEL_43;
v5 = a3 + 3;
result = a2 + 3;
*(_BYTE *)(a2 + 2) += a3[2];
if ( v4 == 3 )
goto LABEL_43;
v5 = a3 + 4;
result = a2 + 4;
*(_BYTE *)(a2 + 3) += a3[3];
if ( v4 == 4 )
goto LABEL_43;
v5 = a3 + 5;
result = a2 + 5;
*(_BYTE *)(a2 + 4) += a3[4];
if ( v4 == 5 )
goto LABEL_43;
v5 = a3 + 6;
result = a2 + 6;
*(_BYTE *)(a2 + 5) += a3[5];
if ( v4 == 6 )
{
v6 = 6;
goto LABEL_22;
}
v5 = a3 + 7;
result = a2 + 7;
*(_BYTE *)(a2 + 6) += a3[6];
if ( v4 == 7 )
goto LABEL_43;
v5 = a3 + 8;
result = a2 + 8;
*(_BYTE *)(a2 + 7) += a3[7];
if ( v4 == 8 )
goto LABEL_43;
v5 = a3 + 9;
result = a2 + 9;
*(_BYTE *)(a2 + 8) += a3[8];
if ( v4 == 9 )
goto LABEL_43;
v5 = a3 + 10;
result = a2 + 10;
*(_BYTE *)(a2 + 9) += a3[9];
if ( v4 == 10 )
goto LABEL_43;
v5 = a3 + 11;
result = a2 + 11;
*(_BYTE *)(a2 + 10) += a3[10];
if ( v4 == 11
|| (v5 = a3 + 12, result = a2 + 12, *(_BYTE *)(a2 + 11) += a3[11], v4 == 12)
|| (v5 = a3 + 13, result = a2 + 13, *(_BYTE *)(a2 + 12) += a3[12], v4 == 13) )
{
LABEL_43:
v6 = v4;
}
else
{
v5 = a3 + 14;
result = a2 + 14;
*(_BYTE *)(a2 + 13) += a3[13];
if ( v4 == 15 )
{
v5 = a3 + 15;
result = a2 + 15;
v6 = 15;
*(_BYTE *)(a2 + 14) += a3[14];
}
else
{
v6 = 14;
}
}
}
else
{
v5 = a3;
result = a2;
v6 = 0;
}
LABEL_22:
v7 = v3 - v4;
v8 = ((v3 - v4 - 16) >> 4) + 1;
v9 = 16 * v8;
if ( v3 - 1 - v4 <= 0xE )
goto LABEL_26;
v10 = (int8x16_t *)(a2 + v4);
v11 = (int8x16_t *)&a3[v4];
v12 = v10;
v13 = 0;
do
{
v14 = *v11++;
v15 = v14;
++v13;
v16 = *v10++;
*v12++ = vaddq_s8(v15, v16);
}
while ( v13 < v8 );
v6 += v9;
result += v9;
v5 += v9;
if ( v7 != v9 )
{
LABEL_26:
*(_BYTE *)result += *v5;
if ( v3 > v6 + 1 )
{
*(_BYTE *)(result + 1) += v5[1];
if ( v3 > v6 + 2 )
{
*(_BYTE *)(result + 2) += v5[2];
if ( v3 > v6 + 3 )
{
*(_BYTE *)(result + 3) += v5[3];
if ( v3 > v6 + 4 )
{
*(_BYTE *)(result + 4) += v5[4];
if ( v3 > v6 + 5 )
{
*(_BYTE *)(result + 5) += v5[5];
if ( v3 > v6 + 6 )
{
*(_BYTE *)(result + 6) += v5[6];
if ( v3 > v6 + 7 )
{
*(_BYTE *)(result + 7) += v5[7];
if ( v3 > v6 + 8 )
{
*(_BYTE *)(result + 8) += v5[8];
if ( v3 > v6 + 9 )
{
*(_BYTE *)(result + 9) += v5[9];
if ( v3 > v6 + 10 )
{
*(_BYTE *)(result + 10) += v5[10];
if ( v3 > v6 + 11 )
{
*(_BYTE *)(result + 11) += v5[11];
if ( v3 > v6 + 12 )
{
*(_BYTE *)(result + 12) += v5[12];
if ( v3 > v6 + 13 )
{
*(_BYTE *)(result + 13) += v5[13];
if ( v3 > v6 + 14 )
*(_BYTE *)(result + 14) += v5[14];
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return result;
}