//
// png_set_filter from 0xe5e320 to 0xe5e5a8 (648 bytes)
//
// 2 xrefs:
// > sub_E5EAE4 @ 0xe5edd8
// > ??> @ 0xd0df8
//
// 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:22 +0000
//
__int64 __fastcall png_set_filter(__int64 result, int a2, int a3)
{
__int64 v3; // x19
int v4; // w2
_BYTE *v5; // x0
int v6; // w2
v3 = result;
if ( !result )
return result;
if ( (a2 != 64 || (*(_DWORD *)(result + 1104) & 4) == 0) && a2 )
png_error(result, "Unknown custom filter method");
switch ( (char)a3 )
{
case 0:
goto LABEL_23;
case 1:
result = *(_QWORD *)(result + 608);
*(_BYTE *)(v3 + 686) = 16;
a3 = 16;
if ( !result )
return result;
if ( !*(_QWORD *)(v3 + 616) )
goto LABEL_42;
goto LABEL_9;
case 2:
result = *(_QWORD *)(result + 608);
*(_BYTE *)(v3 + 686) = 32;
if ( !result )
return result;
result = *(_QWORD *)(v3 + 624);
a3 = 32;
if ( !result )
goto LABEL_33;
goto LABEL_13;
case 3:
result = *(_QWORD *)(result + 608);
*(_BYTE *)(v3 + 686) = 64;
a3 = 64;
if ( !result )
return result;
result = *(_QWORD *)(v3 + 632);
if ( !result )
goto LABEL_39;
goto LABEL_13;
case 4:
a3 = 128;
*(_BYTE *)(result + 686) = 0x80;
goto LABEL_24;
case 5:
case 6:
case 7:
png_app_error(result, "Unknown row filter for method 0");
LABEL_23:
a3 = 8;
*(_BYTE *)(v3 + 686) = 8;
LABEL_24:
result = *(_QWORD *)(v3 + 608);
if ( !result )
return result;
if ( (a3 & 0x80) != 0 )
goto LABEL_18;
goto LABEL_14;
default:
result = *(_QWORD *)(result + 608);
a3 = (unsigned __int8)a3;
*(_BYTE *)(v3 + 686) = a3;
if ( !result )
return result;
if ( (a3 & 0x10) != 0 && !*(_QWORD *)(v3 + 616) )
{
LABEL_42:
v5 = png_malloc(v3, *(_QWORD *)(v3 + 576) + 1LL);
*(_QWORD *)(v3 + 616) = v5;
a3 = *(unsigned __int8 *)(v3 + 686);
*v5 = 1;
result = a3 & 0x20;
if ( (a3 & 0x20) == 0 )
goto LABEL_11;
}
else
{
LABEL_9:
result = a3 & 0x20;
if ( (a3 & 0x20) == 0 )
goto LABEL_11;
}
result = *(_QWORD *)(v3 + 624);
if ( !result )
{
LABEL_33:
if ( *(_QWORD *)(v3 + 600) )
{
result = (__int64)png_malloc(v3, *(_QWORD *)(v3 + 576) + 1LL);
*(_QWORD *)(v3 + 624) = result;
a3 = *(unsigned __int8 *)(v3 + 686);
*(_BYTE *)result = 2;
if ( (a3 & 0x40) != 0 )
goto LABEL_12;
}
else
{
result = png_warning(v3, "Can't add Up filter after starting");
a3 = *(_BYTE *)(v3 + 686) & 0xDF;
*(_BYTE *)(v3 + 686) = a3;
if ( (a3 & 0x40) != 0 )
goto LABEL_12;
}
LABEL_13:
if ( (a3 & 0x80) == 0 )
goto LABEL_14;
goto LABEL_18;
}
LABEL_11:
if ( (a3 & 0x40) == 0 )
goto LABEL_13;
LABEL_12:
result = *(_QWORD *)(v3 + 632);
if ( result )
goto LABEL_13;
LABEL_39:
if ( !*(_QWORD *)(v3 + 600) )
{
result = png_warning(v3, "Can't add Average filter after starting");
a3 = *(_BYTE *)(v3 + 686) & 0xBF;
*(_BYTE *)(v3 + 686) = a3;
if ( (a3 & 0x80) != 0 )
goto LABEL_18;
LABEL_14:
if ( a3 )
return result;
goto LABEL_15;
}
result = (__int64)png_malloc(v3, *(_QWORD *)(v3 + 576) + 1LL);
*(_QWORD *)(v3 + 632) = result;
a3 = *(unsigned __int8 *)(v3 + 686);
*(_BYTE *)result = 3;
if ( (a3 & 0x80) == 0 )
goto LABEL_14;
LABEL_18:
result = *(_QWORD *)(v3 + 640);
if ( result )
return result;
if ( *(_QWORD *)(v3 + 600) )
{
result = (__int64)png_malloc(v3, *(_QWORD *)(v3 + 576) + 1LL);
*(_QWORD *)(v3 + 640) = result;
v4 = *(unsigned __int8 *)(v3 + 686);
*(_BYTE *)result = 4;
if ( v4 )
return result;
LABEL_15:
result = 8;
*(_BYTE *)(v3 + 686) = 8;
return result;
}
result = png_warning(v3, "Can't add Paeth filter after starting");
v6 = *(_BYTE *)(v3 + 686) & 0x7F;
*(_BYTE *)(v3 + 686) = v6;
if ( !v6 )
goto LABEL_15;
return result;
}
}