//
// png_do_invert from 0xe5b56c to 0xe5b974 (1032 bytes)
//
// 3 xrefs:
// > png_do_read_transformations @ 0xe503cc
// > png_do_write_transformations @ 0xe5f510
// > ??> @ 0xd5be0
//
// 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:20 +0000
//
unsigned __int64 __fastcall png_do_invert(unsigned __int64 result, __int64 a2)
{
unsigned __int64 v2; // x5
unsigned __int64 v3; // x2
__int64 v4; // x3
unsigned __int64 v5; // x7
unsigned __int64 v6; // x4
__int64 v7; // x6
int8x16_t *v8; // x2
unsigned __int64 v9; // x1
int8x16_t *v10; // x8
int8x16_t v11; // t1
int v12; // w2
unsigned __int64 v13; // x4
char v14; // w3
char v15; // w2
unsigned __int64 v16; // x3
if ( !*(_BYTE *)(result + 16) )
{
v2 = *(_QWORD *)(result + 8);
if ( !v2 )
return result;
v3 = -a2 & 0xF;
if ( v3 > v2 )
v3 = *(_QWORD *)(result + 8);
if ( v2 > 0x10 )
{
result = a2;
v4 = 0;
if ( !v3 )
{
LABEL_24:
v5 = v2 - v3;
v6 = ((v2 - v3 - 16) >> 4) + 1;
v7 = 16 * v6;
if ( v2 - 1 - v3 <= 0xE )
goto LABEL_28;
v8 = (int8x16_t *)(a2 + v3);
v9 = 0;
v10 = v8;
do
{
v11 = *v8++;
++v9;
*v10++ = vmvnq_s8(v11);
}
while ( v6 > v9 );
result += v7;
v4 += v7;
if ( v5 != v7 )
{
LABEL_28:
*(_BYTE *)result = ~*(_BYTE *)result;
if ( v2 > v4 + 1 )
{
*(_BYTE *)(result + 1) = ~*(_BYTE *)(result + 1);
if ( v2 > v4 + 2 )
{
*(_BYTE *)(result + 2) = ~*(_BYTE *)(result + 2);
if ( v2 > v4 + 3 )
{
*(_BYTE *)(result + 3) = ~*(_BYTE *)(result + 3);
if ( v2 > v4 + 4 )
{
*(_BYTE *)(result + 4) = ~*(_BYTE *)(result + 4);
if ( v2 > v4 + 5 )
{
*(_BYTE *)(result + 5) = ~*(_BYTE *)(result + 5);
if ( v2 > v4 + 6 )
{
*(_BYTE *)(result + 6) = ~*(_BYTE *)(result + 6);
if ( v2 > v4 + 7 )
{
*(_BYTE *)(result + 7) = ~*(_BYTE *)(result + 7);
if ( v2 > v4 + 8 )
{
*(_BYTE *)(result + 8) = ~*(_BYTE *)(result + 8);
if ( v2 > v4 + 9 )
{
*(_BYTE *)(result + 9) = ~*(_BYTE *)(result + 9);
if ( v2 > v4 + 10 )
{
*(_BYTE *)(result + 10) = ~*(_BYTE *)(result + 10);
if ( v2 > v4 + 11 )
{
*(_BYTE *)(result + 11) = ~*(_BYTE *)(result + 11);
if ( v2 > v4 + 12 )
{
*(_BYTE *)(result + 12) = ~*(_BYTE *)(result + 12);
if ( v2 > v4 + 13 )
{
*(_BYTE *)(result + 13) = ~*(_BYTE *)(result + 13);
if ( v2 > v4 + 14 )
*(_BYTE *)(result + 14) = ~*(_BYTE *)(result + 14);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return result;
}
}
else
{
v3 = *(_QWORD *)(result + 8);
}
*(_BYTE *)a2 = ~*(_BYTE *)a2;
result = a2 + 1;
if ( v3 != 1 )
{
result = a2 + 2;
*(_BYTE *)(a2 + 1) = ~*(_BYTE *)(a2 + 1);
if ( v3 != 2 )
{
result = a2 + 3;
*(_BYTE *)(a2 + 2) = ~*(_BYTE *)(a2 + 2);
if ( v3 != 3 )
{
result = a2 + 4;
*(_BYTE *)(a2 + 3) = ~*(_BYTE *)(a2 + 3);
if ( v3 != 4 )
{
result = a2 + 5;
*(_BYTE *)(a2 + 4) = ~*(_BYTE *)(a2 + 4);
if ( v3 != 5 )
{
result = a2 + 6;
*(_BYTE *)(a2 + 5) = ~*(_BYTE *)(a2 + 5);
if ( v3 != 6 )
{
result = a2 + 7;
*(_BYTE *)(a2 + 6) = ~*(_BYTE *)(a2 + 6);
if ( v3 != 7 )
{
result = a2 + 8;
*(_BYTE *)(a2 + 7) = ~*(_BYTE *)(a2 + 7);
if ( v3 != 8 )
{
result = a2 + 9;
*(_BYTE *)(a2 + 8) = ~*(_BYTE *)(a2 + 8);
if ( v3 != 9 )
{
result = a2 + 10;
*(_BYTE *)(a2 + 9) = ~*(_BYTE *)(a2 + 9);
if ( v3 == 10 )
{
v4 = 10;
goto LABEL_23;
}
result = a2 + 11;
*(_BYTE *)(a2 + 10) = ~*(_BYTE *)(a2 + 10);
if ( v3 != 11 )
{
result = a2 + 12;
*(_BYTE *)(a2 + 11) = ~*(_BYTE *)(a2 + 11);
if ( v3 != 12 )
{
result = a2 + 13;
*(_BYTE *)(a2 + 12) = ~*(_BYTE *)(a2 + 12);
if ( v3 != 13 )
{
result = a2 + 14;
*(_BYTE *)(a2 + 13) = ~*(_BYTE *)(a2 + 13);
if ( v3 != 14 )
{
result = a2 + 15;
*(_BYTE *)(a2 + 14) = ~*(_BYTE *)(a2 + 14);
if ( v3 == 16 )
{
result = a2 + 16;
v4 = 16;
*(_BYTE *)(a2 + 15) = ~*(_BYTE *)(a2 + 15);
}
else
{
v4 = 15;
}
LABEL_23:
if ( v3 == v2 )
return result;
goto LABEL_24;
}
}
}
}
}
}
}
}
}
}
}
}
}
v4 = v3;
goto LABEL_23;
}
v12 = *(unsigned __int16 *)(result + 16);
if ( v12 == 2052 )
{
v16 = *(_QWORD *)(result + 8);
if ( v16 )
{
for ( result = 0; result < v16; result += 2LL )
*(_BYTE *)(a2 + result) = ~*(_BYTE *)(a2 + result);
}
}
else if ( v12 == 4100 )
{
v13 = *(_QWORD *)(result + 8);
if ( v13 )
{
result = a2;
do
{
v14 = *(_BYTE *)result;
result += 4LL;
v15 = *(_BYTE *)(result - 3);
*(_BYTE *)(result - 4) = ~v14;
*(_BYTE *)(result - 3) = ~v15;
}
while ( v13 > result - a2 );
}
}
return result;
}