//
// png_image_finish_read from 0x8679a0 to 0x867ab2 (274 bytes)
//
// 0 xrefs:
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:02:48 +0000
//
_DWORD *__fastcall png_image_finish_read(_DWORD *result, int a2, int a3, int a4, int a5)
{
_DWORD *v5; // r4
int v6; // r5
int v8; // r2
unsigned int v9; // r0
bool v10; // zf
bool v11; // zf
int v12; // r5
_DWORD *v13; // [sp+4h] [bp-2Ch] BYREF
int v14; // [sp+8h] [bp-28h]
int v15; // [sp+Ch] [bp-24h]
int v16; // [sp+10h] [bp-20h]
int v17; // [sp+14h] [bp-1Ch]
int v18; // [sp+18h] [bp-18h]
int v19; // [sp+1Ch] [bp-14h]
int v20; // [sp+20h] [bp-10h]
int v21; // [sp+24h] [bp-Ch]
int v22; // [sp+28h] [bp-8h]
int v23; // [sp+2Ch] [bp-4h]
v5 = result;
if ( !result )
return result;
v6 = result[1];
if ( v6 != 1 )
return (_DWORD *)png_image_error((int)result, (int)"png_image_finish_read: damaged PNG_IMAGE_VERSION");
if ( !a4 )
{
if ( (result[4] & 8) == 0 )
v6 = (result[4] & 3) + 1;
a4 = result[2] * v6;
}
v8 = *result;
v9 = abs32(a4);
v10 = a3 == 0;
if ( a3 )
v10 = v8 == 0;
if ( v10 )
return (_DWORD *)png_image_error((int)v5, (int)"png_image_finish_read: invalid argument");
if ( (v5[4] & 8) == 0 )
{
if ( v9 >= v5[2] * ((v5[4] & 3u) + 1) )
{
v15 = a4;
v18 = 0;
v19 = 0;
v20 = 0;
v21 = 0;
v22 = 0;
v23 = 0;
v13 = v5;
v14 = a3;
v16 = a5;
v17 = a2;
v12 = png_safe_execute((int)v5, sub_865DE8, (int)&v13);
LABEL_15:
png_image_free((int)v5);
return (_DWORD *)v12;
}
return (_DWORD *)png_image_error((int)v5, (int)"png_image_finish_read: invalid argument");
}
if ( v9 < v5[2] )
return (_DWORD *)png_image_error((int)v5, (int)"png_image_finish_read: invalid argument");
v11 = a5 == 0;
if ( a5 )
v11 = v5[6] == 0;
if ( !v11 )
{
v15 = a4;
v13 = v5;
v18 = 0;
v19 = 0;
v20 = 0;
v21 = 0;
v22 = 0;
v23 = 0;
v14 = a3;
v16 = a5;
v17 = a2;
v12 = png_safe_execute((int)v5, (int (__fastcall *)(int))sub_8644A4, (int)&v13);
if ( v12 )
v12 = png_safe_execute((int)v5, sub_866A70, (int)&v13) != 0;
goto LABEL_15;
}
return (_DWORD *)png_image_error((int)v5, (int)"png_image_finish_read[color-map]: no color-map");
}