//
// png_process_IDAT_data from 0x652f28 to 0x653048 (288 bytes)
//
// 2 xrefs:
// > png_push_read_IDAT @ 0x6530cc
// > png_push_read_IDAT @ 0x65311e
//
// 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 int __fastcall png_process_IDAT_data(unsigned int result, int a2, unsigned int a3)
{
bool v3; // zf
unsigned int v4; // r4
unsigned int v5; // r5
unsigned int v6; // r3
bool v7; // cc
unsigned int v8; // r3
unsigned int v9; // r6
int v10; // r3
int v11; // r3
int v12; // r0
const char *v13; // r1
unsigned int v14; // r1
unsigned int v15; // r2
int v16; // r3
v3 = a2 == 0;
if ( a2 )
v3 = a3 == 0;
if ( v3 )
png_error(result, "No IDAT data (internal error)");
v4 = result;
*(_DWORD *)(result + 324) = a2;
v5 = result + 324;
*(_DWORD *)(result + 328) = a3;
if ( a3 )
{
while ( 1 )
{
if ( (*(_DWORD *)(v4 + 312) & 8) != 0 )
{
v12 = v4;
v13 = "Extra compression data in IDAT";
return png_warning(v12, v13);
}
if ( !*(_DWORD *)(v4 + 340) )
{
v6 = *(unsigned __int8 *)(v4 + 538);
v7 = v6 > 7;
if ( v6 <= 7 )
a3 = *(_DWORD *)(v4 + 468);
else
v6 >>= 3;
if ( v7 )
a2 = *(_DWORD *)(v4 + 468);
else
v6 *= a3;
if ( v7 )
v8 = v6 * a2;
else
v8 = v6 + 7;
*(_DWORD *)(v4 + 336) = *(_DWORD *)(v4 + 484);
if ( !v7 )
v8 >>= 3;
*(_DWORD *)(v4 + 340) = v8 + 1;
}
result = inflate(v5, 2);
v9 = result;
if ( result > 1 )
break;
a3 = *(_DWORD *)(v4 + 336);
if ( a3 != *(_DWORD *)(v4 + 484) )
{
a3 = *(_DWORD *)(v4 + 472);
if ( a3 >= *(_DWORD *)(v4 + 456) || *(unsigned __int8 *)(v4 + 533) > 6u )
{
result = png_warning(v4, "Extra compressed data in IDAT");
v11 = *(_DWORD *)(v4 + 312);
*(_DWORD *)(v4 + 320) = 0;
*(_DWORD *)(v4 + 312) = v11 | 8;
return result;
}
if ( !*(_DWORD *)(v4 + 340) )
result = png_push_process_row(v4);
}
v10 = *(_DWORD *)(v4 + 328);
if ( v9 == 1 )
{
a3 = *(_DWORD *)(v4 + 312) | 8;
*(_DWORD *)(v4 + 312) = a3;
}
if ( !v10 )
return result;
}
v14 = *(_DWORD *)(v4 + 472);
v15 = *(_DWORD *)(v4 + 456);
v16 = *(_DWORD *)(v4 + 312);
*(_DWORD *)(v4 + 320) = 0;
v12 = v4;
*(_DWORD *)(v4 + 312) = v16 | 8;
if ( v14 < v15 && *(unsigned __int8 *)(v4 + 533) <= 6u )
png_error(v4, "Decompression error in IDAT");
v13 = "Truncated compressed data in IDAT";
return png_warning(v12, v13);
}
return result;
}