//
// fmt::BasicWriter
::PrepareBufferForInt from 0x81e130 to 0x81e2e2 (434 bytes)
//
// 16 xrefs:
// > fmt::BasicWriter::FormatInt @ 0x81e360
// > fmt::BasicWriter::FormatInt @ 0x81e3a8
// > fmt::BasicWriter::FormatInt @ 0x81e3fc
// > fmt::BasicWriter::FormatInt @ 0x81e43a
// > fmt::BasicWriter::FormatInt @ 0x81e508
// > fmt::BasicWriter::FormatInt @ 0x81e564
// > fmt::BasicWriter::FormatInt @ 0x81e5ce
// > fmt::BasicWriter::FormatInt @ 0x81e624
// > fmt::BasicWriter::FormatInt @ 0x81e6e8
// > fmt::BasicWriter::FormatInt @ 0x81e742
// > fmt::BasicWriter::FormatInt @ 0x81e7aa
// > fmt::BasicWriter::FormatInt @ 0x81e7fe
// > fmt::BasicWriter::FormatInt @ 0x81e8b6
// > fmt::BasicWriter::FormatInt @ 0x81e8fc
// > fmt::BasicWriter::FormatInt @ 0x81e94e
// > fmt::BasicWriter::FormatInt @ 0x81e98c
//
// 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 12:01:48 +0000
//
int __fastcall fmt::BasicWriter::PrepareBufferForInt(
unsigned int *a1,
int a2,
int *a3,
unsigned __int8 *a4,
int a5)
{
unsigned __int8 *v5; // r4
int v6; // r6
int v9; // r5
unsigned int v10; // r12
int v11; // r9
int v12; // r8
unsigned int v13; // r6
int v15; // r6
int v16; // r5
int *v17; // r0
int m; // r6
int *v19; // r0
int k; // r3
int v21; // r6
unsigned __int8 *v22; // r5
unsigned int v23; // r0
_DWORD *v24; // r3
int v25; // t1
char *v26; // r0
int *v27; // r2
char *v28; // r3
unsigned __int8 *v29; // r5
int v30; // t1
char *v31; // r2
int v32; // r0
int *v33; // r3
int i; // r0
unsigned __int8 *v35; // r5
_DWORD *v36; // r0
_DWORD *v37; // r3
int v38; // t1
unsigned __int8 *v39; // r0
int *v40; // r1
int v41; // t1
char *v42; // r1
unsigned __int8 *v43; // r5
int v44; // t1
int j; // r6
unsigned int v46; // [sp+Ch] [bp-18h]
int v47; // [sp+Ch] [bp-18h]
int v48[3]; // [sp+10h] [bp-14h] BYREF
v5 = a4;
v6 = a3[4];
v9 = a5;
v10 = *a3;
v11 = a3[2];
v12 = a3[1];
if ( v6 <= a2 )
{
v21 = a2 + a5;
if ( v10 > a2 + a5 )
{
v47 = *a3;
v26 = (char *)fmt::BasicWriter::GrowBuffer(a1, *a3);
v27 = (int *)v26;
v28 = &v26[4 * v47];
if ( v11 == 1 )
{
v29 = &v5[a5];
while ( v5 != v29 )
{
v30 = *v5++;
*(_DWORD *)v26 = v30;
v26 += 4;
}
v31 = (char *)&v27[v21];
v32 = v28 - v31;
v33 = (int *)v31;
for ( i = v32 >> 2; i > 0; --i )
*v33++ = v12;
v28 = v31;
}
else if ( v11 == 3 )
{
v35 = &v5[a5];
v36 = (_DWORD *)fmt::BasicWriter::FillPadding(v26, v47, v21, v12);
v37 = v36;
while ( v5 != v35 )
{
v38 = *v5++;
*v37++ = v38;
}
v28 = (char *)&v36[v21];
}
else
{
if ( v11 == 4 )
{
if ( a5 )
{
v39 = &v5[a5];
v40 = v27;
while ( v5 != v39 )
{
v41 = *v5++;
*v40++ = v41;
}
v27 += a5;
v21 = a2;
}
}
else
{
v42 = &v28[-4 * v21];
v43 = &v5[a5];
while ( v5 != v43 )
{
v44 = *v5++;
*(_DWORD *)v42 = v44;
v42 += 4;
}
}
for ( j = (&v28[-4 * v21] - (char *)v27) >> 2; j > 0; --j )
*v27++ = v12;
}
return (int)(v28 - 4);
}
else
{
v22 = &a4[a5];
v23 = fmt::BasicWriter::GrowBuffer(a1, a2 + a5);
v24 = (_DWORD *)v23;
while ( v5 != v22 )
{
v25 = *v5++;
*v24++ = v25;
}
return v23 + 4 * (v21 + 0x3FFFFFFF);
}
}
else
{
if ( a5 && a4[a5 - 1] == 48 )
v9 = a5 - 1;
v13 = v6 + v9;
v48[1] = 48;
v48[0] = v13;
v48[2] = 4;
if ( v13 < v10 )
{
v46 = v10;
fmt::internal::Array::reserve((int)a1, v10);
v15 = v46 - v13;
if ( v11 != 1 )
{
v19 = (int *)fmt::BasicWriter::GrowBuffer(a1, v15);
for ( k = (4 * v15) >> 2; k > 0; --k )
*v19++ = v12;
}
v16 = fmt::BasicWriter::PrepareBufferForInt(a1, a2, v48, v5, v9);
if ( v11 == 1 )
{
v17 = (int *)fmt::BasicWriter::GrowBuffer(a1, v15);
for ( m = (4 * v15) >> 2; m > 0; --m )
*v17++ = v12;
}
return v16;
}
else
{
return fmt::BasicWriter::PrepareBufferForInt(a1, a2, v48, a4, v9);
}
}
}