//
// fmt::internal::PrintfParser::Format from 0x60cd60 to 0x60d0fc (924 bytes)
//
// 1 xrefs:
// > fmt::printf @ 0x60d15e
//
// 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
//
int __fastcall fmt::internal::PrintfParser::Format(_DWORD *a1, unsigned int *a2, _BYTE *a3, int a4, _DWORD *a5)
{
_BYTE *v7; // r6
int v8; // r1
_BYTE *v9; // r2
int v10; // r6
int v11; // r0
unsigned int v12; // r5
_BYTE *v13; // r2
_BYTE *v14; // r0
unsigned int v15; // r3
int v16; // r3
int v17; // r3
_DWORD *v18; // r0
unsigned __int64 v19; // r2
bool v20; // cf
_BYTE *v21; // r3
int v22; // r2
int v23; // r0
int *v24; // r0
_DWORD *v25; // r0
unsigned int v26; // r6
_DWORD *v27; // r5
int v28; // r3
const char *v29; // r2
unsigned int v30; // r3
bool v31; // zf
char *v32; // r3
fmt::internal *v33; // r0
unsigned int v34; // r0
_BYTE *v35; // r8
unsigned int v36; // r0
unsigned int *v37; // r0
const char **v38; // r1
int v40; // [sp+1Ch] [bp-40h]
_BYTE *v41; // [sp+2Ch] [bp-30h] BYREF
const char *v42; // [sp+30h] [bp-2Ch] BYREF
_DWORD v43[2]; // [sp+34h] [bp-28h] BYREF
unsigned int v44; // [sp+3Ch] [bp-20h] BYREF
int v45; // [sp+40h] [bp-1Ch]
int v46; // [sp+44h] [bp-18h]
unsigned int v47; // [sp+48h] [bp-14h]
int v48; // [sp+4Ch] [bp-10h]
char v49; // [sp+50h] [bp-Ch]
v7 = a3;
v41 = a3;
v8 = a5[1];
*a1 = *a5;
a1[1] = v8;
a1[2] = 0;
while ( 1 )
{
v9 = v41;
if ( !*v41 )
return fmt::internal::Array::append(a2, v7, v41);
++v41;
if ( *v9 != 37 )
continue;
if ( v9[1] == 37 )
{
fmt::internal::Array::append(a2, v7, v9 + 1);
v7 = ++v41;
continue;
}
fmt::internal::Array::append(a2, v7, v9);
v44 = 0;
v47 = 0;
v49 = 0;
v42 = nullptr;
v45 = 32;
v48 = -1;
v46 = 2;
v10 = (unsigned __int8)*v41;
if ( (unsigned int)(v10 - 48) <= 9 )
{
v11 = sub_60B8E8(&v41, (int *)&v42);
v12 = v11;
if ( *v41 == 36 )
{
++v41;
goto LABEL_15;
}
if ( v10 == 48 )
v45 = 48;
if ( v11 )
{
v44 = v11;
v12 = -1;
goto LABEL_43;
}
}
v12 = -1;
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
LABEL_15:
v13 = v41;
v14 = ++v41;
v15 = (unsigned __int8)*v13;
if ( v15 == 43 )
{
v16 = v47 | 3;
goto LABEL_26;
}
if ( v15 > 0x2B )
break;
if ( v15 == 32 )
{
v16 = v47 | 1;
}
else
{
if ( v15 != 35 )
goto LABEL_27;
v16 = v47 | 4;
}
LABEL_26:
v47 = v16;
}
if ( v15 != 45 )
break;
v46 = 1;
}
if ( v15 != 48 )
break;
v45 = 48;
}
LABEL_27:
v41 = v13;
v17 = (unsigned __int8)*v13;
if ( (unsigned int)(v17 - 48) > 9 )
{
if ( v17 == 42 )
{
v41 = v14;
v18 = fmt::internal::PrintfParser::HandleArgIndex(a1, 0xFFFFFFFF, &v42);
switch ( *v18 )
{
case 0:
v19 = (int)v18[2];
if ( (int)v18[2] >= 0 )
goto LABEL_39;
goto LABEL_35;
case 1:
v19 = (unsigned int)v18[2];
goto LABEL_39;
case 2:
v19 = *((_QWORD *)v18 + 1);
if ( (int)v18[3] < 0 )
{
LABEL_35:
v20 = (_DWORD)v19 == 0;
LODWORD(v19) = -(int)v19;
HIDWORD(v19) -= 2 * HIDWORD(v19) + !v20;
v46 = 1;
}
goto LABEL_39;
case 3:
v19 = *((_QWORD *)v18 + 1);
LABEL_39:
if ( v19 < 0x80000000 )
goto LABEL_40;
if ( !v42 )
v42 = "number is too big in format";
break;
default:
if ( !v42 )
v42 = "width is not integer";
LODWORD(v19) = 0;
LABEL_40:
v44 = v19;
break;
}
}
}
else
{
v44 = sub_60B8E8(&v41, (int *)&v42);
}
LABEL_43:
v21 = v41;
if ( *v41 == 46 )
{
++v41;
v22 = (unsigned __int8)v21[1];
if ( (unsigned int)(v22 - 48) <= 9 )
{
v23 = sub_60B8E8(&v41, (int *)&v42);
goto LABEL_49;
}
if ( v22 == 42 )
{
v41 = v21 + 2;
v24 = (int *)fmt::internal::PrintfParser::HandleArgIndex(a1, 0xFFFFFFFF, &v42);
if ( *v24 > 3 )
{
if ( !v42 )
v42 = "precision is not integer";
}
else
{
v23 = sub_60B8BE(v24);
LABEL_49:
v48 = v23;
}
}
}
v25 = fmt::internal::PrintfParser::HandleArgIndex(a1, v12, &v42);
v26 = v47;
v27 = v25;
if ( (v47 & 4) != 0 && !sub_60B8BE(v25) )
v47 = v26 & 0xFFFFFFFB;
if ( v45 == 48 )
{
if ( (int)*v27 > 5 )
v28 = 32;
else
v28 = 4;
if ( (int)*v27 > 5 )
v45 = v28;
else
v46 = v28;
}
v29 = v41;
v30 = (unsigned __int8)*v41;
if ( v30 == 106 )
goto LABEL_71;
if ( v30 <= 0x6A )
{
if ( v30 != 76 )
{
v31 = v30 == 104;
goto LABEL_69;
}
goto LABEL_71;
}
if ( v30 == 116 || v30 == 122 )
goto LABEL_71;
v31 = v30 == 108;
LABEL_69:
if ( v31 )
LABEL_71:
v29 = ++v41;
v32 = v41;
v7 = ++v41;
v33 = (fmt::internal *)(unsigned __int8)*v32;
v49 = *v32;
switch ( *v27 )
{
case 0:
fmt::BasicWriter::FormatInt(a2, v27[2], (int)&v44);
continue;
case 1:
goto LABEL_97;
case 2:
fmt::BasicWriter::FormatInt(a2, *((_QWORD *)v27 + 1), (int)&v44);
continue;
case 3:
fmt::BasicWriter::FormatInt(a2, *((_QWORD *)v27 + 1), (int)&v44);
continue;
case 4:
fmt::BasicWriter::FormatDouble(a2, *((double *)v27 + 1), (int)&v44);
continue;
case 5:
fmt::BasicWriter::FormatDouble(a2, *((double *)v27 + 1), (int)&v44);
continue;
case 6:
if ( v33 )
{
if ( v33 != (fmt::internal *)((char *)&dword_60 + 3) )
fmt::internal::ReportUnknownType(v33, (char)"char", v29);
}
if ( v44 <= 1 )
{
v36 = fmt::BasicWriter::GrowBuffer(a2, 1);
}
else
{
v40 = (unsigned __int8)v45;
v34 = fmt::BasicWriter::GrowBuffer(a2, v44);
v35 = (_BYTE *)v34;
if ( v46 == 2 )
{
sub_60B970((void *)v34, v44 - 1, v40);
v35 += v44 - 1;
goto LABEL_89;
}
if ( v46 != 3 )
{
sub_60B970((void *)(v34 + 1), v44 - 1, v40);
goto LABEL_89;
}
v36 = (unsigned int)fmt::BasicWriter::FillPadding((char *)v34, v44, 1, v40);
}
v35 = (_BYTE *)v36;
LABEL_89:
*v35 = v27[2];
break;
case 7:
v37 = a2;
v38 = (const char **)(v27 + 2);
goto LABEL_92;
case 8:
v38 = (const char **)v43;
v37 = a2;
v43[0] = &unk_939830;
v43[1] = 0;
LABEL_92:
fmt::BasicWriter::write_str(v37, v38, (int)&v44);
continue;
case 9:
if ( v33 && v33 != (fmt::internal *)&dword_70 )
fmt::internal::ReportUnknownType(v33, (char)"pointer", v29);
v47 = 4;
v49 = 120;
LABEL_97:
fmt::BasicWriter::FormatInt(a2, (fmt::internal *)v27[2], (int *)&v44);
continue;
case 0xA:
if ( v33 )
fmt::internal::ReportUnknownType(v33, (char)"object", v29);
((void (__fastcall *)(unsigned int *, _DWORD, __int16 *))v27[3])(a2, v27[2], &aO1i2r3e45s7t89[9]);
continue;
default:
continue;
}
}
}