//
// std::__ndk1::moneypunct_byname::init from 0xf6207c to 0xf625b0 (1332 bytes)
//
// 5 xrefs:
// > sub_F61FDC @ 0xf62028
// > std::__ndk1::moneypunct_byname::init @ 0xf6255c
// > sub_F6A1A8 @ 0xf6a97c
// > sub_F6B1B0 @ 0xf6b81c
// > ??> @ 0xc4678
//
// 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:27 +0000
//
__int64 __fastcall std::moneypunct_byname::init(__int64 a1, char *a2)
{
__int64 v4; // x22
struct lconv *v5; // x21
int v6; // w8
int v7; // w8
__int64 v8; // x22
size_t v9; // x23
int frac_digits; // w8
__int64 v11; // x23
size_t v12; // x24
__int64 v13; // x23
size_t v14; // x24
__int64 result; // x0
void *exception; // x19
size_t v17; // x0
_QWORD *v18; // x0
std::runtime_error *v19; // x21
std::runtime_error *v20; // x21
std::runtime_error *v21; // x21
char *src; // [xsp+48h] [xbp-208h] BYREF
mbstate_t ps; // [xsp+50h] [xbp-200h] BYREF
__int64 v24[3]; // [xsp+58h] [xbp-1F8h] BYREF
wchar_t dst[4]; // [xsp+70h] [xbp-1E0h] BYREF
__int64 v26; // [xsp+80h] [xbp-1D0h]
__int64 v27; // [xsp+208h] [xbp-48h]
v27 = *(_QWORD *)(_ReadStatusReg(TPIDR_EL0) + 40);
if ( !newlocale() )
{
exception = _cxa_allocate_exception(0x10u);
memset(v24, 0, sizeof(v24));
v17 = strlen(a2);
std::string::__init(v24, a2, v17);
v18 = std::string::insert(v24, 0, "moneypunct_byname failed to construct for ");
v26 = v18[2];
*(_OWORD *)dst = *(_OWORD *)v18;
v18[1] = 0;
v18[2] = 0;
*v18 = 0;
std::runtime_error::runtime_error(exception, dst);
_cxa_throw(
exception,
(struct type_info *)&`typeinfo for'std::runtime_error,
(void (*)(void *))std::overflow_error::~overflow_error);
}
v4 = uselocale();
v5 = localeconv();
if ( v4 )
uselocale();
v6 = *(unsigned __int8 *)v5->mon_decimal_point;
if ( !*v5->mon_decimal_point )
v6 = -1;
*(_DWORD *)(a1 + 16) = v6;
v7 = *(unsigned __int8 *)v5->mon_thousands_sep;
if ( !*v5->mon_thousands_sep )
v7 = -1;
*(_DWORD *)(a1 + 20) = v7;
std::string::assign((__int64 *)(a1 + 24), v5->mon_grouping);
ps = 0;
src = v5->currency_symbol;
v8 = uselocale();
v9 = mbsrtowcs(dst, (const char **)&src, 0x64u, &ps);
if ( v8 )
uselocale();
if ( v9 == -1 )
{
v19 = (std::runtime_error *)_cxa_allocate_exception(0x10u);
std::runtime_error::runtime_error(v19, "locale not supported");
_cxa_throw(
v19,
(struct type_info *)&`typeinfo for'std::runtime_error,
(void (*)(void *))std::overflow_error::~overflow_error);
}
std::wstring::assign(a1 + 48, dst, &dst[v9]);
frac_digits = (unsigned __int8)v5->frac_digits;
if ( frac_digits == 255 )
frac_digits = 0;
*(_DWORD *)(a1 + 120) = frac_digits;
if ( v5->p_sign_posn )
{
ps = 0;
src = v5->positive_sign;
v11 = uselocale();
v12 = mbsrtowcs(dst, (const char **)&src, 0x64u, &ps);
if ( v11 )
uselocale();
if ( v12 == -1 )
{
v20 = (std::runtime_error *)_cxa_allocate_exception(0x10u);
std::runtime_error::runtime_error(v20, "locale not supported");
_cxa_throw(
v20,
(struct type_info *)&`typeinfo for'std::runtime_error,
(void (*)(void *))std::overflow_error::~overflow_error);
}
std::wstring::assign(a1 + 72, dst, &dst[v12]);
}
else
{
std::wstring::assign(a1 + 72, U"()");
}
if ( v5->n_sign_posn )
{
ps = 0;
src = v5->negative_sign;
v13 = uselocale();
v14 = mbsrtowcs(dst, (const char **)&src, 0x64u, &ps);
if ( v13 )
uselocale();
if ( v14 == -1 )
{
v21 = (std::runtime_error *)_cxa_allocate_exception(0x10u);
std::runtime_error::runtime_error(v21, "locale not supported");
_cxa_throw(
v21,
(struct type_info *)&`typeinfo for'std::runtime_error,
(void (*)(void *))std::overflow_error::~overflow_error);
}
std::wstring::assign(a1 + 96, dst, &dst[v14]);
}
else
{
std::wstring::assign(a1 + 96, U"()");
}
std::wstring::basic_string(v24, a1 + 48);
sub_F780A0(
a1 + 124,
v24,
0,
*(unsigned __int16 *)&v5->p_cs_precedes,
HIBYTE(*(unsigned __int16 *)&v5->p_cs_precedes),
(unsigned __int8)v5->p_sign_posn);
sub_F780A0(
a1 + 128,
a1 + 48,
0,
*(unsigned int *)&v5->n_cs_precedes,
(unsigned __int8)BYTE1(*(_DWORD *)&v5->n_cs_precedes),
HIBYTE(*(_DWORD *)&v5->n_cs_precedes));
std::wstring::~wstring(v24);
result = freelocale();
_ReadStatusReg(TPIDR_EL0);
return result;
}