//
// fmt::BasicFormatter::format from 0x60d194 to 0x60d47e (746 bytes)
//
// 1 xrefs:
// > fmt::BasicFormatter::Format @ 0x60d514
//
// 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
//
char *__fastcall fmt::BasicFormatter::format(int a1, char *a2, int *a3)
{
int v4; // r1
char *v7; // r1
int v8; // r3
char *v9; // r0
int v10; // r2
int v11; // t1
char *result; // r0
int v13; // lr
unsigned __int8 *v14; // r7
char *v15; // r12
unsigned __int8 *v16; // r0
unsigned int v17; // r1
int v18; // r2
int v19; // r3
int v20; // r3
int v21; // r3
char *v22; // r3
int v23; // r2
_DWORD *v24; // r0
__int64 v25; // r2
char *v26; // r3
char *v27; // r2
int v28; // r3
int v29; // r7
unsigned int v30; // r0
_BYTE *v31; // r4
unsigned int v32; // r0
unsigned int *v33; // r0
const char **v34; // r1
char *v35; // [sp+Ch] [bp-2Ch] BYREF
int v36; // [sp+10h] [bp-28h] BYREF
_DWORD v37[2]; // [sp+14h] [bp-24h] BYREF
unsigned int v38; // [sp+1Ch] [bp-1Ch] BYREF
int v39; // [sp+20h] [bp-18h]
int v40; // [sp+24h] [bp-14h]
int v41; // [sp+28h] [bp-10h]
int v42; // [sp+2Ch] [bp-Ch]
fmt::internal *v43; // [sp+30h] [bp-8h]
v35 = a2;
v39 = 32;
v42 = -1;
v4 = (unsigned __int8)*a2;
v36 = 0;
v38 = 0;
v40 = 0;
v41 = 0;
LOBYTE(v43) = 0;
if ( v4 != 58 )
goto LABEL_53;
if ( *a3 == 10 )
{
((void (__fastcall *)(int, int, char *))a3[3])(a1, a3[2], a2);
v7 = v35;
v8 = 1;
while ( 1 )
{
v9 = v7;
v11 = (unsigned __int8)*v7++;
v10 = v11;
if ( !v11 )
break;
if ( v10 == 123 )
{
++v8;
}
else if ( v10 == 125 && !--v8 )
{
return v9 + 1;
}
}
return v9 + 1;
}
v13 = (unsigned __int8)a2[1];
v14 = (unsigned __int8 *)(a2 + 1);
v35 = a2 + 1;
if ( !v13 )
goto LABEL_28;
v15 = a2 + 2;
while ( 1 )
{
v16 = (unsigned __int8 *)v15--;
v17 = *v16;
if ( v17 == 61 )
{
v18 = 4;
goto LABEL_22;
}
if ( v17 <= 0x3D )
break;
if ( v17 == 62 )
{
v18 = 2;
goto LABEL_22;
}
if ( v17 == 94 )
{
v18 = 3;
goto LABEL_22;
}
LABEL_26:
if ( v14 > (unsigned __int8 *)v15 )
{
v40 = 0;
goto LABEL_28;
}
}
if ( v17 != 60 )
goto LABEL_26;
v18 = 1;
LABEL_22:
v40 = v18;
if ( v16 == v14 )
{
v35 = a2 + 2;
}
else if ( v13 != 125 )
{
v39 = v13;
v35 = a2 + 3;
}
LABEL_28:
v19 = (unsigned __int8)*v35;
switch ( v19 )
{
case '+':
fmt::BasicFormatter::CheckSign(a1, &v35, a3);
v20 = v41 | 3;
LABEL_34:
v41 = v20;
break;
case '-':
fmt::BasicFormatter::CheckSign(a1, &v35, a3);
break;
case ' ':
fmt::BasicFormatter::CheckSign(a1, &v35, a3);
v20 = v41 | 1;
goto LABEL_34;
}
if ( *v35 == 35 )
{
++v35;
v41 |= 4u;
}
v21 = (unsigned __int8)*v35;
if ( (unsigned int)(v21 - 48) <= 9 )
{
if ( v21 == 48 )
{
v39 = 48;
v40 = 4;
}
v38 = sub_60B8E8(&v35, &v36);
}
v22 = v35;
if ( *v35 == 46 )
{
++v35;
v42 = 0;
v23 = (unsigned __int8)v22[1];
if ( (unsigned int)(v23 - 48) > 9 )
{
if ( v23 == 123 )
{
v35 = v22 + 2;
++*(_DWORD *)(a1 + 20);
v24 = (_DWORD *)fmt::BasicFormatter::ParseArgIndex(a1, &v35, 123);
switch ( *v24 )
{
case 0:
case 1:
LODWORD(v25) = v24[2];
break;
case 2:
case 3:
v25 = *((_QWORD *)v24 + 1);
break;
default:
LODWORD(v25) = 0;
break;
}
HIDWORD(v25) = *(_DWORD *)(a1 + 20);
v42 = v25;
*(_DWORD *)(a1 + 20) = HIDWORD(v25) - 1;
}
}
else
{
v42 = sub_60B8E8(&v35, &v36);
}
}
v26 = v35;
if ( *v35 != 125 && *v35 )
{
++v35;
LOBYTE(v43) = *v26;
}
LABEL_53:
v27 = v35;
v28 = *a3;
*(_DWORD *)(a1 + 16) = v35;
switch ( v28 )
{
case 0:
fmt::BasicWriter::FormatInt(*(unsigned int **)a1, a3[2], (int)&v38);
goto LABEL_80;
case 1:
goto LABEL_78;
case 2:
fmt::BasicWriter::FormatInt(*(unsigned int **)a1, *((_QWORD *)a3 + 1), (int)&v38);
goto LABEL_80;
case 3:
fmt::BasicWriter::FormatInt(
*(unsigned int **)a1,
*((_QWORD *)a3 + 1),
(int)&v38);
goto LABEL_80;
case 4:
fmt::BasicWriter::FormatDouble(*(unsigned int **)a1, *((double *)a3 + 1), (int)&v38);
goto LABEL_80;
case 5:
fmt::BasicWriter::FormatDouble(*(unsigned int **)a1, *((double *)a3 + 1), (int)&v38);
goto LABEL_80;
case 6:
if ( (_BYTE)v43 && (unsigned __int8)v43 != 99 )
fmt::internal::ReportUnknownType((fmt::internal *)(unsigned __int8)v43, (char)"char", v27);
if ( v38 <= 1 )
{
v32 = fmt::BasicWriter::GrowBuffer(*(unsigned int **)a1, 1);
}
else
{
v29 = (unsigned __int8)v39;
v30 = fmt::BasicWriter::GrowBuffer(*(unsigned int **)a1, v38);
v31 = (_BYTE *)v30;
if ( v40 == 2 )
{
sub_60B970((void *)v30, v38 - 1, v29);
v31 += v38 - 1;
goto LABEL_70;
}
if ( v40 != 3 )
{
sub_60B970((void *)(v30 + 1), v38 - 1, v29);
goto LABEL_70;
}
v32 = (unsigned int)fmt::BasicWriter::FillPadding((char *)v30, v38, 1, v29);
}
v31 = (_BYTE *)v32;
LABEL_70:
*v31 = a3[2];
LABEL_80:
result = v35;
break;
case 7:
v33 = *(unsigned int **)a1;
v34 = (const char **)(a3 + 2);
goto LABEL_73;
case 8:
v33 = *(unsigned int **)a1;
v34 = (const char **)v37;
v37[0] = &unk_939830;
v37[1] = 0;
LABEL_73:
fmt::BasicWriter::write_str(v33, v34, (int)&v38);
goto LABEL_80;
case 9:
if ( (_BYTE)v43 && (unsigned __int8)v43 != 112 )
fmt::internal::ReportUnknownType((fmt::internal *)(unsigned __int8)v43, (char)"pointer", v27);
v41 = 4;
LOBYTE(v43) = 120;
LABEL_78:
fmt::BasicWriter::FormatInt(
*(unsigned int **)a1,
(fmt::internal *)a3[2],
(int *)&v38);
goto LABEL_80;
case 10:
((void (__fastcall *)(int, int, char *))a3[3])(a1, a3[2], v27 - 1);
goto LABEL_80;
default:
goto LABEL_80;
}
return result;
}