//
// std::__ndk1::to_wstring from 0xf85618 to 0xf857fc (484 bytes)
//
// 1 xrefs:
// > ??> @ 0xc7a68
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:13:52 +0000
//
__int64 *__usercall std::to_wstring@(long double a1@, __int64 a2@)
{
char v3; // w8
unsigned __int64 v4; // x23
wchar_t *v5; // x0
__int64 *result; // x0
unsigned __int64 v7; // x8
unsigned __int64 v8; // x9
unsigned __int64 v9; // x10
__int128 v10; // q0
double v11; // [xsp+0h] [xbp-60h]
__int128 v12; // [xsp+10h] [xbp-50h] BYREF
void *v13; // [xsp+20h] [xbp-40h]
__int64 v14; // [xsp+28h] [xbp-38h]
v11 = *(double *)&a1;
v14 = *(_QWORD *)(_ReadStatusReg(TPIDR_EL0) + 40);
*(_QWORD *)&v12 = 25;
*((_QWORD *)&v12 + 1) = 20;
v13 = operator new(0x60u);
wmemset((wchar_t *)v13, 0, 0x14u);
*((_DWORD *)v13 + 20) = 0;
std::wstring::append((__int64 *)&v12, 3u, 0);
v3 = v12;
if ( (v12 & 1) != 0 )
v4 = *((_QWORD *)&v12 + 1);
else
v4 = (unsigned __int64)(unsigned __int8)v12 >> 1;
while ( 1 )
{
v5 = (v3 & 1) != 0 ? (wchar_t *)v13 : (wchar_t *)((char *)&v12 + 4);
result = (__int64 *)swprintf(v5, v4 + 1, U"%Lf", v11);
if ( ((unsigned int)result & 0x80000000) == 0 )
break;
v7 = (2 * v4) | 1;
LABEL_11:
v4 = v7;
v8 = *((_QWORD *)&v12 + 1);
if ( (v12 & 1) == 0 )
v8 = (unsigned __int64)(unsigned __int8)v12 >> 1;
if ( v7 <= v8 )
{
if ( (v12 & 1) != 0 )
{
*((_DWORD *)v13 + v7) = 0;
v3 = v12;
*((_QWORD *)&v12 + 1) = v4;
}
else
{
*((_DWORD *)&v12 + v7 + 1) = 0;
LOBYTE(v12) = 2 * v7;
v3 = 2 * v7;
}
}
else
{
std::wstring::append((__int64 *)&v12, v7 - v8, 0);
v3 = v12;
}
}
v7 = (int)result;
if ( (int)result > v4 )
goto LABEL_11;
v9 = *((_QWORD *)&v12 + 1);
if ( (v12 & 1) == 0 )
v9 = (unsigned __int64)(unsigned __int8)v12 >> 1;
if ( (int)result <= v9 )
{
if ( (v12 & 1) != 0 )
{
*((_DWORD *)v13 + (int)result) = 0;
*((_QWORD *)&v12 + 1) = (int)result;
}
else
{
*((_DWORD *)&v12 + (int)result + 1) = 0;
LOBYTE(v12) = 2 * (_BYTE)result;
}
}
else
{
result = std::wstring::append((__int64 *)&v12, (int)result - v9, 0);
}
v10 = v12;
*(_QWORD *)(a2 + 16) = v13;
*(_OWORD *)a2 = v10;
_ReadStatusReg(TPIDR_EL0);
return result;
}