//
// MusicDownloadManager::nameForTagID from 0x833ac8 to 0x833df0 (808 bytes)
//
// 2 xrefs:
// > SongInfoObject::getTagsString @ 0x833f0c
// > ??> @ 0xb45a0
//
// 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 MusicDownloadManager::nameForTagID@(
MusicDownloadManager *this@,
int a2@,
__int64 a3@)
{
std::_rb_tree_base *p_m_header; // x22
std::_rb_tree_base *m_parent; // x19
std::_rb_tree_base *v7; // x4
std::_rb_tree_base *v8; // x0
std::_rb_tree_base *v9; // x21
__int64 v10; // x27
std::map *p_m_musicTags; // x25
__int64 v12; // x28
int v13; // w1
int v14; // w3
std::_rb_tree_base *m_right; // x2
int *v16; // x4
_BOOL8 v17; // x0
char *v19; // x2
__int64 v20; // x0
std::_rb_tree_base *v21; // x1
std::size_t m_nodecount; // x2
__int64 insert_unique_pos; // x0
std::_rb_tree_base *v24; // x1
unsigned int *v25; // x3
int v26; // w1
int v27; // [xsp+70h] [xbp+70h]
int v29; // [xsp+78h] [xbp+78h]
p_m_header = &this->m_musicTags.m_header;
m_parent = this->m_musicTags.m_header.m_parent;
if ( !m_parent )
goto LABEL_27;
v7 = &this->m_musicTags.m_header;
v8 = this->m_musicTags.m_header.m_parent;
do
{
while ( *(_DWORD *)&v8[1].m_isblack >= a2 )
{
v7 = v8;
v8 = v8->m_left;
if ( !v8 )
goto LABEL_5;
}
v8 = v8->m_right;
}
while ( v8 );
LABEL_5:
if ( p_m_header == v7 || *(_DWORD *)&v7[1].m_isblack > a2 )
{
LABEL_27:
sub_D153B8(a3, &byte_F288A0);
return a3;
}
v9 = p_m_header;
do
{
while ( *(_DWORD *)&m_parent[1].m_isblack >= a2 )
{
v9 = m_parent;
m_parent = m_parent->m_left;
if ( !m_parent )
goto LABEL_10;
}
m_parent = m_parent->m_right;
}
while ( m_parent );
LABEL_10:
v10 = (__int64)v9;
if ( p_m_header == v9 )
{
p_m_musicTags = &this->m_musicTags;
v12 = operator new(0x30u);
m_nodecount = this->m_musicTags.m_nodecount;
*(_DWORD *)(v12 + 32) = a2;
*(_QWORD *)(v12 + 40) = &byte_124B6C8;
if ( !m_nodecount || (m_right = this->m_musicTags.m_header.m_right, *(_DWORD *)&m_right[1].m_isblack >= a2) )
{
insert_unique_pos = std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::_M_get_insert_unique_pos(
(__int64)&this->m_musicTags,
(int *)(v12 + 32));
m_right = v24;
v10 = insert_unique_pos;
if ( !v24 )
goto LABEL_50;
goto LABEL_17;
}
goto LABEL_35;
}
if ( *(_DWORD *)&v9[1].m_isblack > a2 )
{
p_m_musicTags = &this->m_musicTags;
v12 = operator new(0x30u);
v13 = a2;
*(_DWORD *)(v12 + 32) = a2;
v14 = *(_DWORD *)&v9[1].m_isblack;
*(_QWORD *)(v12 + 40) = &byte_124B6C8;
if ( v14 > a2 )
{
if ( this->m_musicTags.m_header.m_left == v9 )
goto LABEL_16;
m_right = (std::_rb_tree_base *)sub_CFABD4(v9);
v16 = (int *)(v12 + 32);
if ( *(_DWORD *)&m_right[1].m_isblack < a2 )
{
if ( m_right->m_right )
{
LABEL_16:
m_right = v9;
if ( v9 )
goto LABEL_17;
goto LABEL_50;
}
goto LABEL_35;
}
LABEL_38:
v20 = std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::_M_get_insert_unique_pos(
(__int64)&this->m_musicTags,
v16);
m_right = v21;
v10 = v20;
if ( !v21 )
{
LABEL_50:
v19 = *(char **)(v12 + 40);
goto LABEL_36;
}
LABEL_17:
if ( v10 || p_m_header == m_right )
{
v17 = 1;
goto LABEL_21;
}
v13 = *(_DWORD *)(v12 + 32);
v14 = *(_DWORD *)&m_right[1].m_isblack;
LABEL_20:
v17 = v14 > v13;
LABEL_21:
sub_CFAD74(v17, v12, m_right, p_m_header);
++p_m_musicTags->m_nodecount;
goto LABEL_22;
}
if ( v14 >= a2 )
{
v19 = &byte_124B6C8;
LABEL_36:
if ( v19 - 24 != (char *)&qword_124B6B0 )
{
v25 = (unsigned int *)(v19 - 8);
if ( &pthread_create )
{
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *((_DWORD *)v19 - 2);
*((_DWORD *)v19 - 2) = v26 - 1;
}
if ( v26 <= 0 )
operator delete(v19 - 24);
}
operator delete((void *)v12);
goto LABEL_22;
}
if ( this->m_musicTags.m_header.m_right == v9 )
goto LABEL_44;
v27 = a2;
v29 = v14;
m_parent = (std::_rb_tree_base *)sub_CFAB14(v9);
v13 = v27;
v16 = (int *)(v12 + 32);
if ( *(_DWORD *)&m_parent[1].m_isblack <= v27 )
goto LABEL_38;
v14 = v29;
if ( !v9->m_right )
{
LABEL_44:
m_right = v9;
goto LABEL_20;
}
m_right = m_parent;
LABEL_35:
v10 = (__int64)m_parent;
goto LABEL_17;
}
LABEL_22:
sub_D18D28(a3);
return a3;
}