//
// png_do_write_interlace from 0xe645ec to 0xe64934 (840 bytes)
//
// 2 xrefs:
// > png_write_row @ 0xe5d7f4
// > ??> @ 0x66058
//
// 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:25 +0000
//
__int64 __fastcall png_do_write_interlace(__int64 result, unsigned __int8 *a2, int a3)
{
__int64 v4; // x1
unsigned int v5; // w2
__int64 v6; // x20
unsigned int v7; // w19
unsigned int v8; // w26
unsigned int v9; // w25
unsigned int v10; // w22
unsigned int v11; // w24
unsigned __int8 *v12; // x23
unsigned __int64 v13; // x1
unsigned __int8 *v14; // x1
bool v15; // zf
unsigned int v16; // w19
unsigned int v17; // w19
_BYTE *v18; // x3
int v19; // w24
int v20; // w23
_BYTE *v21; // x4
int v22; // w3
int v23; // w23
int v24; // w23
_BYTE *v25; // x4
int v26; // w24
char v27; // w3
unsigned int v28; // w0
if ( a3 <= 5 )
{
v4 = a3;
v5 = *(unsigned __int8 *)(result + 19);
v6 = result;
switch ( v5 )
{
case 2u:
v17 = *(_DWORD *)result;
v9 = byte_11BF700[(int)v4];
if ( *(_DWORD *)result > v9 )
{
LODWORD(result) = byte_11BF700[(int)v4];
v18 = a2;
v19 = 0;
v20 = 6;
v10 = byte_11BF710[(int)v4];
do
{
while ( 1 )
{
v19 |= (((int)a2[(unsigned int)result >> 2] >> (2 * (~(_BYTE)result & 3))) & 3) << v20;
if ( v20 )
break;
result = (unsigned int)result + v10;
*v18 = v19;
v20 = 6;
++v18;
v19 = 0;
if ( v17 <= (unsigned int)result )
goto LABEL_19;
}
result = (unsigned int)result + v10;
v20 -= 2;
}
while ( v17 > (unsigned int)result );
LABEL_19:
if ( v20 != 6 )
{
*v18 = v19;
v5 = *(unsigned __int8 *)(v6 + 19);
v16 = (v10 + *(_DWORD *)v6 - 1 - v9) / v10;
*(_DWORD *)v6 = v16;
if ( v5 > 7 )
goto LABEL_12;
goto LABEL_21;
}
goto LABEL_10;
}
v28 = byte_11BF710[(int)v4];
break;
case 4u:
v17 = *(_DWORD *)result;
v9 = byte_11BF700[v4];
if ( *(_DWORD *)result > v9 )
{
v24 = 4;
LODWORD(result) = byte_11BF700[v4];
v25 = a2;
v26 = 0;
v10 = byte_11BF710[v4];
do
{
while ( 1 )
{
v27 = (result & 1) != 0 ? 0 : v5;
v26 |= (((int)a2[(unsigned int)result >> 1] >> v27) & 0xF) << v24;
if ( v24 )
break;
result = (unsigned int)result + v10;
*v25 = v26;
v24 = 4;
++v25;
v26 = 0;
if ( v17 <= (unsigned int)result )
goto LABEL_37;
}
result = (unsigned int)result + v10;
v24 -= 4;
}
while ( v17 > (unsigned int)result );
LABEL_37:
if ( v24 == 4 )
goto LABEL_10;
*v25 = v26;
v7 = *(_DWORD *)v6;
v5 = *(unsigned __int8 *)(v6 + 19);
goto LABEL_11;
}
v28 = byte_11BF710[v4];
break;
case 1u:
v17 = *(_DWORD *)result;
v9 = byte_11BF700[(int)v4];
if ( *(_DWORD *)result > v9 )
{
LODWORD(result) = byte_11BF700[(int)v4];
v21 = a2;
v22 = 0;
v23 = 7;
v10 = byte_11BF710[(int)v4];
do
{
while ( 1 )
{
v22 |= (((int)a2[(unsigned int)result >> 3] >> (~(_BYTE)result & 7)) & 1) << v23;
if ( v23 )
break;
result = (unsigned int)result + v10;
*v21 = v22;
v23 = 7;
++v21;
v22 = 0;
if ( v17 <= (unsigned int)result )
goto LABEL_27;
}
result = (unsigned int)result + v10;
--v23;
}
while ( v17 > (unsigned int)result );
LABEL_27:
if ( v23 == 7 )
goto LABEL_10;
*v21 = v22;
v7 = *(_DWORD *)v6;
v5 = *(unsigned __int8 *)(v6 + 19);
goto LABEL_11;
}
v28 = byte_11BF710[(int)v4];
break;
default:
v7 = *(_DWORD *)result;
v8 = v5 >> 3;
result = (__int64)byte_11BF710;
v9 = byte_11BF700[v4];
if ( v7 > v9 )
{
v10 = byte_11BF710[v4];
v11 = byte_11BF700[v4];
v12 = a2;
do
{
v13 = v11 * (unsigned __int64)v8;
result = (__int64)v12;
v11 += v10;
v14 = &a2[v13];
v15 = v12 == v14;
v12 += (unsigned __int8)v8;
if ( !v15 )
result = (__int64)memcpy((void *)result, v14, (unsigned __int8)v8);
}
while ( v7 > v11 );
LABEL_10:
v7 = *(_DWORD *)v6;
v5 = *(unsigned __int8 *)(v6 + 19);
goto LABEL_11;
}
v10 = byte_11BF710[v4];
LABEL_11:
v16 = (v10 + v7 - 1 - v9) / v10;
*(_DWORD *)v6 = v16;
if ( v5 > 7 )
{
LABEL_12:
*(_QWORD *)(v6 + 8) = v16 * (unsigned __int64)(v5 >> 3);
return result;
}
LABEL_21:
*(_QWORD *)(v6 + 8) = (v16 * (unsigned __int64)v5 + 7) >> 3;
return 7;
}
v16 = (v28 + v17 - 1 - v9) / v28;
*(_DWORD *)v6 = v16;
goto LABEL_21;
}
return result;
}