//
// sub_873E7C from 0x873e7c to 0x873f68 (236 bytes)
//
// 6 xrefs:
// > png_write_iCCP @ 0x874aca
// > png_write_sPLT @ 0x874c12
// > png_write_tEXt @ 0x875358
// > png_write_zTXt @ 0x875444
// > png_write_iTXt @ 0x875580
// > png_write_pCAL @ 0x875900
//
// 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:00 +0000
//
unsigned int __fastcall sub_873E7C(int a1, char *a2, _BYTE *a3)
{
signed int v3; // r9
char *v5; // r6
unsigned int v6; // r7
int v7; // r0
unsigned int v8; // r4
unsigned __int8 *v9; // lr
_BOOL4 v10; // r5
int v11; // r3
int v12; // r3
_BYTE v14[288]; // [sp-120h] [bp-120h] BYREF
if ( a2 )
{
v3 = 0;
v5 = a2;
v6 = 0;
v7 = 1;
while ( 1 )
{
v8 = (unsigned __int8)*v5;
v9 = (unsigned __int8 *)v5++;
v10 = v8 > 0xA0;
v11 = v8;
if ( v8 )
v11 = 1;
if ( v6 > 0x4E )
v11 = 0;
if ( v8 - 33 <= 0x5D )
v10 = 1;
if ( !v11 )
break;
if ( v10 )
{
*a3 = v8;
++v6;
++a3;
v7 = 0;
}
else if ( v7 )
{
v7 = 1;
if ( !v3 )
v3 = v8;
}
else
{
*a3 = 32;
++v6;
if ( v8 != 32 )
v3 = v8;
++a3;
v7 = 1;
}
}
if ( v6 )
v12 = v7;
else
v12 = 0;
if ( v12 )
{
--v6;
--a3;
if ( !v3 )
v3 = 32;
}
*a3 = 0;
if ( !v6 )
return v6;
if ( *v9 )
{
png_warning(a1, "keyword truncated");
return v6;
}
else
{
if ( !v3 )
return v6;
png_warning_parameter((unsigned int)v14, 1, a2);
png_warning_parameter_signed((unsigned int)v14, 2, 4, v3);
png_formatted_warning(a1, (int)v14, "keyword \"@1\": bad character '0x@2'");
return v6;
}
}
else
{
*a3 = 0;
return 0;
}
}