//
// fp_format_f_internal from 0x180137c14 to 0x180137d79 (357 bytes)
//
// 3 xrefs:
// > sub_180137D7C @ 0x180137e69
// > sub_180137FE0 @ 0x18013826c
// > ??> @ 0x180203614
//
// 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
//
__int64 __fastcall fp_format_f_internal(
char *const Src,
__int64 a2,
int a3,
struct _strflt *const a4,
bool a5,
struct __crt_locale_pointers *const a6)
{
__int64 v9; // rcx
__int64 v10; // rax
__int64 v11; // rdi
bool v12; // al
char *v13; // rbp
__int64 v14; // r8
char *v15; // rbx
char *v16; // rbp
__int64 v17; // r8
int v18; // eax
int v19; // eax
_QWORD v21[3]; // [rsp+20h] [rbp-28h] BYREF
char v22; // [rsp+38h] [rbp-10h]
_LocaleUpdate::_LocaleUpdate((_LocaleUpdate *)v21, a6);
v9 = *((int *)a4 + 1);
if ( a5 && (_DWORD)v9 - 1 == a3 )
*(_WORD *)&Src[(*(_DWORD *)a4 == 45) - 1 + v9] = 48;
if ( *(_DWORD *)a4 == 45 )
*Src++ = 45;
v10 = *((int *)a4 + 1);
v11 = -1;
if ( (int)v10 > 0 )
{
v15 = &Src[v10];
}
else
{
v12 = !(_DWORD)v10 && **((_BYTE **)a4 + 1) == 48;
if ( a5 && v12 )
{
v13 = Src + 1;
}
else
{
v13 = Src + 1;
v14 = -1;
do
++v14;
while ( Src[v14] );
memmove(Src + 1, Src, v14 + 1);
}
*Src = 48;
v15 = v13;
}
if ( a3 > 0 )
{
v16 = v15 + 1;
v17 = -1;
do
++v17;
while ( v15[v17] );
memmove(v15 + 1, v15, v17 + 1);
*v15 = ***(_BYTE ***)(v21[1] + 248LL);
v18 = *((_DWORD *)a4 + 1);
if ( v18 < 0 )
{
v19 = -v18;
if ( a5 || v19 < a3 )
a3 = v19;
if ( a3 )
{
do
++v11;
while ( v16[v11] );
memmove(&v16[a3], v15 + 1, v11 + 1);
}
memset(v15 + 1, 48, a3);
}
}
if ( v22 )
*(_DWORD *)(v21[0] + 936LL) &= ~2u;
return 0;
}