//
// png_handle_iTXt from 0xe579d0 to 0xe57d08 (824 bytes)
//
// 4 xrefs:
// > png_push_read_chunk @ 0xe45b94
// > png_read_info @ 0xe4985c
// > png_read_end @ 0xe4be14
// > ??> @ 0x577d8
//
// 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:19 +0000
//
__int64 __fastcall png_handle_iTXt(
__int64 a1,
__int64 a2,
unsigned int a3,
int a4,
int a5,
int a6,
int a7,
int a8,
char a9)
{
int v10; // w1
int v13; // w1
int v14; // w0
unsigned __int8 *v15; // x23
size_t v16; // x19
__int64 result; // x0
unsigned __int8 *v18; // x2
unsigned int i; // w1
unsigned int v21; // w0
int v22; // w1
const char *v23; // x1
unsigned __int8 *v24; // x0
unsigned int v25; // w19
unsigned int v26; // w26
unsigned int v27; // w1
unsigned int v28; // w25
unsigned int v29; // w0
__int64 v30; // x24
int v31; // w4
unsigned __int64 v32; // x20
unsigned __int8 *v33; // x20
unsigned __int64 v34; // [xsp+50h] [xbp+50h] BYREF
int v35; // [xsp+58h] [xbp+58h] BYREF
unsigned __int8 *v36; // [xsp+60h] [xbp+60h]
unsigned __int8 *v37; // [xsp+68h] [xbp+68h]
__int64 v38; // [xsp+70h] [xbp+70h]
unsigned __int64 v39; // [xsp+78h] [xbp+78h]
unsigned __int8 *v40; // [xsp+80h] [xbp+80h]
unsigned __int8 *v41; // [xsp+88h] [xbp+88h]
v10 = *(_DWORD *)(a1 + 1180);
if ( v10 )
{
if ( v10 == 1 )
return png_crc_finish((_DWORD *)a1, a3);
v13 = v10 - 1;
*(_DWORD *)(a1 + 1180) = v13;
if ( v13 == 1 )
{
png_crc_finish((_DWORD *)a1, a3);
return png_chunk_benign_error(a1, "no space in chunk cache");
}
}
v14 = *(_DWORD *)(a1 + 356);
if ( (v14 & 1) == 0 )
png_chunk_error(a1, "missing IHDR");
if ( (v14 & 4) == 0 )
{
v15 = *(unsigned __int8 **)(a1 + 1232);
v16 = a3 + 1;
if ( v15 )
goto LABEL_7;
LABEL_25:
v24 = (unsigned __int8 *)png_malloc_base(a1, v16);
v15 = v24;
if ( !v24 )
{
png_chunk_warning(a1, "insufficient memory to read chunk");
png_crc_finish((_DWORD *)a1, a3);
return png_chunk_benign_error(a1, "out of memory");
}
*(_QWORD *)(a1 + 1232) = v24;
*(_QWORD *)(a1 + 1240) = v16;
goto LABEL_8;
}
v15 = *(unsigned __int8 **)(a1 + 1232);
*(_DWORD *)(a1 + 356) = v14 | 8;
v16 = a3 + 1;
if ( !v15 )
goto LABEL_25;
LABEL_7:
if ( v16 > *(_QWORD *)(a1 + 1240) )
{
*(_QWORD *)(a1 + 1232) = 0;
*(_QWORD *)(a1 + 1240) = 0;
png_free(a1, v15);
goto LABEL_25;
}
LABEL_8:
png_crc_read(a1, (__int64)v15, a3);
result = png_crc_finish((_DWORD *)a1, 0);
if ( (_DWORD)result )
return result;
if ( !a3 || !*v15 )
goto LABEL_21;
v18 = v15 + 1;
for ( i = 0; ; ++i )
{
v21 = i + 1;
if ( i + 1 == a3 )
break;
if ( !*v18++ )
goto LABEL_16;
}
v21 = a3;
LABEL_16:
if ( i > 0x4E )
{
LABEL_21:
v23 = "bad keyword";
return png_chunk_benign_error(a1, v23);
}
if ( a3 < v21 + 5 )
goto LABEL_28;
v22 = v15[v21 + 1];
if ( v15[v21 + 1] && (v22 != 1 || v15[v21 + 2]) )
{
v23 = "bad compression info";
return png_chunk_benign_error(a1, v23);
}
v25 = v21 + 3;
v26 = v22 != 0;
v34 = 0;
if ( a3 <= v21 + 3 )
{
v27 = v21 + 3;
}
else
{
v27 = v21 + 3;
if ( v15[v25] )
{
do
++v27;
while ( a3 > v27 && v15[v27] );
}
}
v28 = v27 + 1;
if ( a3 > v27 + 1 && v15[v28] )
{
v29 = v27 + 1;
do
++v29;
while ( a3 > v29 && v15[v29] );
}
else
{
v29 = v27 + 1;
}
v30 = v29 + 1;
if ( ((unsigned int)v30 <= a3) > v26 )
{
v32 = a3 - (unsigned int)v30;
v34 = v32;
goto LABEL_52;
}
if ( (unsigned int)v30 >= a3 || !v26 )
{
LABEL_28:
v23 = "truncated";
return png_chunk_benign_error(a1, v23);
}
v34 = -1;
if ( (unsigned int)sub_E54B1C(a1, a3, v30, &v34) != 1 )
{
v23 = *(const char **)(a1 + 424);
if ( !v23 )
{
v31 = 2;
v15[v34 + v30] = 0;
goto LABEL_47;
}
return png_chunk_benign_error(a1, v23);
}
v15 = *(unsigned __int8 **)(a1 + 1232);
v32 = v34;
LABEL_52:
v33 = &v15[v32];
if ( v26 )
v31 = 2;
else
v31 = 1;
v33[v30] = 0;
LABEL_47:
v35 = v31;
v36 = v15;
v40 = &v15[v25];
v41 = &v15[v28];
v37 = &v15[v30];
v38 = 0;
v39 = v34;
result = png_set_text_2(a1, a2, &v35, 1);
if ( (_DWORD)result )
{
v23 = "insufficient memory";
return png_chunk_benign_error(a1, v23);
}
return result;
}