//
// png_handle_tEXt from 0xbe13e8 to 0xbe15c8 (480 bytes)
//
// 4 xrefs:
// > png_push_read_chunk @ 0xbcf998
// > png_read_info @ 0xbd36ac
// > png_read_end @ 0xbd5c6c
// > ??> @ 0xa5510
//
// 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
//
__int64 __fastcall png_handle_tEXt(__int64 a1, __int64 a2, unsigned int a3)
{
int v4; // w1
__int64 v6; // x21
int v7; // w1
int v8; // w0
_BYTE *v9; // x20
size_t v10; // x23
__int64 result; // x0
const char *v12; // x2
const char *v13; // x0
_BYTE *v15; // x0
int v16; // [xsp+48h] [xbp+48h] BYREF
_BYTE *v17; // [xsp+50h] [xbp+50h]
const char *v18; // [xsp+58h] [xbp+58h]
size_t v19; // [xsp+60h] [xbp+60h]
__int64 v20; // [xsp+68h] [xbp+68h]
__int64 v21; // [xsp+70h] [xbp+70h]
__int64 v22; // [xsp+78h] [xbp+78h]
v4 = *(_DWORD *)(a1 + 1180);
v6 = a3;
if ( v4 )
{
if ( v4 == 1 )
return png_crc_finish((_DWORD *)a1, a3);
v7 = v4 - 1;
*(_DWORD *)(a1 + 1180) = v7;
if ( v7 == 1 )
{
png_crc_finish((_DWORD *)a1, a3);
return png_chunk_benign_error(a1, "no space in chunk cache");
}
}
v8 = *(_DWORD *)(a1 + 356);
if ( (v8 & 1) == 0 )
png_chunk_error(a1, "missing IHDR");
if ( (v8 & 4) != 0 )
{
v9 = *(_BYTE **)(a1 + 1232);
*(_DWORD *)(a1 + 356) = v8 | 8;
v10 = a3 + 1;
if ( !v9 )
goto LABEL_17;
}
else
{
v9 = *(_BYTE **)(a1 + 1232);
v10 = a3 + 1;
if ( !v9 )
goto LABEL_17;
}
if ( v10 <= *(_QWORD *)(a1 + 1240) )
goto LABEL_8;
*(_QWORD *)(a1 + 1232) = 0;
*(_QWORD *)(a1 + 1240) = 0;
png_free(a1, v9);
LABEL_17:
v15 = png_malloc_base(a1, v10);
v9 = v15;
if ( !v15 )
{
png_chunk_warning(a1, "insufficient memory to read chunk");
return png_chunk_benign_error(a1, "out of memory");
}
*(_QWORD *)(a1 + 1232) = v15;
*(_QWORD *)(a1 + 1240) = v10;
LABEL_8:
png_crc_read(a1, (__int64)v9, v6);
result = png_crc_finish((_DWORD *)a1, 0);
if ( !(_DWORD)result )
{
v9[v6] = 0;
v12 = &v9[v6];
if ( *v9 )
{
v13 = v9;
while ( *++v13 )
;
}
else
{
v13 = v9;
}
if ( v13 != v12 )
v12 = v13 + 1;
v16 = -1;
v18 = v12;
v17 = v9;
v21 = 0;
v22 = 0;
v20 = 0;
v19 = strlen(v12);
result = png_set_text_2(a1, a2, &v16, 1);
if ( (_DWORD)result )
return png_warning(a1, "Insufficient memory to process text chunk");
}
return result;
}