//
// sub_A586BC from 0xa586bc to 0xa58940 (644 bytes)
//
// 3 xrefs:
// > StarInfoPopup::createFromStringMoons @ 0xa5897c
// > StarInfoPopup::createFromString @ 0xa58b98
// > DemonInfoPopup::createFromString @ 0xa58dc8
//
// 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:00:09 +0000
//
__int64 __fastcall sub_A586BC(unsigned __int8 *a1, __int64 *a2)
{
int v4; // w0
__int64 v5; // x23
_BYTE *v6; // x21
__int64 v7; // x20
unsigned __int64 v8; // x25
int v9; // w1
size_t v10; // x2
__int64 *v11; // x0
char v12; // w1
size_t v13; // x3
unsigned __int8 *v14; // x2
unsigned __int64 v15; // x0
unsigned __int8 *v16; // x3
unsigned __int8 *v17; // x0
__int64 v19; // x2
_BYTE *v20; // x20
__int64 v21; // [xsp+50h] [xbp+50h] BYREF
size_t v22; // [xsp+58h] [xbp+58h]
void *v23; // [xsp+60h] [xbp+60h]
v4 = *a1;
if ( (v4 & 1) == 0 )
{
LODWORD(v5) = v4 >> 1;
if ( !(v4 >> 1) )
goto LABEL_3;
v6 = a1 + 1;
v19 = (__int64)&a1[(int)v5 + 1];
if ( a1 + 1 == (unsigned __int8 *)v19 )
{
v7 = -1;
LABEL_40:
v5 = (int)v5;
goto LABEL_5;
}
LABEL_42:
v20 = v6;
if ( *v6 == 44 )
{
v7 = 0;
}
else
{
do
{
if ( (_BYTE *)v19 == ++v20 )
{
v7 = -1;
goto LABEL_47;
}
}
while ( *v20 != 44 );
v7 = v20 - v6;
}
LABEL_47:
LODWORD(v5) = v4 >> 1;
if ( (v4 & 1) != 0 )
{
v5 = *((_QWORD *)a1 + 1);
goto LABEL_5;
}
goto LABEL_40;
}
v5 = *((_QWORD *)a1 + 1);
v6 = *((_BYTE **)a1 + 2);
if ( v5 )
{
v19 = (__int64)&v6[v5];
if ( v6 == &v6[v5] )
goto LABEL_4;
goto LABEL_42;
}
LABEL_3:
v5 = 0;
LABEL_4:
v7 = -1;
LABEL_5:
v8 = 0;
while ( 1 )
{
std::string::basic_string(&v21, (__int64)a1, v8, v7 - v8);
v9 = v21 & 1;
v10 = (unsigned __int8)v21 >> 1;
if ( (v21 & 1) != 0 )
v10 = v22;
if ( !v10 && v8 == v5 )
goto LABEL_16;
v11 = (__int64 *)a2[1];
if ( v11 != (__int64 *)a2[2] )
{
if ( v11 )
{
*v11 = 0;
v11[1] = 0;
v12 = v21;
v11[2] = 0;
if ( (v12 & 1) != 0 )
{
std::string::__init(v11, v23, v22);
}
else
{
v13 = v22;
*v11 = v21;
v11[1] = v13;
v11[2] = (__int64)v23;
}
v11 = (__int64 *)a2[1];
v9 = v21 & 1;
}
a2[1] = (__int64)(v11 + 3);
LABEL_16:
if ( v7 == -1 )
break;
goto LABEL_17;
}
std::vector::__push_back_slow_path(a2, &v21);
v9 = v21 & 1;
if ( v7 == -1 )
break;
LABEL_17:
v8 = v7 + 1;
if ( (*a1 & 1) != 0 )
{
v14 = *((unsigned __int8 **)a1 + 2);
v15 = *((_QWORD *)a1 + 1);
}
else
{
v14 = a1 + 1;
v15 = *a1 >> 1;
}
v7 = -1;
if ( v8 >= v15 || (v16 = &v14[v8], v17 = &v14[v15], &v14[v8] == v17) )
{
if ( v9 )
goto LABEL_21;
}
else if ( v14[v8] == 44 )
{
LABEL_30:
v7 = v16 - v14;
if ( v9 )
goto LABEL_21;
}
else
{
while ( v17 != ++v16 )
{
if ( *v16 == 44 )
goto LABEL_30;
}
v7 = -1;
if ( v9 )
LABEL_21:
operator delete(v23);
}
}
if ( v9 )
operator delete(v23);
return _stack_chk_guard;
}