//
// png_format_number from 0x650cbc to 0x650dbc (256 bytes)
//
// 11 xrefs:
// > sub_64D088 @ 0x64d0f8
// > png_convert_to_rfc1123_buffer @ 0x64d914
// > png_convert_to_rfc1123_buffer @ 0x64d95c
// > png_convert_to_rfc1123_buffer @ 0x64d982
// > png_convert_to_rfc1123_buffer @ 0x64d9a8
// > png_convert_to_rfc1123_buffer @ 0x64d9ce
// > png_icc_check_length @ 0x64dca0
// > png_icc_check_length @ 0x64dd14
// > png_warning_parameter_unsigned @ 0x650ec8
// > png_warning_parameter_signed @ 0x650eec
// > png_warning_parameter_signed @ 0x650f06
//
// 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
//
_BYTE *__fastcall png_format_number(unsigned int a1, int a2, int a3, unsigned int a4)
{
_BYTE *v4; // r4
int v5; // r12
bool v6; // r5
int v7; // r2
int v8; // r1
int v9; // r6
char *v10; // r7
unsigned int v13; // r7
unsigned int v14; // r6
bool v15; // zf
v4 = (_BYTE *)(a2 - 1);
v5 = 0;
*(_BYTE *)(a2 - 1) = 0;
if ( a2 - 1 > a1 )
{
v6 = a3 == 5;
v7 = a3 - 1;
v8 = 0;
v9 = 1;
while ( 1 )
{
switch ( v7 )
{
case 0:
goto LABEL_13;
case 1:
v9 = 2;
LABEL_13:
--v4;
v13 = a4 % 0xA;
a4 /= 0xAu;
*v4 = a0123456789abcd_7[v13 + 16];
goto LABEL_6;
case 2:
goto LABEL_5;
case 3:
v9 = 2;
LABEL_5:
--v4;
v10 = &a0123456789abcd_7[a4 & 0xF];
a4 >>= 4;
*v4 = v10[16];
goto LABEL_6;
case 4:
if ( v5 )
{
v14 = a4 % 0xA;
LABEL_16:
--v4;
v5 = 1;
*v4 = a0123456789abcd_7[v14 + 16];
goto LABEL_17;
}
v14 = a4 % 0xA;
if ( a4 % 0xA )
goto LABEL_16;
LABEL_17:
v9 = 5;
a4 /= 0xAu;
LABEL_6:
if ( ++v8 != 5 || !v6 )
goto LABEL_20;
if ( (unsigned int)v4 <= a1 )
return v4;
if ( v5 )
{
*--v4 = 46;
v8 = 5;
LABEL_20:
if ( (unsigned int)v4 <= a1 )
return v4;
v15 = v9 == v8;
if ( v9 <= v8 )
v15 = a4 == 0;
if ( v15 )
return v4;
}
else
{
if ( !a4 )
{
*--v4 = 48;
v8 = 5;
goto LABEL_20;
}
v8 = 5;
}
break;
default:
a4 = 0;
goto LABEL_6;
}
}
}
return v4;
}