//
// sub_1003A6DB0 from 0x1003a6db0 to 0x1003a7060 (688 bytes)
//
// 1 xrefs:
// > SongInfoLayer::init @ 0x1003a7d94
//
// 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 __usercall sub_1003A6DB0@(__int64 a1@, std::string *a2@)
{
_QWORD *v3; // x0
std::string *v4; // x24
std::string::size_type size; // x25
std::string::size_type v6; // x21
std::string *v7; // x9
std::string::size_type v8; // x21
char *v9; // x24
std::string::size_type v11; // x1
__int64 v12; // x8
__int64 v13; // x20
unsigned __int64 v14; // x21
unsigned __int64 v15; // x22
__int64 v16; // x8
int v17; // w10
const std::string::value_type *v18; // x1
std::string::size_type v19; // x2
const std::string::value_type *v20; // x1
__int64 v22; // [xsp+0h] [xbp-1A0h] BYREF
__int64 v23; // [xsp+8h] [xbp-198h]
__int64 v24; // [xsp+10h] [xbp-190h]
std::string v25; // [xsp+18h] [xbp-188h] BYREF
_QWORD v26[3]; // [xsp+30h] [xbp-170h] BYREF
void (__cdecl **v27)(std::streambuf *__hidden); // [xsp+48h] [xbp-158h]
std::locale v28[9]; // [xsp+50h] [xbp-150h] BYREF
char v29; // [xsp+9Fh] [xbp-101h]
__int64 (__fastcall **v30)(); // [xsp+B0h] [xbp-F0h] BYREF
void **v31; // [xsp+148h] [xbp-58h] BYREF
sub_1000AD484((__int64)v26, a1, 24);
memset(&v25, 0, sizeof(v25));
v22 = 0;
v23 = 0;
v24 = 0;
while ( 1 )
{
v3 = sub_1000AD558(v26, (__int64)&v25, 0x2Cu);
if ( (*((_BYTE *)v3 + *(_QWORD *)(*v3 - 24LL) + 32) & 5) != 0 )
break;
if ( (v25.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v4 = &v25;
else
v4 = (std::string *)v25.__r_.__value_.__r.__words[0];
if ( (v25.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
size = HIBYTE(v25.__r_.__value_.__r.__words[2]);
else
size = v25.__r_.__value_.__l.__size_;
if ( size )
{
v6 = 0;
while ( memchr(" \t\n\r\f\v", v4->__r_.__value_.__s.__data_[v6], 6u) )
{
if ( size == ++v6 )
goto LABEL_13;
}
}
else
{
LABEL_13:
v6 = -1;
}
std::string::erase(&v25, 0, v6);
if ( (v25.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v7 = &v25;
else
v7 = (std::string *)v25.__r_.__value_.__r.__words[0];
if ( (v25.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v8 = HIBYTE(v25.__r_.__value_.__r.__words[2]);
else
v8 = v25.__r_.__value_.__l.__size_;
v9 = (char *)&v7[-1].__r_.__value_.__r.__words[2] + 7;
while ( v8 )
{
if ( !memchr(" \t\n\r\f\v", v9[v8--], 6u) )
{
v11 = v8 + 1;
goto LABEL_25;
}
}
v11 = 0;
LABEL_25:
std::string::erase(&v25, v11, 0xFFFFFFFFFFFFFFFFLL);
sub_100017238((__int64)&v22);
}
a2->__r_.__value_.__r.__words[0] = 0;
a2->__r_.__value_.__l.__size_ = 0;
a2->__r_.__value_.__r.__words[2] = 0;
v12 = v22;
if ( v23 != v22 )
{
v13 = 0;
v14 = 0;
v15 = 1;
do
{
v16 = v12 + v13;
v17 = *(char *)(v16 + 23);
if ( v17 >= 0 )
v18 = (const std::string::value_type *)v16;
else
v18 = *(const std::string::value_type **)v16;
if ( v17 >= 0 )
v19 = *(unsigned __int8 *)(v16 + 23);
else
v19 = *(_QWORD *)(v16 + 8);
std::string::append(a2, v18, v19);
if ( v14 != -1 - 0x5555555555555555LL * ((v23 - v22) >> 3) )
{
if ( 5 * (v15 / 5) - 1 == v14 )
v20 = ",\n";
else
v20 = ", ";
std::string::append(a2, v20);
}
++v14;
v12 = v22;
++v15;
v13 += 24;
}
while ( v14 < 0xAAAAAAAAAAAAAAABLL * ((v23 - v22) >> 3) );
}
v31 = (void **)&v22;
sub_1000177FC(&v31);
if ( SHIBYTE(v25.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v25.__r_.__value_.__l.__data_);
v26[0] = off_1007812D8;
v26[2] = off_100781300;
v30 = off_100781328;
v27 = (void (__cdecl **)(std::streambuf *__hidden))off_1007814C8;
if ( v29 < 0 )
operator delete(v28[7].__locale_);
v27 = &`vtable for'std::streambuf.~basic_streambuf;
std::locale::~locale(v28);
std::iostream::~iostream(v26, off_100781340);
return std::ios::~ios(&v30);
}