//
// sub_BDD28C from 0xbdd28c to 0xbddd34 (2728 bytes)
//
// 1 xrefs:
// > png_read_filter_row @ 0xbe2a20
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
unsigned __int64 __fastcall sub_BDD28C(__int64 a1, unsigned __int64 a2, unsigned __int8 *a3)
{
__int64 v3; // x4
unsigned __int64 result; // x0
unsigned __int64 v5; // x3
unsigned __int64 v6; // x4
unsigned __int64 v7; // x5
_BYTE *v8; // x7
__int64 v9; // x6
unsigned __int64 v10; // x10
unsigned __int64 v11; // x8
__int64 v12; // x9
int8x16_t *v13; // x11
unsigned __int64 v14; // x12
uint8x16_t *v15; // x5
int8x16_t *v16; // x13
uint8x16_t v17; // t1
uint8x16_t v18; // q0
int8x16_t v19; // t1
unsigned __int8 *v20; // x5
unsigned __int64 v21; // x6
unsigned __int8 *v22; // x7
int v23; // w5
int v24; // w5
int v25; // w5
int v26; // w5
int v27; // w5
int v28; // w5
int v29; // w5
int v30; // w5
int v31; // w5
int v32; // w5
int v33; // w5
int v34; // w5
int v35; // w5
int v36; // w9
__int64 v37; // x5
unsigned __int64 v38; // x9
__int64 v39; // x10
__int64 v40; // x13
unsigned __int64 v41; // x14
uint8x8_t *v42; // x17
uint8x8_t *v43; // x16
int8x16_t *v44; // x11
uint16x8_t v45; // q4
uint16x8_t v46; // q1
uint16x8_t v47; // q2
uint16x8_t v48; // q0
v3 = *(_QWORD *)(a1 + 8);
result = (unsigned int)((*(unsigned __int8 *)(a1 + 19) + 7) >> 3);
v5 = (int)result;
v6 = v3 - (int)result;
if ( (_DWORD)result )
{
if ( (unsigned __int64)a3 < a2 + 16 && a2 < (unsigned __int64)(a3 + 16) || (unsigned __int64)(int)result <= 0x12 )
{
result = 0;
do
{
*(_BYTE *)(a2 + result) += a3[result] >> 1;
++result;
}
while ( v5 != result );
LABEL_41:
a3 += v5;
a2 += v5;
goto LABEL_42;
}
v7 = -(__int64)a2 & 0xF;
if ( (int)result <= v7 )
v7 = (int)result;
if ( !v7 )
{
v8 = a3;
result = a2;
v9 = 0;
goto LABEL_22;
}
v8 = a3 + 1;
*(_BYTE *)a2 += *a3 >> 1;
result = a2 + 1;
if ( v7 != 1 )
{
v8 = a3 + 2;
result = a2 + 2;
*(_BYTE *)(a2 + 1) += a3[1] >> 1;
if ( v7 != 2 )
{
v8 = a3 + 3;
result = a2 + 3;
*(_BYTE *)(a2 + 2) += a3[2] >> 1;
if ( v7 != 3 )
{
v8 = a3 + 4;
result = a2 + 4;
*(_BYTE *)(a2 + 3) += a3[3] >> 1;
if ( v7 != 4 )
{
v8 = a3 + 5;
result = a2 + 5;
*(_BYTE *)(a2 + 4) += a3[4] >> 1;
if ( v7 != 5 )
{
v8 = a3 + 6;
result = a2 + 6;
*(_BYTE *)(a2 + 5) += a3[5] >> 1;
if ( v7 == 6 )
{
v9 = 6;
LABEL_22:
v10 = v5 - v7;
v11 = ((v5 - v7 - 16) >> 4) + 1;
v12 = 16 * v11;
if ( v5 - 1 - v7 <= 0xE )
goto LABEL_99;
v13 = (int8x16_t *)(a2 + v7);
v14 = 0;
v15 = (uint8x16_t *)&a3[v7];
v16 = v13;
do
{
v17 = *v15++;
v18 = v17;
++v14;
v19 = *v16++;
*v13++ = vaddq_s8(vshrq_n_u8(v18, 1u), v19);
}
while ( v14 < v11 );
v9 += v12;
result += v12;
v8 += v12;
if ( v10 != v12 )
{
LABEL_99:
*(_BYTE *)result += *v8 >> 1;
if ( v5 > v9 + 1 )
{
*(_BYTE *)(result + 1) += v8[1] >> 1;
if ( v5 > v9 + 2 )
{
*(_BYTE *)(result + 2) += v8[2] >> 1;
if ( v5 > v9 + 3 )
{
*(_BYTE *)(result + 3) += v8[3] >> 1;
if ( v5 > v9 + 4 )
{
*(_BYTE *)(result + 4) += v8[4] >> 1;
if ( v5 > v9 + 5 )
{
*(_BYTE *)(result + 5) += v8[5] >> 1;
if ( v5 > v9 + 6 )
{
*(_BYTE *)(result + 6) += v8[6] >> 1;
if ( v5 > v9 + 7 )
{
*(_BYTE *)(result + 7) += v8[7] >> 1;
if ( v5 > v9 + 8 )
{
*(_BYTE *)(result + 8) += v8[8] >> 1;
if ( v5 > v9 + 9 )
{
*(_BYTE *)(result + 9) += v8[9] >> 1;
if ( v5 > v9 + 10 )
{
*(_BYTE *)(result + 10) += v8[10] >> 1;
if ( v5 > v9 + 11 )
{
*(_BYTE *)(result + 11) += v8[11] >> 1;
if ( v5 > v9 + 12 )
{
*(_BYTE *)(result + 12) += v8[12] >> 1;
if ( v5 > v9 + 13 )
{
*(_BYTE *)(result + 13) += v8[13] >> 1;
if ( v5 > v9 + 14 )
*(_BYTE *)(result + 14) += v8[14] >> 1;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
goto LABEL_41;
}
v8 = a3 + 7;
result = a2 + 7;
*(_BYTE *)(a2 + 6) += a3[6] >> 1;
if ( v7 != 7 )
{
v8 = a3 + 8;
result = a2 + 8;
*(_BYTE *)(a2 + 7) += a3[7] >> 1;
if ( v7 != 8 )
{
v8 = a3 + 9;
result = a2 + 9;
*(_BYTE *)(a2 + 8) += a3[8] >> 1;
if ( v7 != 9 )
{
v8 = a3 + 10;
result = a2 + 10;
*(_BYTE *)(a2 + 9) += a3[9] >> 1;
if ( v7 != 10 )
{
v8 = a3 + 11;
result = a2 + 11;
*(_BYTE *)(a2 + 10) += a3[10] >> 1;
if ( v7 != 11 )
{
v8 = a3 + 12;
result = a2 + 12;
*(_BYTE *)(a2 + 11) += a3[11] >> 1;
if ( v7 != 12 )
{
v8 = a3 + 13;
result = a2 + 13;
*(_BYTE *)(a2 + 12) += a3[12] >> 1;
if ( v7 != 13 )
{
v8 = a3 + 14;
result = a2 + 14;
*(_BYTE *)(a2 + 13) += a3[13] >> 1;
if ( v7 == 15 )
{
v8 = a3 + 15;
result = a2 + 15;
v9 = 15;
*(_BYTE *)(a2 + 14) += a3[14] >> 1;
}
else
{
v9 = 14;
}
goto LABEL_22;
}
}
}
}
}
}
}
}
}
}
}
}
v9 = v7;
goto LABEL_22;
}
LABEL_42:
if ( !v6 )
return result;
v20 = (unsigned __int8 *)(a2 - v5);
if ( a2 - v5 < a2 + 16 && (__int64)(16 - v5) > 0
|| a2 < (unsigned __int64)(a3 + 16) && (unsigned __int64)a3 < a2 + 16
|| v6 <= 0x11 )
{
for ( result = 0; result != v6; ++result )
*(_BYTE *)(a2 + result) += (a3[result] + (unsigned int)v20[result]) >> 1;
return result;
}
v21 = -(__int64)a2 & 0xF;
if ( v21 > v6 )
v21 = v6;
if ( v21 )
{
v22 = a3 + 1;
*(_BYTE *)a2 += (*a3 + (unsigned int)*v20) >> 1;
result = a2 + 1;
if ( v21 == 1 )
goto LABEL_85;
v23 = *(unsigned __int8 *)(result - v5);
v22 = a3 + 2;
result = a2 + 2;
*(_BYTE *)(a2 + 1) += ((unsigned int)a3[1] + v23) >> 1;
if ( v21 == 2 )
goto LABEL_85;
v24 = *(unsigned __int8 *)(result - v5);
v22 = a3 + 3;
result = a2 + 3;
*(_BYTE *)(a2 + 2) += ((unsigned int)a3[2] + v24) >> 1;
if ( v21 == 3 )
goto LABEL_85;
v25 = *(unsigned __int8 *)(result - v5);
v22 = a3 + 4;
result = a2 + 4;
*(_BYTE *)(a2 + 3) += ((unsigned int)a3[3] + v25) >> 1;
if ( v21 == 4 )
goto LABEL_85;
v26 = *(unsigned __int8 *)(result - v5);
v22 = a3 + 5;
result = a2 + 5;
*(_BYTE *)(a2 + 4) += ((unsigned int)a3[4] + v26) >> 1;
if ( v21 == 5 )
goto LABEL_85;
v27 = *(unsigned __int8 *)(result - v5);
v22 = a3 + 6;
result = a2 + 6;
*(_BYTE *)(a2 + 5) += ((unsigned int)a3[5] + v27) >> 1;
if ( v21 == 6 )
{
v37 = 6;
goto LABEL_63;
}
v28 = *(unsigned __int8 *)(result - v5);
v22 = a3 + 7;
result = a2 + 7;
*(_BYTE *)(a2 + 6) += ((unsigned int)a3[6] + v28) >> 1;
if ( v21 == 7 )
goto LABEL_85;
v29 = *(unsigned __int8 *)(result - v5);
v22 = a3 + 8;
result = a2 + 8;
*(_BYTE *)(a2 + 7) += ((unsigned int)a3[7] + v29) >> 1;
if ( v21 == 8 )
goto LABEL_85;
v30 = *(unsigned __int8 *)(result - v5);
v22 = a3 + 9;
result = a2 + 9;
*(_BYTE *)(a2 + 8) += ((unsigned int)a3[8] + v30) >> 1;
if ( v21 == 9 )
goto LABEL_85;
v31 = *(unsigned __int8 *)(result - v5);
v22 = a3 + 10;
result = a2 + 10;
*(_BYTE *)(a2 + 9) += ((unsigned int)a3[9] + v31) >> 1;
if ( v21 == 10 )
goto LABEL_85;
v32 = *(unsigned __int8 *)(result - v5);
v22 = a3 + 11;
result = a2 + 11;
*(_BYTE *)(a2 + 10) += ((unsigned int)a3[10] + v32) >> 1;
if ( v21 == 11 )
goto LABEL_85;
v33 = *(unsigned __int8 *)(result - v5);
v22 = a3 + 12;
result = a2 + 12;
*(_BYTE *)(a2 + 11) += ((unsigned int)a3[11] + v33) >> 1;
if ( v21 == 12
|| (v34 = *(unsigned __int8 *)(result - v5),
v22 = a3 + 13,
result = a2 + 13,
*(_BYTE *)(a2 + 12) += ((unsigned int)a3[12] + v34) >> 1,
v21 == 13) )
{
LABEL_85:
v37 = v21;
}
else
{
v35 = *(unsigned __int8 *)(result - v5);
v22 = a3 + 14;
result = a2 + 14;
*(_BYTE *)(a2 + 13) += ((unsigned int)a3[13] + v35) >> 1;
if ( v21 == 15 )
{
v36 = *(unsigned __int8 *)(result - v5);
v22 = a3 + 15;
result = a2 + 15;
v37 = 15;
*(_BYTE *)(a2 + 14) += ((unsigned int)a3[14] + v36) >> 1;
}
else
{
v37 = 14;
}
}
}
else
{
v22 = a3;
result = a2;
v37 = 0;
}
LABEL_63:
v38 = ((v6 - v21 - 16) >> 4) + 1;
v39 = 16 * v38;
if ( v6 - 1 - v21 <= 0xE )
goto LABEL_67;
v40 = 0;
v41 = 0;
do
{
v42 = (uint8x8_t *)&a3[v40 + v21];
v43 = (uint8x8_t *)(a2 + v40 + v21 - v5);
v44 = (int8x16_t *)(a2 + v40 + v21);
++v41;
v40 += 16;
v45 = vmovl_u8((uint8x8_t)v42->n64_u64[0]);
v46 = vmovl_u8((uint8x8_t)v43->n64_u64[0]);
v47 = vmovl_high_u8(*(uint8x16_t *)v42->n64_u64);
v48 = vmovl_high_u8(*(uint8x16_t *)v43->n64_u64);
*v44 = vaddq_s8(
*v44,
vmovn_hight_s16(
vmovn_s16(
vmovn_hight_s32(
vmovn_s32(vshrq_n_s32(vaddl_u16((uint16x4_t)v46.n128_u64[0], (uint16x4_t)v45.n128_u64[0]), 1u)),
vshrq_n_s32(vaddl_high_u16(v46, v45), 1u))),
vmovn_hight_s32(
vmovn_s32(vshrq_n_s32(vaddl_u16((uint16x4_t)v48.n128_u64[0], (uint16x4_t)v47.n128_u64[0]), 1u)),
vshrq_n_s32(vaddl_high_u16(v48, v47), 1u))));
}
while ( v41 < v38 );
v37 += v39;
result += v39;
v22 += v39;
if ( v6 - v21 != v39 )
{
LABEL_67:
*(_BYTE *)result += (*v22 + (unsigned int)*(unsigned __int8 *)(result - v5)) >> 1;
if ( v6 > v37 + 1 )
{
*(_BYTE *)(result + 1) += (v22[1] + (unsigned int)*(unsigned __int8 *)(result - v5 + 1)) >> 1;
if ( v6 > v37 + 2 )
{
*(_BYTE *)(result + 2) += (v22[2] + (unsigned int)*(unsigned __int8 *)(result + 2 - v5)) >> 1;
if ( v6 > v37 + 3 )
{
*(_BYTE *)(result + 3) += (v22[3] + (unsigned int)*(unsigned __int8 *)(result + 3 - v5)) >> 1;
if ( v6 > v37 + 4 )
{
*(_BYTE *)(result + 4) += (v22[4] + (unsigned int)*(unsigned __int8 *)(result + 4 - v5)) >> 1;
if ( v6 > v37 + 5 )
{
*(_BYTE *)(result + 5) += (v22[5] + (unsigned int)*(unsigned __int8 *)(result + 5 - v5)) >> 1;
if ( v6 > v37 + 6 )
{
*(_BYTE *)(result + 6) += (v22[6] + (unsigned int)*(unsigned __int8 *)(result + 6 - v5)) >> 1;
if ( v6 > v37 + 7 )
{
*(_BYTE *)(result + 7) += (v22[7] + (unsigned int)*(unsigned __int8 *)(result + 7 - v5)) >> 1;
if ( v6 > v37 + 8 )
{
*(_BYTE *)(result + 8) += (v22[8] + (unsigned int)*(unsigned __int8 *)(result + 8 - v5)) >> 1;
if ( v6 > v37 + 9 )
{
*(_BYTE *)(result + 9) += (v22[9] + (unsigned int)*(unsigned __int8 *)(result + 9 - v5)) >> 1;
if ( v6 > v37 + 10 )
{
*(_BYTE *)(result + 10) += (v22[10] + (unsigned int)*(unsigned __int8 *)(result + 10 - v5)) >> 1;
if ( v6 > v37 + 11 )
{
*(_BYTE *)(result + 11) += (v22[11] + (unsigned int)*(unsigned __int8 *)(result + 11 - v5)) >> 1;
if ( v6 > v37 + 12 )
{
*(_BYTE *)(result + 12) += (v22[12] + (unsigned int)*(unsigned __int8 *)(result + 12 - v5)) >> 1;
if ( v6 > v37 + 13 )
{
*(_BYTE *)(result + 13) += (v22[13] + (unsigned int)*(unsigned __int8 *)(result + 13 - v5)) >> 1;
if ( v6 > v37 + 14 )
*(_BYTE *)(result + 14) += (v22[14]
+ (unsigned int)*(unsigned __int8 *)(result + 14 - v5)) >> 1;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return result;
}