//
// fmt::BasicWriter::FormatDouble from 0xb67db0 to 0xb682ac (1276 bytes)
//
// 3 xrefs:
// > fmt::internal::PrintfParser::Format @ 0xb6abd4
// > fmt::BasicFormatter::format @ 0xb6b2fc
// > ??> @ 0x6e8c8
//
// 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 fmt::BasicWriter::FormatDouble(size_t *a1, unsigned int *a2, long double a3)
{
double v5; // x20
unsigned int v6; // w25
__int64 v7; // x19
int v8; // w22
long double v9; // q0
int v10; // w26
long double v11; // q0
long double v12; // q1
const char *v13; // x1
size_t *v14; // x0
unsigned int v16; // w0
long double v17; // q0
long double v18; // q1
long double v19; // q0
size_t v20; // x27
unsigned int v21; // w22
unsigned __int64 v22; // x1
unsigned int v23; // w0
char *v24; // x1
unsigned int v25; // w0
char *v26; // x0
unsigned __int64 v27; // x2
size_t v28; // x5
size_t v29; // x1
unsigned int v30; // w4
_BYTE *v31; // x24
int v32; // w0
unsigned __int64 v33; // x1
unsigned int v34; // w20
size_t v35; // x19
char v36; // w1
unsigned __int64 v37; // x19
unsigned int v38; // w23
size_t v39; // x22
size_t v40; // x25
size_t v41; // x26
char *v42; // x26
__int64 v43; // x20
unsigned __int64 v44; // x1
unsigned int v45; // [xsp+68h] [xbp+68h]
char format; // [xsp+78h] [xbp+78h] BYREF
char v47; // [xsp+79h] [xbp+79h] BYREF
_BYTE v48[6]; // [xsp+7Ah] [xbp+7Ah] BYREF
v5 = *(double *)&a3;
v6 = *((unsigned __int8 *)a2 + 20);
v7 = *((_QWORD *)&a3 + 1);
if ( v6 <= 0x47 )
{
if ( v6 >= 0x45 )
goto LABEL_14;
if ( !*((_BYTE *)a2 + 20) )
{
v8 = 0;
LOBYTE(v6) = 103;
goto LABEL_5;
}
if ( v6 == 65 )
{
LABEL_14:
v8 = 1;
if ( (COERCE_UNSIGNED_INT64(a3) & 0x8000000000000000LL) != 0 )
goto LABEL_6;
goto LABEL_15;
}
goto LABEL_27;
}
if ( v6 != 97 && (v6 < 0x61 || v6 - 101 > 2) )
{
LABEL_27:
v8 = 0;
fmt::internal::ReportUnknownType(
(fmt::internal *)*((unsigned __int8 *)a2 + 20),
(char)"double",
*(const char **)&a3);
goto LABEL_5;
}
v8 = 0;
LABEL_5:
*(double *)&v9 = v5;
*((_QWORD *)&v9 + 1) = v7;
if ( (COERCE_UNSIGNED_INT64(v9) & 0x8000000000000000LL) != 0 )
{
LABEL_6:
v7 ^= 0x8000000000000000LL;
v10 = 45;
goto LABEL_7;
}
LABEL_15:
v16 = a2[3];
v10 = 0;
if ( (v16 & 1) == 0 )
{
LABEL_7:
*(double *)&v11 = v5;
*(double *)&v12 = v5;
*((_QWORD *)&v11 + 1) = v7;
*((_QWORD *)&v12 + 1) = v7;
if ( v11 != v12 )
{
LABEL_8:
if ( v8 )
v13 = " NAN";
else
v13 = " nan";
goto LABEL_10;
}
goto LABEL_20;
}
*(double *)&v17 = v5;
*(double *)&v18 = v5;
if ( (v16 & 2) != 0 )
v10 = 43;
else
v10 = 32;
*((_QWORD *)&v17 + 1) = v7;
*((_QWORD *)&v18 + 1) = v7;
if ( v17 != v18 )
goto LABEL_8;
LABEL_20:
*(double *)&v19 = v5;
*((_QWORD *)&v19 + 1) = v7;
if ( fabs(v19) > 1.79769313e308 )
{
if ( v8 )
{
v14 = a1;
v13 = " INF";
if ( !v10 )
goto LABEL_11;
goto LABEL_23;
}
v13 = " inf";
LABEL_10:
v14 = a1;
if ( !v10 )
{
LABEL_11:
fmt::BasicWriter::write_str(v14, v13 + 1, 3u, a2);
return _stack_chk_guard;
}
LABEL_23:
*fmt::BasicWriter::write_str(v14, v13, 4u, a2) = v10;
return _stack_chk_guard;
}
v20 = *a1;
v21 = *a2;
if ( v10 )
{
if ( v21 )
{
v44 = v20 + v21;
if ( a1[1] < v44 )
fmt::internal::Array::grow(a1, v44);
--v21;
++v20;
}
else
{
v22 = v20 + 1;
if ( a1[1] < v20 + 1 )
{
++v20;
fmt::internal::Array::grow(a1, v22);
}
else
{
++v20;
}
}
}
v23 = a2[3];
format = 37;
v24 = &v47;
if ( (v23 & 4) != 0 )
{
v24 = v48;
v47 = 35;
}
v25 = a2[2];
if ( v25 == 3 )
{
v21 = 0;
}
else
{
if ( v25 == 1 )
*v24++ = 45;
if ( v21 )
*v24++ = 42;
}
if ( (a2[4] & 0x80000000) != 0 )
{
v26 = v24;
}
else
{
*v24 = 46;
v26 = v24 + 2;
v24[1] = 42;
}
v45 = a2[1];
v26[1] = v6;
v26[2] = 0;
*v26 = 76;
LABEL_43:
v27 = a1[1];
while ( 1 )
{
v28 = a1[2];
v29 = v27 - v20;
v30 = a2[4];
v31 = (_BYTE *)(v28 + v20);
if ( !v21 )
{
if ( (v30 & 0x80000000) != 0 )
v32 = snprintf((char *)(v28 + v20), v29, &format, v5);
else
v32 = snprintf((char *)(v28 + v20), v29, &format, v30, v5);
LABEL_47:
if ( v32 < 0 )
goto LABEL_57;
goto LABEL_48;
}
if ( (v30 & 0x80000000) != 0 )
{
v32 = snprintf((char *)(v28 + v20), v29, &format, v21, v5);
goto LABEL_47;
}
v32 = snprintf((char *)(v28 + v20), v29, &format, v21, v5);
if ( v32 < 0 )
{
LABEL_57:
v27 = a1[1];
v33 = v27 + 1;
goto LABEL_50;
}
LABEL_48:
v27 = a1[1];
if ( v32 + v20 < v27 )
break;
v33 = v20 + 1 + v32;
LABEL_50:
if ( v33 > v27 )
{
fmt::internal::Array::grow(a1, v33);
goto LABEL_43;
}
}
v34 = v32;
v35 = v32;
if ( v10 )
{
if ( (a2[2] & 0xFFFFFFFD) == 0 && *v31 == 32 )
{
v36 = v45;
}
else
{
v36 = v10;
v10 = 0;
}
v34 = v32 + 1;
*(v31 - 1) = v36;
v35 = v32 + 1;
}
if ( a2[2] == 3 && (v38 = *a2, *a2 > v34) )
{
v39 = *a1;
v40 = *a1 + v38;
if ( v40 > a1[1] )
fmt::internal::Array::grow(a1, *a1 + v38);
v41 = a1[2];
*a1 = v40;
v42 = (char *)(v41 + v39);
if ( v34 )
memmove(&v42[(v38 - v34) >> 1], v42, v35);
v43 = *a2;
memset(v42, (unsigned __int8)v45, (v43 - v35) >> 1);
memset(&v42[((v43 - v35) >> 1) + v35], (unsigned __int8)v45, v43 - v35 - ((v43 - v35) >> 1));
}
else
{
if ( v10 || a2[1] != 32 )
{
for ( ; *v31 == 32; ++v31 )
*v31 = v45;
if ( v10 )
*(v31 - 1) = v10;
}
v37 = v35 + *a1;
if ( v37 > a1[1] )
fmt::internal::Array::grow(a1, v37);
*a1 = v37;
}
return _stack_chk_guard;
}