//
// fmt::BasicWriter::PrepareBufferForInt from 0x2e0478 to 0x2e0614 (412 bytes)
//
// 5 xrefs:
// > fmt::BasicWriter::PrepareBufferForInt @ 0x2e04c8
// > fmt::BasicWriter::PrepareBufferForInt @ 0x2e0506
// > fmt::BasicWriter::PrepareBufferForInt @ 0x60be8a
// > fmt::BasicWriter::PrepareBufferForInt @ 0x60bec0
// > fmt::internal::FormatSystemErrorMessage @ 0x60ca44
//
// 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::BasicWriter::PrepareBufferForInt(
unsigned int *a1,
int a2,
unsigned int *a3,
_BYTE *a4,
int a5)
{
int v8; // r4
unsigned int v9; // r3
unsigned int v10; // r7
unsigned int v11; // r10
size_t v13; // r5
void *v14; // r0
int v15; // r11
void *v16; // r0
int v17; // r5
unsigned int v18; // r1
unsigned int v19; // r11
unsigned int v20; // r3
void *v21; // r11
unsigned int v22; // r2
char *v23; // r8
char *v24; // r11
char *v25; // r0
unsigned int v26; // [sp+10h] [bp-1Ch]
unsigned int v27; // [sp+10h] [bp-1Ch]
unsigned int v28; // [sp+14h] [bp-18h]
_DWORD v29[3]; // [sp+18h] [bp-14h] BYREF
v8 = a5;
v9 = *a3;
v10 = a3[1];
v11 = a3[2];
if ( a2 >= -1 )
{
v17 = a2 + a5;
v18 = a1[1];
v19 = *a1;
if ( v9 > a2 + a5 )
{
v22 = v9 + v19;
if ( v9 + v19 > v18 )
{
v28 = v9;
v27 = v9 + v19;
fmt::internal::Array::grow((int)a1, v9 + v19);
v9 = v28;
v22 = v27;
}
*a1 = v22;
v23 = (char *)(a1[2] + v19);
v24 = &v23[v9];
if ( v11 == 1 )
{
std::__copy_move::__copy_m(a4, &a4[a5], v23);
v24 = (char *)memset(&v23[v17], (unsigned __int8)v10, v24 - &v23[v17]);
}
else if ( v11 == 3 )
{
v25 = (char *)fmt::BasicWriter::FillPadding(v23, v9, a2 + a5, (unsigned __int8)v10);
v24 = &v25[v17];
std::__copy_move::__copy_m(a4, &a4[a5], v25);
}
else
{
if ( v11 == 4 )
{
if ( a5 )
{
v17 = a2;
v23 = (char *)std::__copy_move::__copy_m(a4, &a4[a5], v23);
}
}
else
{
std::__copy_move::__copy_m(a4, &a4[a5], &v24[-v17]);
}
memset(v23, (unsigned __int8)v10, &v24[-v17] - v23);
}
return (int)(v24 - 1);
}
else
{
if ( v17 + v19 > v18 )
fmt::internal::Array::grow((int)a1, v17 + v19);
v20 = a1[2];
*a1 = v17 + v19;
v21 = (void *)(v19 + v20);
std::__copy_move::__copy_m(a4, &a4[a5], v21);
return (int)v21 + v17 - 1;
}
}
else
{
if ( a5 && a4[a5 - 1] == 48 )
v8 = a5 - 1;
v29[1] = 48;
v29[0] = v8 - 1;
v29[2] = 4;
if ( v8 - 1 < v9 )
{
if ( v9 > a1[1] )
{
v26 = v9;
fmt::internal::Array::grow((int)a1, v9);
v9 = v26;
}
v13 = v9 - (v8 - 1);
if ( v11 != 1 )
{
v14 = (void *)fmt::BasicWriter::GrowBuffer(a1, v9 - (v8 - 1));
memset(v14, (unsigned __int8)v10, v13);
}
v15 = fmt::BasicWriter::PrepareBufferForInt(a1, a2, v29, a4, v8);
if ( v11 == 1 )
{
v16 = (void *)fmt::BasicWriter::GrowBuffer(a1, v13);
memset(v16, (unsigned __int8)v10, v13);
}
return v15;
}
else
{
return fmt::BasicWriter::PrepareBufferForInt(a1, a2, v29, a4, v8);
}
}
}