//
// png_handle_zTXt from 0x86e324 to 0x86e49a (374 bytes)
//
// 3 xrefs:
// > png_push_read_chunk @ 0x862c1a
// > png_read_info @ 0x8659c6
// > png_read_end @ 0x8674f0
//
// 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:56 +0000
//
int __fastcall png_handle_zTXt(_DWORD *a1, int a2, size_t byte_count)
{
int v4; // r3
int v7; // r3
int v8; // r3
_BYTE *v9; // r10
int result; // r0
unsigned int v11; // r3
_BYTE *v12; // r5
size_t v14; // r4
_BYTE *v15; // r10
int v16; // r5
const char *v17; // r1
_BYTE *v18; // r0
int v19; // r6
unsigned int v20; // [sp+0h] [bp-20h] BYREF
_DWORD v21[7]; // [sp+4h] [bp-1Ch] BYREF
v4 = a1[214];
if ( v4 )
{
if ( v4 == 1 )
return png_crc_finish(a1, byte_count);
v7 = v4 - 1;
a1[214] = v7;
if ( v7 == 1 )
{
png_crc_finish(a1, byte_count);
return png_chunk_benign_error((int)a1, "no space in chunk cache");
}
}
v8 = a1[77];
if ( (v8 & 1) == 0 )
png_chunk_error((int)a1, "missing IHDR");
v9 = (_BYTE *)a1[222];
if ( (v8 & 4) != 0 )
a1[77] = v8 | 8;
if ( v9 )
{
if ( byte_count <= a1[223] )
goto LABEL_9;
a1[222] = 0;
a1[223] = 0;
png_free((int)a1, v9);
}
v18 = png_malloc_base((int)a1, byte_count);
v9 = v18;
if ( !v18 )
{
png_crc_finish(a1, byte_count);
return png_chunk_benign_error((int)a1, "out of memory");
}
a1[222] = v18;
a1[223] = byte_count;
LABEL_9:
png_crc_read(a1, (int)v9, byte_count);
result = png_crc_finish(a1, 0);
if ( result )
return result;
if ( !byte_count )
{
v17 = "bad keyword";
return png_chunk_benign_error((int)a1, v17);
}
if ( !*v9 )
{
v17 = "bad keyword";
return png_chunk_benign_error((int)a1, v17);
}
v11 = 0;
v12 = v9;
while ( 1 )
{
v14 = v11 + 1;
if ( v11 + 1 == byte_count )
break;
if ( !*++v12 )
goto LABEL_17;
++v11;
}
v14 = byte_count;
LABEL_17:
if ( v11 > 0x4E )
{
v17 = "bad keyword";
return png_chunk_benign_error((int)a1, v17);
}
if ( byte_count < v14 + 3 )
{
v17 = "truncated";
return png_chunk_benign_error((int)a1, v17);
}
v15 = &v9[v14];
v16 = (unsigned __int8)v15[1];
if ( v15[1] )
{
v17 = "unknown compression type";
return png_chunk_benign_error((int)a1, v17);
}
v20 = -1;
result = sub_86C418((int)a1, byte_count, v14 + 2, &v20);
if ( result == 1 )
{
v19 = a1[222];
*(_BYTE *)(v14 + v19 + v20 + 2) = v16;
v21[2] = v19 + v14 + 2;
v21[1] = v19;
v21[0] = v16;
v21[4] = v16;
v21[5] = v16;
v21[6] = v16;
v21[3] = v20;
result = png_set_text_2(a1, a2, v21, 1);
if ( result )
{
v17 = "insufficient memory";
return png_chunk_benign_error((int)a1, v17);
}
}
else
{
v17 = (const char *)a1[87];
if ( v17 )
return png_chunk_benign_error((int)a1, v17);
}
return result;
}