//
// fmt::BasicWriter::PrepareBufferForInt from 0x3bf110 to 0x3bf2d8 (456 bytes)
//
// 5 xrefs:
// > fmt::BasicWriter::PrepareBufferForInt @ 0x3bf160
// > fmt::BasicWriter::PrepareBufferForInt @ 0x3bf1ba
// > fmt::internal::FormatSystemErrorMessage @ 0x81cae0
// > fmt::BasicWriter::PrepareBufferForInt @ 0x81cbcc
// > fmt::BasicWriter::PrepareBufferForInt @ 0x81cc08
//
// 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 11:46:29 +0000
//
char *__fastcall fmt::BasicWriter::PrepareBufferForInt(
unsigned int *a1,
int a2,
unsigned int *a3,
const void *a4,
size_t a5)
{
size_t v8; // r4
unsigned int v9; // r3
unsigned int v10; // r8
unsigned int v11; // r10
int v13; // r5
unsigned int v14; // r2
unsigned int v15; // r3
int v16; // r11
void *v17; // r0
int v18; // r11
unsigned int v19; // r1
unsigned int v20; // r5
unsigned int v21; // r3
char *v22; // r3
unsigned int v23; // r2
unsigned int v24; // r1
char *v25; // r7
char *v26; // r5
char *v27; // r11
char *v28; // r0
char *v29; // r5
void *v30; // r0
unsigned int v31; // [sp+10h] [bp-1Ch]
unsigned int v32; // [sp+10h] [bp-1Ch]
unsigned int v33; // [sp+10h] [bp-1Ch]
unsigned int v34; // [sp+14h] [bp-18h]
unsigned int v35; // [sp+14h] [bp-18h]
_DWORD v36[3]; // [sp+18h] [bp-14h] BYREF
v8 = a5;
v9 = *a3;
v10 = a3[1];
v11 = a3[2];
if ( a2 >= -1 )
{
v18 = a2 + a5;
v19 = a1[1];
v20 = *a1;
if ( v9 > a2 + a5 )
{
v23 = v9 + v20;
if ( v9 + v20 > v19 )
{
v35 = v9;
v33 = v9 + v20;
fmt::internal::Array::grow((int)a1, v9 + v20);
v9 = v35;
v23 = v33;
}
v24 = a1[2];
*a1 = v23;
v25 = (char *)(v24 + v20);
v26 = (char *)(v24 + v20 + v9);
if ( v11 == 1 )
{
if ( a5 )
memmove(v25, a4, a5);
v27 = &v25[v18];
if ( v26 - v27 > 0 )
memset(v27, (unsigned __int8)v10, v26 - v27);
v26 = v27;
}
else if ( v11 == 3 )
{
v28 = (char *)fmt::BasicWriter::FillPadding(v25, v9, a2 + a5, (unsigned __int8)v10);
v29 = v28;
if ( a5 )
memmove(v28, a4, a5);
v26 = &v29[v18];
}
else
{
if ( v11 == 4 )
{
if ( a5 )
{
v30 = v25;
v25 += a5;
memmove(v30, a4, a5);
v18 = a2;
}
}
else if ( a5 )
{
memmove(&v26[-v18], a4, a5);
}
if ( &v26[-v18] - v25 > 0 )
memset(v25, (unsigned __int8)v10, &v26[-v18] - v25);
}
return v26 - 1;
}
else
{
if ( v18 + v20 > v19 )
fmt::internal::Array::grow((int)a1, v18 + v20);
v21 = a1[2];
*a1 = v18 + v20;
v22 = (char *)(v21 + v20);
if ( a5 )
v22 = (char *)memmove(v22, a4, a5);
return &v22[v18 - 1];
}
}
else
{
if ( a5 && *((_BYTE *)a4 + a5 - 1) == 48 )
v8 = a5 - 1;
v36[1] = 48;
v36[0] = v8 - 1;
v36[2] = 4;
if ( v8 - 1 < v9 )
{
if ( v9 > a1[1] )
{
v31 = v9;
fmt::internal::Array::grow((int)a1, v9);
v9 = v31;
}
v13 = v9 - (v8 - 1);
if ( v11 != 1 )
{
v14 = *a1;
v15 = v13 + *a1;
if ( v15 > a1[1] )
{
v34 = *a1;
v32 = v13 + *a1;
fmt::internal::Array::grow((int)a1, v32);
v14 = v34;
v15 = v32;
}
*a1 = v15;
if ( v13 > 0 )
memset((void *)(a1[2] + v14), (unsigned __int8)v10, v13);
}
v16 = fmt::BasicWriter::PrepareBufferForInt((int)a1, a2, (int)v36, (int)a4, v8);
if ( v11 == 1 )
{
v17 = (void *)fmt::BasicWriter::GrowBuffer(a1, v13);
if ( v13 > 0 )
memset(v17, (unsigned __int8)v10, v13);
}
return (char *)v16;
}
else
{
return (char *)fmt::BasicWriter::PrepareBufferForInt((int)a1, a2, (int)v36, (int)a4, v8);
}
}
}