//
// png_do_write_interlace from 0x875ec4 to 0x8760ec (552 bytes)
//
// 1 xrefs:
// > png_write_row @ 0x872000
//
// 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:03:02 +0000
//
unsigned int __fastcall png_do_write_interlace(unsigned int result, char *a2, int a3)
{
int v3; // r6
unsigned int v4; // r8
char *v5; // r4
size_t v6; // r10
unsigned int v7; // r9
char *v8; // r2
unsigned int v9; // r8
char *v10; // r7
bool v11; // zf
char *v12; // r0
char *v13; // r1
bool v14; // cf
unsigned int v15; // r0
unsigned int v16; // r2
unsigned int v17; // r0
char *v18; // r2
unsigned int v19; // r12
unsigned int v20; // r1
char *v21; // r8
int v22; // lr
int v23; // r7
unsigned int v24; // r1
unsigned int v25; // r0
unsigned int v26; // r7
char *v27; // r2
_BYTE *v28; // r0
unsigned int v29; // r2
int v30; // r8
int v31; // r1
unsigned int v32; // r1
int v33; // r2
char *v34; // r0
int v35; // lr
char v36; // r8
unsigned int v37; // r0
unsigned int v38; // r5
unsigned int v39; // r3
unsigned int v40; // [sp+4h] [bp-2Ch]
if ( a3 <= 5 )
{
v3 = result;
v4 = *(unsigned __int8 *)(result + 11);
v5 = a2;
switch ( v4 )
{
case 2u:
v17 = *(_DWORD *)result;
v18 = (char *)&dword_C21A48 + a3;
v19 = (unsigned __int8)v18[40];
if ( v17 <= v19 )
{
v26 = v17;
v24 = (unsigned __int8)v18[48];
v25 = (unsigned __int8)v18[40];
goto LABEL_24;
}
v38 = (unsigned __int8)v18[48];
v20 = (unsigned __int8)v18[40];
v21 = v5;
v22 = 0;
v23 = 6;
do
{
while ( 1 )
{
v22 |= (((int)(unsigned __int8)v5[v20 >> 2] >> (2 * (~(_BYTE)v20 & 3))) & 3) << v23;
if ( v23 )
break;
v20 += v38;
*v21 = v22;
v22 = 0;
++v21;
v23 = 6;
if ( v17 <= v20 )
goto LABEL_21;
}
v20 += v38;
v23 -= 2;
}
while ( v17 > v20 );
LABEL_21:
if ( v23 != 6 )
{
*v21 = v22;
v37 = v19;
v39 = *(_DWORD *)v3;
v4 = *(unsigned __int8 *)(v3 + 11);
goto LABEL_13;
}
break;
case 4u:
v26 = *(_DWORD *)result;
v27 = (char *)&dword_C21A48 + a3;
v19 = (unsigned __int8)v27[40];
if ( *(_DWORD *)result <= v19 )
{
LABEL_23:
v24 = (unsigned __int8)v27[48];
v25 = v19;
LABEL_24:
v16 = (v24 + v26 - 1 - v25) / v24;
*(_DWORD *)v3 = v16;
LABEL_25:
result = (v4 * v16 + 7) >> 3;
*(_DWORD *)(v3 + 4) = result;
return result;
}
v38 = (unsigned __int8)v27[48];
v32 = (unsigned __int8)v27[40];
v33 = *(unsigned __int8 *)(result + 11);
v34 = v5;
v35 = 0;
do
{
while ( 1 )
{
v36 = (v32 & 1) != 0 ? 0 : 4;
v35 |= (((int)(unsigned __int8)v5[v32 >> 1] >> v36) & 0xF) << v33;
if ( v33 )
break;
v32 += v38;
*v34 = v35;
v35 = 0;
++v34;
v33 = 4;
if ( v26 <= v32 )
goto LABEL_41;
}
v32 += v38;
v33 -= 4;
}
while ( v26 > v32 );
LABEL_41:
if ( v33 != 4 )
*v34 = v35;
break;
case 1u:
v26 = *(_DWORD *)result;
v27 = (char *)&dword_C21A48 + a3;
v19 = (unsigned __int8)v27[40];
if ( *(_DWORD *)result > v19 )
{
v38 = (unsigned __int8)v27[48];
v28 = a2;
v29 = (unsigned __int8)v27[40];
v30 = 0;
v31 = 7;
do
{
while ( 1 )
{
v30 |= (((int)(unsigned __int8)v5[v29 >> 3] >> (~(_BYTE)v29 & 7)) & 1) << v31;
if ( v31 )
break;
v29 += v38;
*v28 = v30;
v30 = 0;
++v28;
v31 = 7;
if ( v26 <= v29 )
goto LABEL_31;
}
v29 += v38;
--v31;
}
while ( v26 > v29 );
LABEL_31:
if ( v31 != 7 )
{
*v28 = v30;
v37 = v19;
v39 = *(_DWORD *)v3;
v4 = *(unsigned __int8 *)(v3 + 11);
goto LABEL_13;
}
break;
}
goto LABEL_23;
default:
v6 = v4 >> 3;
v7 = *(_DWORD *)result;
v8 = (char *)&dword_C21A48 + a3;
v40 = (unsigned __int8)v8[40];
if ( *(_DWORD *)result > v40 )
{
v38 = (unsigned __int8)v8[48];
v9 = v40 + v38;
v10 = &a2[v6 * v40];
do
{
v11 = v5 == v10;
v12 = v5;
v13 = v10;
v5 += v6;
v10 += (__int16)v38 * (__int16)v6;
if ( !v11 )
memcpy(v12, v13, v6);
v14 = v9 >= v7;
v9 += v38;
}
while ( !v14 );
v39 = *(_DWORD *)v3;
v37 = v40;
v4 = *(unsigned __int8 *)(v3 + 11);
}
else
{
v37 = (unsigned __int8)v8[40];
v38 = (unsigned __int8)v8[48];
v39 = v7;
}
LABEL_13:
v15 = (v38 + v39 - 1 - v37) / v38;
v16 = v15;
*(_DWORD *)v3 = v15;
if ( v4 > 7 )
{
result = (v4 >> 3) * v15;
*(_DWORD *)(v3 + 4) = result;
return result;
}
goto LABEL_25;
}
v37 = v19;
v39 = *(_DWORD *)v3;
v4 = *(unsigned __int8 *)(v3 + 11);
goto LABEL_13;
}
return result;
}